mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-03 05:20:09 +00:00
Improved Hero#toString.
This commit is contained in:
1 parent
62b871774a
commit
ca59c97510
1 file changed
+2
-1
@@ -42,6 +42,7 @@ public class Hero {
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("This is a ");
|
||||
sb.append(profession);
|
||||
sb.append(" named ");
|
||||
sb.append(name);
|
||||
@@ -62,7 +63,7 @@ public class Hero {
|
||||
sb.append(armor);
|
||||
}
|
||||
if (weapon != null) {
|
||||
sb.append(" and wielding ");
|
||||
sb.append(" and wielding a ");
|
||||
sb.append(weapon);
|
||||
}
|
||||
sb.append(".");
|
||||
|
||||
Reference in new issue
Block a user