Last active
March 18, 2018 08:14
-
-
Save VintageAppMaker/7efa24e5fcf4e2fc0b56afe2eede9327 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
class 회사평가 { | |
val m = mapOf<String, Int>( | |
"일이좋다" to 25, | |
"자부심" to 30, | |
"높은연봉" to 25, | |
"유명회사" to 20, | |
"야근당연" to -60) | |
var 만족도 : Int = 0 | |
// infix는 확장함수나 멤버함수로 구현되어야 한다. | |
infix fun 추가(s : String) : Int{ | |
this.만족도 += m[s]!! | |
return this.만족도 | |
} | |
} | |
fun main(args: Array<String>) { | |
// 삶은 이런 것!! | |
var 내회사 = 회사평가() | |
내회사 추가 "일이좋다" | |
내회사 추가 "자부심" | |
내회사 추가 "높은연봉" | |
내회사 추가 "유명회사" | |
내회사 추가 "야근당연" | |
println(내회사.만족도) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
결과화면
![image](https://user-images.githubusercontent.com/31234716/37563824-a3fe2cd2-2acc-11e8-88f4-0da63a2697ae.png)