-
-
Save NatashaTheRobot/2f0b83b483a49917ea04 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
protocol AgeClasificationProtocol { | |
var age: Int { get } | |
func agetype() -> String | |
} | |
class Person { | |
var firstname: String | |
var lastname: String | |
var age: Int | |
init(firstname: String, lastname: String) { | |
self.firstname = firstname | |
self.lastname = lastname | |
self.age = 10 | |
} | |
} | |
extension Person: AgeClasificationProtocol { | |
func fullname() -> String { | |
return firstname + " " + lastname | |
} | |
func agetype() -> String { | |
switch age { | |
case 0...2: | |
return "Baby" | |
case 2...12: | |
return "Child" | |
case 13...19: | |
return "Teenager" | |
case let x where x > 65: | |
return "Elderly" | |
default: | |
return "Normal" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment