File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed
flyweight/src/main/java/com/iluwatar Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 33import java .util .ArrayList ;
44import java .util .List ;
55
6+ /**
7+ *
8+ * The class that needs many objects.
9+ *
10+ */
611public class AlchemistShop {
712
813 List <Potion > topShelf ;
Original file line number Diff line number Diff line change 11package com .iluwatar ;
22
3+ /**
4+ *
5+ * Flyweight (PotionFactory) is useful when there is plethora of
6+ * objects (Potion). It provides means to decrease resource usage
7+ * by sharing object instances.
8+ *
9+ */
310public class App
411{
512 public static void main ( String [] args )
Original file line number Diff line number Diff line change 11package com .iluwatar ;
22
3+ /**
4+ *
5+ * Interface for objects.
6+ *
7+ */
38public interface Potion {
49
510 public void drink ();
Original file line number Diff line number Diff line change 22
33import java .util .EnumMap ;
44
5+ /**
6+ *
7+ * Flyweight.
8+ *
9+ */
510public class PotionFactory {
611
712 private EnumMap <PotionType , Potion > potions ;
You can’t perform that action at this time.
0 commit comments