[refactor] Update flyweight pattern.
This commit is contained in:
parent
eb9b5fdd1b
commit
c23f58e86f
@ -7,6 +7,5 @@ package com.iluwatar;
|
||||
*/
|
||||
public interface Potion {
|
||||
|
||||
public void drink();
|
||||
|
||||
void drink();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.iluwatar;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -12,7 +13,7 @@ import java.util.EnumMap;
|
||||
*/
|
||||
public class PotionFactory {
|
||||
|
||||
private EnumMap<PotionType, Potion> potions;
|
||||
private final Map<PotionType, Potion> potions;
|
||||
|
||||
public PotionFactory() {
|
||||
potions = new EnumMap<>(PotionType.class);
|
||||
|
@ -7,6 +7,5 @@ package com.iluwatar;
|
||||
*/
|
||||
public enum PotionType {
|
||||
|
||||
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON;
|
||||
|
||||
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user