Created
February 16, 2015 12:12
-
-
Save mizdra/32c973111453539e1d17 to your computer and use it in GitHub Desktop.
ポケモンの性格の列挙型
This file contains 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
/* | |
* Nature.java | |
* Copyright (c) 2015 mizdra | |
* License: MIT License | |
*/ | |
import java.util.Locale; | |
public enum Nature { | |
Hardy(0, Locale.ENGLISH), Lonely(1, Locale.ENGLISH), Brave(2, Locale.ENGLISH), Adamant(3, Locale.ENGLISH), Naughty(4, Locale.ENGLISH), | |
Bold(5, Locale.ENGLISH), Docile(6, Locale.ENGLISH), Relaxed(7, Locale.ENGLISH), Impish(8, Locale.ENGLISH), Lax(9, Locale.ENGLISH), | |
Timid(10, Locale.ENGLISH), Hasty(11, Locale.ENGLISH), Serious(12, Locale.ENGLISH), Jolly(13, Locale.ENGLISH), Naive(14, Locale.ENGLISH), | |
Modest(15, Locale.ENGLISH), Mild(16, Locale.ENGLISH), Quiet(17, Locale.ENGLISH), Bashful(18, Locale.ENGLISH), Rash(19, Locale.ENGLISH), | |
Calm(20, Locale.ENGLISH), Gentle(21, Locale.ENGLISH), Sassy(22, Locale.ENGLISH), Careful(23, Locale.ENGLISH), Quirky(24, Locale.ENGLISH), | |
がんばりや(0, Locale.JAPANESE), さみしがり(1, Locale.JAPANESE), ゆうかん(2, Locale.JAPANESE), いじっぱり(3, Locale.JAPANESE), やんちゃ(4, Locale.JAPANESE), | |
ずぶとい(5, Locale.JAPANESE), すなお(6, Locale.JAPANESE), のんき(7, Locale.JAPANESE), わんぱく(8, Locale.JAPANESE), のうてんき(9, Locale.JAPANESE), | |
おくびょう(10, Locale.JAPANESE), せっかち(11, Locale.JAPANESE), まじめ(12, Locale.JAPANESE), ようき(13, Locale.JAPANESE), むじゃき(14, Locale.JAPANESE), | |
ひかえめ(15, Locale.JAPANESE), おっとり(16, Locale.JAPANESE), れいせい(17, Locale.JAPANESE), てれや(18, Locale.JAPANESE), うっかりや(19, Locale.JAPANESE), | |
おだやか(20, Locale.JAPANESE), おとなしい(21, Locale.JAPANESE), なまいき(22, Locale.JAPANESE), しんちょう(23, Locale.JAPANESE), きまぐれ(24, Locale.JAPANESE); | |
private final int value; | |
private final Locale lang; | |
private Nature(int value, Locale lang) { | |
this.value = value; | |
this.lang = lang; | |
} | |
// Nature.がんばりや.toInt(); // -> 0 | |
public int toInt() { | |
return this.value; | |
} | |
// Nature.がんばりや.toLocale(); // -> ja | |
public Locale toLocale() { | |
return this.lang; | |
} | |
// Nature.がんばりや.translate(Locale.ENGLISH); // -> Hardy | |
public Nature translate(Locale lang){ | |
for (Nature n : values()) | |
if (n.value == value && n.lang == lang) | |
return n; | |
throw new IllegalArgumentException(); | |
} | |
// Nature.fromInt(0); // -> Hardy | |
public static Nature fromInt(int value){ | |
return fromInt(value, Locale.ENGLISH); | |
} | |
// Nature.fromInt(0, Locale.JAPANESE); // -> がんばりや | |
public static Nature fromInt(int value, Locale lang){ | |
for (Nature n : values()) | |
if (n.value == value && n.lang == lang) | |
return n; | |
throw new IllegalArgumentException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment