Permalink
Browse files

Merge branch 'feature/properties' into develop

  • Loading branch information...
gonzapico committed Apr 22, 2017
2 parents 12ee262 + 89a4350 commit 4348a919096b41ba18652ab2936fbef80a5424dd
Showing with 17 additions and 5 deletions.
  1. +17 −5 app/src/main/java/xyz/gonzapico/myfirstkotlinapp/Person.kt
@@ -3,11 +3,23 @@ package xyz.gonzapico.myfirstkotlinapp
/**
* Created by gfernandez on 22/04/17.
*/
abstract class Person(val name: String, val age: Int)
// Open by default
class Developer(name: String) : Person(name, 24)
class Person(name: String, age: Int){
// To change functionality in getter and/or setter
// Without constructor
class MyDeveloper(val name: String = "", val age: Int = 20) {
var name = name
get() = "Name -> $field"
set(value){
if (value.isNotEmpty()){
field = value
}
}
var age = age
}
fun testClass(){
val person = Person("Anto", 33)
val name = person.name
person.name = "Miguel"
}

0 comments on commit 4348a91

Please sign in to comment.