mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 08:15:38 +00:00
1 parent
547cf20140
commit
3b2098b80d
1 file changed
+4
-12
+4
-12
@@ -77,21 +77,13 @@ public class PotionFactory {
|
|||||||
var potion = potions.get(type);
|
var potion = potions.get(type);
|
||||||
if (potion == null) {
|
if (potion == null) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HEALING -> {
|
case HEALING -> potion = new HealingPotion();
|
||||||
potion = new HealingPotion();
|
case HOLY_WATER -> potion = new HolyWaterPotion();
|
||||||
potions.put(type, potion);
|
case INVISIBILITY -> potion = new InvisibilityPotion();
|
||||||
}
|
|
||||||
case HOLY_WATER -> {
|
|
||||||
potion = new HolyWaterPotion();
|
|
||||||
potions.put(type, potion);
|
|
||||||
}
|
|
||||||
case INVISIBILITY -> {
|
|
||||||
potion = new InvisibilityPotion();
|
|
||||||
potions.put(type, potion);
|
|
||||||
}
|
|
||||||
default -> {
|
default -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
potions.put(type, potion);
|
||||||
}
|
}
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user