- .
public enum SpeechPart
{
NOUN ("noun"),
PLURAL ("plural"),
NOUNPHRASE ("noun phrase"),
ADVERB ("adverb"),
ADJECTIVE ("adjective"),
CONJUNCTION ("conjunction"),
VERB ("verb");
private String english;
SpeechPart(String inEnglish)
{
this.english = inEnglish;
}
public String toString() { return english; }
}
.
SpeechPart dog = SpeechPart.NOUN;
SpeechPart ran = SpeechPart.VERB;
SpeechPart quickly = SpeechPart.ADVERB;
, :
System.out.println(dog.toString());
System.out.println(quickly);
. , " ", " ", " ", "", "" .., - , , , Decorator Pattern, .
- :
public enum SpeechModifier
{
SINGULAR,
PLURAL,
FIRST_PERSON,
SECOND_PERSON,
THIRD_PERSON,
PRESENT,
PAST,
PERFECT,
PROGRESSIVE;
}
, :
public class Word
{
String word;
SpeechPart part;
EnumSet<SpeechModifier> modifiers;
}
:
Word w1 = new Word();
w1.word = "bouncing";
w1.part = SpeechPart.VERB;
w1.modifiers = EnumSet<SpeechModifier>.of(SpeechModifier.PRESENT, SpeechModifier.PROGRESSIVE);
, , , FIRST_PERSON NOUN PAST.