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 {
|
||||
var name: String
|
||||
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 {
|
||||
|
|
@ -30,10 +37,13 @@ struct Bike: Vehicle {
|
|||
#Playground {
|
||||
var greeting = "Hallo Playground"
|
||||
var bike = Bike.trek
|
||||
var train = Train(name:"TGV")
|
||||
var train = Train(name:"ICE")
|
||||
bike.description
|
||||
bike.description = "Mein Rad"
|
||||
bike.description
|
||||
|
||||
train
|
||||
train.delayed(minutes: 23)
|
||||
|
||||
// write code here
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue