Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct User {
- var fullName: String
- var email: String
- var age: Int
- }
- var someUser = User(fullName: "Pasan Premaratne", email: "pasan@teamtreehouse.com", age: 28)
- var anotherUser = someUser
- someUser.email = "pasan.premaratne@gmail.com"
- class Person {
- var fullName: String
- var email: String
- var age: Int
- init(name: String, email: String, age:Int) {
- self.fullName = name
- self.email = email
- self.age = age
- }
- }
- var somePerson = Person(name: "Tim Cook", email: "tim.cook@gmail.com", age: 58)
- var anotherPerson = somePerson
- somePerson.email = "tcook@email.com"
- anotherPerson.email
- 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 am a machine!")
- }
- }
- // Enter your code below
- class Robot : Machine {
- override func move(_ direction: String) {
- switch direction {
- case "up": self.location.y += 1
- case "down": self.location.y -= 1
- case "left": self.location.x -= 1
- case "right": self.location.x += 1
- default: break
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement