Skip to content

Instantly share code, notes, and snippets.

@JonasWanke
Last active November 7, 2019 08:17
Show Gist options
  • Save JonasWanke/e1dc61b556d6cedd4bbf14a03afed981 to your computer and use it in GitHub Desktop.
Save JonasWanke/e1dc61b556d6cedd4bbf14a03afed981 to your computer and use it in GitHub Desktop.
MobileDev: Kotlin-Workshop — student before
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