import java.util.Scanner;
public class Main {
public static void main
(String[] args
) {
IAnimalProvider provider = new AnimalProviderFactory().createProvider();
Scanner scn
= new Scanner
(System.
in);
String strAnimals
= "(" + Utils.
join(provider.
names(),
", ") + ")";
do {
System.
out.
print("動物名を入力してください"); System.
out.
println(strAnimals
); } while( listen(provider.find(scn.next()) ) );
}
public static boolean listen(ISoundMaker sm){
if( sm != null ){
System.
out.
println(sm.
makeSound()); return true;
}
return false;
}
public static class Utils {
if( ss.length > 0 ){ res = ss[0]; }
for( int i = 1; i < ss.length; i++ ){
res += sep + ss[i];
}
return res;
}
}
static class AnimalProviderFactory {
public AnimalProviderFactory(){}
public IAnimalProvider createProvider(){
return new SimpleAnimalProvider( new IAnimal[] {
new SimpleAnimal("いぬ","わおーん")
, new SimpleAnimal("ねこ","にゃおーん")
, new SimpleAnimal("らいおん","がおーん")
, new SimpleAnimal("うし","もおーん")
, new UtyuuTeikokuHei("A","宇宙和平連合軍が何の用だ。この惑星は、我々が先に目を付けた惑星だぞ")
, new UtyuuTeikokuHei("B","大人しく身を引いた方が身の為だぞ。さもなくば、命の保証はない!")
, new UtyuuTeikokuHei("C","お前たちは、おとなしく宇宙のゴミ掃除でもしておけよ。はははは!")
});
}
}
static interface ISoundMaker {
}
static interface INamedOne {
}
static interface IAnimal
extends ISoundMaker, INamedOne {}
static interface IAnimalProvider {
public IAnimal find
(String s
); }
static class SimpleAnimal implements IAnimal {
mSound = sound;
mName = name;
}
public String makeSound
(){ return mSound
; } public String getName
(){ return mName
; } }
static class UtyuuTeikokuHei implements IAnimal {
IAnimal mAnimDel;
mAnimDel = new SimpleAnimal("宇宙帝国兵"+id,"「"+serief+"」\nクルッ");
}
public String getName
(){ return mAnimDel.
getName(); } public String makeSound
(){ return mAnimDel.
makeSound(); } }
static class SimpleAnimalProvider implements IAnimalProvider {
IAnimal[] mAnimalArray;
public SimpleAnimalProvider(IAnimal[] arr){
mAnimalArray = arr;
mCachedNames
= new String[mAnimalArray.
length]; for( int i = 0; i < mAnimalArray.length; i++ ){
mCachedNames[i] = mAnimalArray[i].getName();
}
}
public IAnimal find
(String s
){ for( IAnimal animal: mAnimalArray ){
if( animal.getName().equals(s) ){
return animal;
}
}
return null;
}
return java.
util.
Arrays.
copyOf(mCachedNames,mCachedNames.
length); }
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwogCnB1YmxpYyBjbGFzcyBNYWluIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKCiAgICAJSUFuaW1hbFByb3ZpZGVyIHByb3ZpZGVyID0gbmV3IEFuaW1hbFByb3ZpZGVyRmFjdG9yeSgpLmNyZWF0ZVByb3ZpZGVyKCk7CiAgICAgICAgU2Nhbm5lciBzY24gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgCiAgICAgICAgU3RyaW5nIHN0ckFuaW1hbHMgPSAiKCIgKyBVdGlscy5qb2luKHByb3ZpZGVyLm5hbWVzKCksIiwgIikgKyAiKSI7CgoJCWRvIHsKCSAgICAgICAgU3lzdGVtLm91dC5wcmludCgi5YuV54mp5ZCN44KS5YWl5Yqb44GX44Gm44GP44Gg44GV44GEIik7CgkgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihzdHJBbmltYWxzKTsKCSAgICAgICAgU3lzdGVtLm91dC5wcmludCgiPiAiKTsKCQl9IHdoaWxlKCBsaXN0ZW4ocHJvdmlkZXIuZmluZChzY24ubmV4dCgpKSApICk7CiAgICB9CiAgICAKICAgIHB1YmxpYyBzdGF0aWMgYm9vbGVhbiBsaXN0ZW4oSVNvdW5kTWFrZXIgc20pewogICAgICAgIGlmKCBzbSAhPSBudWxsICl7CiAgICAgICAgCVN5c3RlbS5vdXQucHJpbnRsbihzbS5tYWtlU291bmQoKSk7CiAgICAgICAgCXJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgoJcHVibGljIHN0YXRpYyBjbG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uYW1lcygpewoJCQlyZXR1cm4gamF2YS51dGlsLkFycmF5cy5jb3B5T2YobUNhY2hlZE5hbWVzLG1DYWNoZWROYW1lcy5sZW5ndGgpOwoJCX0KCX0KfQ==
動物名を入力してください(いぬ, ねこ, らいおん, うし, 宇宙帝国兵A, 宇宙帝国兵B, 宇宙帝国兵C)
> わおーん
動物名を入力してください(いぬ, ねこ, らいおん, うし, 宇宙帝国兵A, 宇宙帝国兵B, 宇宙帝国兵C)
> がおーん
動物名を入力してください(いぬ, ねこ, らいおん, うし, 宇宙帝国兵A, 宇宙帝国兵B, 宇宙帝国兵C)
> 「お前たちは、おとなしく宇宙のゴミ掃除でもしておけよ。はははは!」
クルッ
動物名を入力してください(いぬ, ねこ, らいおん, うし, 宇宙帝国兵A, 宇宙帝国兵B, 宇宙帝国兵C)
>