Enums and Structs
{
case red
case blue
case green
}
import UIKit
enum PrimaryColor {
case red
case blue
case yellow
}
enum Aunties {
case Aime, Billie, Diane, Gail, Janie, Pam
}
enum AmericanLeagueWest: String {
case As = "Oakland"
case Astros = "Houston"
case Angels = "Los Angeles"
case Mariners = "Seatle"
case Rangers = "Arlington"
}
enum CaliforniaPark {
case Yosemite, DeathValley, Lesson, Sequoia
}
var warning = ""
var destination = CaliforniaPark.Yosemite
switch destination {
case.Yosemite:
warning = "Beware of agressive bears!"
case.DeathValley:
warning = "Beware of dehydration!"
case.Lasson:
warning = "Watch out for boiling pools!"
}
struct PictureFrame {
var width = 5
var height = 7
var thickness: Double = 1.5
var area: Int {
get {
return width * height
}
}
}
var frame = PictureFrame(width: 3, height: 5, thickness: 0.5)
var frameForMom = frame
frameForMom.width = 5
frameForMom.height = 7
frame.width
frame.height
class ClassyPictureFrame {
var width = 5
var height = 7
var thickness: Double = 1.5
var area: Int {
get {
return (width * height) / 2
}
}
init(width: Int, height: Int, thickness: Double){
self.width = width
self.height = height
self.thickness = thickness
}
}
var classyFrame = ClassyPictureFrame(width: 3, height: 5, thickness: 0.5)
var classyFrameForMom = classyFrame
var darkColors = Laundry(temperature: 70, speed: "medium")
var darkDelicates = darkColors
darkDelicates.speed = "low"
darkColors.speed
Triangle {
let angles = [30, 60, 90]
let sides = [3,4,5]
}
UIImagePickerControllerSourceType : Int {
case PhotoLibrary
case Camera
case SavedPhotosAlbum
}
struck Name {
var firstName: String
var lastName: String
}
enum Subject {
case Math
case English
case Spanish
case Science
}