mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 16:17:25 +00:00
[refactor] Update flyweight pattern.
This commit is contained in:
1 parent
eb9b5fdd1b
commit
c23f58e86f
3 files changed
+4
-5
No files matched your search
@@ -7,6 +7,5 @@ package com.iluwatar;
|
|||||||
*/
|
*/
|
||||||
public interface Potion {
|
public interface Potion {
|
||||||
|
|
||||||
public void drink();
|
void drink();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -12,7 +13,7 @@ import java.util.EnumMap;
|
|||||||
*/
|
*/
|
||||||
public class PotionFactory {
|
public class PotionFactory {
|
||||||
|
|
||||||
private EnumMap<PotionType, Potion> potions;
|
private final Map<PotionType, Potion> potions;
|
||||||
|
|
||||||
public PotionFactory() {
|
public PotionFactory() {
|
||||||
potions = new EnumMap<>(PotionType.class);
|
potions = new EnumMap<>(PotionType.class);
|
||||||
|
|||||||
@@ -7,6 +7,5 @@ package com.iluwatar;
|
|||||||
*/
|
*/
|
||||||
public enum PotionType {
|
public enum PotionType {
|
||||||
|
|
||||||
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON;
|
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user