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
// Management Function | |
func handleCarStarted() | |
{ | |
turnLights(on: true) | |
turnAC(on: true | |
} |
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
// Router Function | |
private func turnLights(on shouldTurnLightsOn: Bool) | |
{ | |
if shouldTurnLightsOn | |
{ | |
turnExteriorLightsOn() | |
checkForBurnedBulbs() | |
} | |
else { turnExteriorLightsOff() } | |
// When an if statment has only 1 thing to execute i like to write it |
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
// Execution Functions | |
private func turnExteriorLightsOn() | |
{ | |
leftFrontLight .isOn = true | |
rightFrontLight.isOn = true | |
leftBackLight .isOn = true | |
rightBackLight .isOn = true | |
} | |
private func checkForBurnedBulbs() | |
{ |
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
class Car: Vehicle { | |
// Informer Functions | |
override func engineStarted() { | |
super.engineStarted() | |
handleCarStarted() | |
} | |
// Management Functions | |
private func handleCarStarted() { |
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
extension Car { | |
// Execution Functions | |
private func turnExteriorLightsOn() { | |
leftFrontLight .isOn = true | |
rightFrontLight.isOn = true | |
leftBackLight .isOn = true | |
rightBackLight .isOn = true | |
} | |
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
private var positionedVerticaly: Bool { | |
return view.frame.width/2 == centerX | |
} | |
if positionedVerticaly | |
if positionedVerticaly && positionedHorizontally | |
VS | |
if isPositionedVerticaly | |
if isPositionedVerticaly && isPositionedHorizontally |
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
public var isPositionedVerticaly: Bool { | |
return positionedVerticaly | |
} | |
if containerView.isPositionedVerticaly |
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
delegate.dataHasUpdated() | |
func dataHasUpdated() { | |
//Someone is informing you that something has happened | |
} |
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
if let date = dateFormatter.parseDate(from: string) { | |
postUploadDate = date | |
} |
OlderNewer