Skip to content

Instantly share code, notes, and snippets.

@paulthegeek
Last active June 24, 2016 05:26
Show Gist options
  • Save paulthegeek/ccb0dbf0e9c6c907b1642a6b0d7611f7 to your computer and use it in GitHub Desktop.
Save paulthegeek/ccb0dbf0e9c6c907b1642a6b0d7611f7 to your computer and use it in GitHub Desktop.
class Point {
var x: Int
var y: Int
init(x: Int, y: Int){
self.x = x
self.y = y
}
}
class Machine {
var location: Point
init() {
self.location = Point(x: 0, y: 0)
}
func move(direction: String) {
print("Do nothing! I'm a machine!")
}
}
class Robot: Machine {
override func move(direction: String) {
switch direction {
case "Up": location.y += 1
case "Down": location.y -= 1
case "Left": location.x -= 1
case "Right": location.x += 1
default: break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment