Last active
August 29, 2015 14:06
-
-
Save nanase/7513e3c485171ab952a8 to your computer and use it in GitHub Desktop.
notepad-lang独自案
This file contains hidden or 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
| abstract class Person: | |
| # protected | |
| prop trueAge [get, private set] | |
| abstract prop age [get] | |
| # public | |
| def me(age): | |
| me.trueAge = age | |
| def tellAge => "私は\(me.age)歳です。" | |
| class HonestPerson extends Person: | |
| protected prop age => me.trueAge | |
| class Liar extends Person: | |
| protected prop age => me.trueAge but if $ > 40 then $ / 2 | |
| var mike = new HonestPerson(20) | |
| var ken = new Liar(20) | |
| println "mike: " ~ mike.tellAge | |
| println "ken: " ~ ken.tellAge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment