mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 12:14:51 +00:00
Improves a toString method.
Makes it more readable and deletes an useless semicolon.
This commit is contained in:
1 parent
a4637fcf99
commit
bc060309e3
1 file changed
+6
-13
@@ -6,23 +6,16 @@ public enum Action {
|
|||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
String s = "";
|
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ENEMY:
|
case ENEMY:
|
||||||
s = "spotted enemies";
|
return "spotted enemies";
|
||||||
break;
|
|
||||||
case GOLD:
|
case GOLD:
|
||||||
s = "found gold";
|
return "found gold";
|
||||||
break;
|
|
||||||
case HUNT:
|
case HUNT:
|
||||||
s = "hunted a rabbit";
|
return "hunted a rabbit";
|
||||||
break;
|
|
||||||
case TALE:
|
case TALE:
|
||||||
s = "tells a tale";
|
return "tells a tale";
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return s;
|
return "";
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user