mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +00:00
+4
-12
@@ -77,21 +77,13 @@ public class PotionFactory {
|
||||
var potion = potions.get(type);
|
||||
if (potion == null) {
|
||||
switch (type) {
|
||||
case HEALING -> {
|
||||
potion = new HealingPotion();
|
||||
potions.put(type, potion);
|
||||
}
|
||||
case HOLY_WATER -> {
|
||||
potion = new HolyWaterPotion();
|
||||
potions.put(type, potion);
|
||||
}
|
||||
case INVISIBILITY -> {
|
||||
potion = new InvisibilityPotion();
|
||||
potions.put(type, potion);
|
||||
}
|
||||
case HEALING -> potion = new HealingPotion();
|
||||
case HOLY_WATER -> potion = new HolyWaterPotion();
|
||||
case INVISIBILITY -> potion = new InvisibilityPotion();
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
potions.put(type, potion);
|
||||
}
|
||||
return potion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user