protocol + func
This commit is contained in:
parent
cd3d32a6b9
commit
64da46dc27
3 changed files with 11 additions and 1 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
|
@ -10,6 +10,13 @@ protocol Vehicle {
|
||||||
struct Train: Vehicle {
|
struct Train: Vehicle {
|
||||||
var name: String
|
var name: String
|
||||||
var color = "white"
|
var color = "white"
|
||||||
|
var delay = 0 // nicht im protocol
|
||||||
|
func delayed(minutes: Int) -> Train {
|
||||||
|
var train = self
|
||||||
|
train.delay = minutes
|
||||||
|
return train
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ICE: Vehicle {
|
struct ICE: Vehicle {
|
||||||
|
|
@ -30,10 +37,13 @@ struct Bike: Vehicle {
|
||||||
#Playground {
|
#Playground {
|
||||||
var greeting = "Hallo Playground"
|
var greeting = "Hallo Playground"
|
||||||
var bike = Bike.trek
|
var bike = Bike.trek
|
||||||
var train = Train(name:"TGV")
|
var train = Train(name:"ICE")
|
||||||
bike.description
|
bike.description
|
||||||
bike.description = "Mein Rad"
|
bike.description = "Mein Rad"
|
||||||
bike.description
|
bike.description
|
||||||
|
|
||||||
train
|
train
|
||||||
|
train.delayed(minutes: 23)
|
||||||
|
|
||||||
// write code here
|
// write code here
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue