Created
August 11, 2014 08:48
-
-
Save kyonmm/2da2eaa796c03b16c277 to your computer and use it in GitHub Desktop.
DCIかどうか知らんが、おれが書きたいのはこういうのをもうちょっときれいに書くことだ。
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
import groovy.transform.TupleConstructor | |
Object.metaClass.addRole = {role -> | |
delegate.metaClass.mixin role | |
} | |
@TupleConstructor | |
class InFrontOfWoman { | |
def he | |
InFrontOfWoman(コミュ障 people){ | |
people.addRole(Hangdog) | |
this.he = people | |
} | |
InFrontOfWoman(リア充 people){ | |
people.addRole(Confident) | |
this.he = people | |
} | |
} | |
class InFrontOfFriends{ | |
def he | |
InFrontOfFriends(コミュ障 people){ | |
people.addRole(Confident) | |
this.he = people | |
} | |
InFrontOfFriends(リア充 people){ | |
people.addRole(Confident) | |
this.he = people | |
} | |
} | |
class Confident{ | |
String speak(){ | |
"$name です!よろしくねー。" | |
} | |
} | |
class Hangdog{ | |
String speak(){ | |
"えっと。。。あの。。。" | |
} | |
String chuckIt(){ | |
"" | |
} | |
} | |
class People{ | |
def name | |
} | |
class コミュ障 extends People{ | |
} | |
class リア充 extends People{ | |
} | |
def yamada = new リア充(name:"山田太郎"); | |
assert new InFrontOfWoman(yamada).he.speak() == "山田太郎 です!よろしくねー。" | |
assert new InFrontOfFriends(yamada).he.speak() == "山田太郎 です!よろしくねー。" | |
def sato = new コミュ障(name:"佐藤次郎"); | |
assert new InFrontOfWoman(sato).he.speak() == "えっと。。。あの。。。" | |
assert new InFrontOfFriends(sato).he.speak() == "佐藤次郎 です!よろしくねー。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍