Skip to content

Instantly share code, notes, and snippets.

@kazuhito-m
Created August 23, 2015 09:44
Show Gist options
  • Save kazuhito-m/29b695d28afb0463d6dc to your computer and use it in GitHub Desktop.
Save kazuhito-m/29b695d28afb0463d6dc to your computer and use it in GitHub Desktop.
「どんな大きさが好きか、コードで示せ」って言われたので…。
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