Skip to content

Instantly share code, notes, and snippets.

@5ldkamal
Created June 19, 2019 11:09
Show Gist options
  • Save 5ldkamal/7f458708ed5bdc61fadb8ecce6f57e8d to your computer and use it in GitHub Desktop.
Save 5ldkamal/7f458708ed5bdc61fadb8ecce6f57e8d to your computer and use it in GitHub Desktop.
//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