Skip to content

Commit

Permalink
[refactor] Update WeaponType enum in factory-method pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslanpa committed Feb 9, 2015
1 parent bd4cecd commit eb9b5fd
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions factory-method/src/main/java/com/iluwatar/WeaponType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

public enum WeaponType {

SHORT_SWORD, SPEAR, AXE;
SHORT_SWORD("short sword"), SPEAR("spear"), AXE("axe"), UNDEFINED("");

@Override
private String title;

WeaponType(String title) {
this.title = title;
}

@Override
public String toString() {
String s = "";
switch (this) {
case SHORT_SWORD:
s = "short sword";
break;
case SPEAR:
s = "spear";
break;
case AXE:
s = "axe";
break;
}
return s;
return title;
}

}

0 comments on commit eb9b5fd

Please sign in to comment.