Last active
June 24, 2016 05:26
-
-
Save paulthegeek/ccb0dbf0e9c6c907b1642a6b0d7611f7 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
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