Update flyweight
This commit is contained in:
@@ -78,12 +78,12 @@ public class AlchemistShop {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate potions.
|
||||
* Drink all the potions.
|
||||
*/
|
||||
public void enumerate() {
|
||||
LOGGER.info("Enumerating top shelf potions\n");
|
||||
public void drinkPotions() {
|
||||
LOGGER.info("Drinking top shelf potions");
|
||||
topShelf.forEach(Potion::drink);
|
||||
LOGGER.info("Enumerating bottom shelf potions\n");
|
||||
LOGGER.info("Drinking bottom shelf potions");
|
||||
bottomShelf.forEach(Potion::drink);
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,9 @@ public class App {
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// create the alchemist shop with the potions
|
||||
var alchemistShop = new AlchemistShop();
|
||||
alchemistShop.enumerate();
|
||||
// a brave visitor enters the alchemist shop and drinks all the potions
|
||||
alchemistShop.drinkPotions();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user