提交 05cb4089 编写于 作者: I Ilkka Seppala

Commented flyweight example.

上级 05d21295
......@@ -3,6 +3,11 @@ package com.iluwatar;
import java.util.ArrayList;
import java.util.List;
/**
*
* The class that needs many objects.
*
*/
public class AlchemistShop {
List<Potion> topShelf;
......
package com.iluwatar;
/**
*
* Flyweight (PotionFactory) is useful when there is plethora of
* objects (Potion). It provides means to decrease resource usage
* by sharing object instances.
*
*/
public class App
{
public static void main( String[] args )
......
package com.iluwatar;
/**
*
* Interface for objects.
*
*/
public interface Potion {
public void drink();
......
......@@ -2,6 +2,11 @@ package com.iluwatar;
import java.util.EnumMap;
/**
*
* Flyweight.
*
*/
public class PotionFactory {
private EnumMap<PotionType, Potion> potions;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册