Created
August 17, 2019 11:11
-
-
Save rail-rate/003fa9defb202a9aab683417b861f9f4 to your computer and use it in GitHub Desktop.
class3
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(args: Array<String>) { | |
val a = Test() //インスタンスを生成 | |
a.name = "山田" //Testクラスの変数に値を入れる | |
a.age = 20 //上記同様 | |
a.hello() //hello関数を呼び出してみる | |
a.konnichiha() //konnichiha関数を呼び出してみる | |
a.nihao() //nihao関数を呼び出してみる | |
}//main | |
class Test{ | |
var name = "" | |
var age = 0 | |
fun hello(){ | |
println("${name}です。${age}です。HELLO!") | |
}//hello | |
fun konnichiha(){ | |
println("${name}です。${age}です。こんにちは!") | |
}//konnichiha | |
fun nihao(){ | |
println("${name}です。${age}です。ニーハオ!") | |
}//nihao | |
}//Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment