Created
August 23, 2015 09:44
-
-
Save kazuhito-m/29b695d28afb0463d6dc to your computer and use it in GitHub Desktop.
「どんな大きさが好きか、コードで示せ」って言われたので…。
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
public class KazuhitoM { | |
public static void main(String[] args) { | |
KazuhitoM self = new KazuhitoM(); | |
System.out.println(String.format("%s が好きなのは %s 感じのです。" | |
, self.getClass().getCanonicalName() | |
, self.getLikeSize().getCaption())); | |
} | |
/** | |
* 好きなサイズを返す。 | |
* | |
* @return タイプ。 | |
*/ | |
public SizeType getLikeSize() { | |
return SizeType.values()[SizeType.values().length / 2]; | |
} | |
enum SizeType { | |
SMALL("小さい"), | |
MIDDLE("中くらい"), | |
LARGE("巨大な"); | |
private String caption; | |
private SizeType(String caption) { | |
this.caption = caption; | |
} | |
public String getCaption() { | |
return caption; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment