[refactor] Update flyweight pattern.

This commit is contained in:
ruslanpa 2015-02-09 21:54:54 +02:00
parent eb9b5fdd1b
commit c23f58e86f
3 changed files with 4 additions and 5 deletions

View File

@ -7,6 +7,5 @@ package com.iluwatar;
*/
public interface Potion {
public void drink();
void drink();
}

View File

@ -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);

View File

@ -7,6 +7,5 @@ package com.iluwatar;
*/
public enum PotionType {
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON;
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON
}