Skip to content

Instantly share code, notes, and snippets.

@nooglersoon
Created June 4, 2020 00:41
Show Gist options
  • Save nooglersoon/5370bdba153dc455357b839d2c6b6f30 to your computer and use it in GitHub Desktop.
Save nooglersoon/5370bdba153dc455357b839d2c6b6f30 to your computer and use it in GitHub Desktop.
Medium Session: Introduction to Swift's OOP in Indonesia - Part 1C
class Mobil {
func startEngine () {
engineStart = true
print("Engine is Started!")
}
func offEngine () {
engineStart = false
}
func carStatus (_ status: String) -> String {
if engineStart {
switch status {
case "P":
return " You are in \(statusList[0]) mode! "
case "R":
return " You are in \(statusList[1]) mode! "
case "N":
return " You are in \(statusList[2]) mode! "
case "D":
return " You are in \(statusList[3]) mode! "
default:
return "You have never drive"
}
}else{
return "Your car hasn't started"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment