diff --git a/.DS_Store b/.DS_Store index 1e85c6a..6d51db5 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Playground.swift b/Playground.swift index d247281..e11b5f7 100644 --- a/Playground.swift +++ b/Playground.swift @@ -1,11 +1,25 @@ // https://carrascomolina.com import Playgrounds +import Foundation protocol Vehicle { // name ist read-only var name: String {get} var color: String {get set} } +protocol Garage { + associatedtype V: Vehicle + func park(vehicle: V) + +} + +struct BikeGarage: Garage { + + + func park(vehicle: Bike){ + vehicle.emptyBasket() + } +} struct Train: Vehicle { var name: String @@ -24,10 +38,13 @@ struct ICE: Vehicle { var color = "white" } -struct Bike: Vehicle { +struct Bike: Vehicle, CustomStringConvertible { var name: String var color: String // newValue ist ein special keyword + func emptyBasket(){ + print(description + " korb ausgekippt", Date()) + } var description: String { set { name = newValue } get {"A bike called \(name) and it is \(color)." }} @@ -35,15 +52,16 @@ struct Bike: Vehicle { } #Playground { - var greeting = "Hallo Playground" - var bike = Bike.trek + // var greeting = "Hallo Playground" + var bike = Bike.trek var train = Train(name:"ICE") - bike.description - bike.description = "Mein Rad" - bike.description + // bike.description + // bike.description = "Mein Rad" + // bike.description train train.delayed(minutes: 23) - + BikeGarage().park(vehicle: bike) + print( bike) // write code here } diff --git a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate index d34902b..43f4aa0 100644 Binary files a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate and b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TheSwiftWeek.xcodeproj/xcuserdata/rohing73.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TheSwiftWeek.xcodeproj/xcuserdata/rohing73.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..19e0a0e --- /dev/null +++ b/TheSwiftWeek.xcodeproj/xcuserdata/rohing73.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,24 @@ + + + + + + + + +