Last active
November 7, 2019 08:17
-
-
Save JonasWanke/e1dc61b556d6cedd4bbf14a03afed981 to your computer and use it in GitHub Desktop.
MobileDev: Kotlin-Workshop — student before
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
fun main() { | |
val john: Student = Student("John Doe", 19) | |
println(john.getName() + ", " + john.getAge()) | |
} | |
/** | |
* _This_ `class` represents a __single__ [Student]. | |
*/ | |
class Student { | |
private val name: String | |
private val age: Int | |
constructor(name: String, age: Int) { | |
this.name = name | |
this.age = age | |
} | |
fun getName(): String { | |
return name | |
} | |
fun getAge(): Int { | |
return age | |
} | |
} | |
fun ageGroup(age: Int): String { | |
if (age < 13) return "Child" | |
else if (age < 20) return "Teenager" | |
else return "Adult" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment