Created
June 19, 2019 11:09
-
-
Save 5ldkamal/7f458708ed5bdc61fadb8ecce6f57e8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MARK:- AirCondition Actions | |
protocol SwitchProtocol { | |
func turnon() | |
func turnoff() | |
} | |
protocol ModeProtocol { | |
func changeMode() | |
} | |
protocol FanProtocol { | |
func controlWindSpeed() | |
} | |
class Switcher: SwitchProtocol | |
{ | |
func turnon() { | |
//implementation | |
} | |
func turnoff() { | |
//implementation | |
} | |
} | |
class Mode: ModeProtocol | |
{ | |
func changeMode() { | |
//implementation | |
} | |
} | |
class FanWind: FanProtocol | |
{ | |
func controlWindSpeed() { | |
//implementation | |
} | |
} | |
class AirCondition : FanProtocol , ModeProtocol , SwitchProtocol | |
{ | |
let switcher : SwitchProtocol | |
let mode : ModeProtocol | |
let fanWind : FanProtocol | |
init(switcher : SwitchProtocol , mode : ModeProtocol,fanWind : FanProtocol) { | |
self.switcher = switcher | |
self.mode = mode | |
self.fanWind = fanWind | |
} | |
// | |
func turnon() { | |
switcher.turnoff() | |
} | |
func turnoff() { | |
switcher.turnoff() | |
} | |
// | |
func changeMode() { | |
mode.changeMode() | |
} | |
// | |
func controlWindSpeed() { | |
fanWind.controlWindSpeed() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment