Just formatting App classes to be like the other class files on the project
This commit is contained in:
		| @@ -2,17 +2,17 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * The essence of the Abstract Factory pattern is a factory interface (KingdomFactory) | ||||
|  * and its implementations (ElfKingdomFactory, OrcKingdomFactory). | ||||
|  * The essence of the Abstract Factory pattern is a factory interface | ||||
|  * (KingdomFactory) and its implementations (ElfKingdomFactory, | ||||
|  * OrcKingdomFactory). | ||||
|  * | ||||
|  * The example uses both concrete implementations to create a king, a castle and an | ||||
|  * army. | ||||
|  * The example uses both concrete implementations to create a king, a castle and | ||||
|  * an army. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         createKingdom(new ElfKingdomFactory()); | ||||
|         createKingdom(new OrcKingdomFactory()); | ||||
|     } | ||||
|   | ||||
| @@ -2,21 +2,19 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * There are two variations of the Adapter pattern: The | ||||
|  * class adapter implements the adaptee's interface whereas | ||||
|  * the object adapter uses composition to contain the adaptee | ||||
|  * in the adapter object. This example uses the object adapter | ||||
|  * approach. | ||||
|  * There are two variations of the Adapter pattern: The class adapter implements | ||||
|  * the adaptee's interface whereas the object adapter uses composition to | ||||
|  * contain the adaptee in the adapter object. This example uses the object | ||||
|  * adapter approach. | ||||
|  * | ||||
|  * The Adapter (GnomeEngineer) converts the interface of the | ||||
|  * target class (GoblinGlider) into a suitable one expected | ||||
|  * by the client (GnomeEngineeringManager). | ||||
|  * The Adapter (GnomeEngineer) converts the interface of the target class | ||||
|  * (GoblinGlider) into a suitable one expected by the client | ||||
|  * (GnomeEngineeringManager). | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         GnomeEngineeringManager manager = new GnomeEngineeringManager(); | ||||
|         manager.operateDevice(); | ||||
|     } | ||||
|   | ||||
| @@ -2,17 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In Bridge pattern both abstraction (MagicWeapon)  | ||||
|  * and implementation (MagicWeaponImp) have their  | ||||
|  * own class hierarchies. The interface of the | ||||
|  * implementations can be changed without affecting | ||||
|  * the clients. | ||||
|  * In Bridge pattern both abstraction (MagicWeapon) and implementation | ||||
|  * (MagicWeaponImp) have their own class hierarchies. The interface of the | ||||
|  * implementations can be changed without affecting the clients. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         BlindingMagicWeapon blindingMagicWeapon = new BlindingMagicWeapon(new Excalibur()); | ||||
|         blindingMagicWeapon.wield(); | ||||
|         blindingMagicWeapon.blind(); | ||||
|   | ||||
| @@ -4,24 +4,20 @@ import com.iluwatar.Hero.HeroBuilder; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * This is the Builder pattern variation as described by | ||||
|  * Joshua Bloch in Effective Java 2nd Edition. | ||||
|  * This is the Builder pattern variation as described by Joshua Bloch in | ||||
|  * Effective Java 2nd Edition. | ||||
|  * | ||||
|  * We want to build Hero objects, but its construction | ||||
|  * is complex because of the many parameters needed. To | ||||
|  * aid the user we introduce HeroBuilder class. HeroBuilder | ||||
|  * takes the minimum parameters to build Hero object in | ||||
|  * its constructor. After that additional configuration | ||||
|  * for the Hero object can be done using the fluent | ||||
|  * HeroBuilder interface. When configuration is ready | ||||
|  * the build method is called to receive the final Hero | ||||
|  * object. | ||||
|  * We want to build Hero objects, but its construction is complex because of the | ||||
|  * many parameters needed. To aid the user we introduce HeroBuilder class. | ||||
|  * HeroBuilder takes the minimum parameters to build Hero object in its | ||||
|  * constructor. After that additional configuration for the Hero object can be | ||||
|  * done using the fluent HeroBuilder interface. When configuration is ready the | ||||
|  * build method is called to receive the final Hero object. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         Hero mage = new HeroBuilder(Profession.MAGE, "Riobard") | ||||
|                 .withHairColor(HairColor.BLACK) | ||||
|   | ||||
| @@ -2,16 +2,15 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Chain of Responsibility organizes request handlers (RequestHandler) into | ||||
|  * a chain where each handler has a chance to act on the request on its | ||||
|  * turn. In this example the king (OrcKing) makes requests and the military | ||||
|  * orcs (OrcCommander, OrcOfficer, OrcSoldier) form the handler chain. | ||||
|  * Chain of Responsibility organizes request handlers (RequestHandler) into a | ||||
|  * chain where each handler has a chance to act on the request on its turn. In | ||||
|  * this example the king (OrcKing) makes requests and the military orcs | ||||
|  * (OrcCommander, OrcOfficer, OrcSoldier) form the handler chain. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         OrcKing king = new OrcKing(); | ||||
|         king.makeRequest(new Request(RequestType.DEFEND_CASTLE, "defend castle")); | ||||
|   | ||||
| @@ -2,15 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In Command pattern actions are objects that can | ||||
|  * be executed and undone. The commands in this example | ||||
|  * are spells cast by the wizard on the goblin. | ||||
|  * In Command pattern actions are objects that can be executed and undone. The | ||||
|  * commands in this example are spells cast by the wizard on the goblin. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         Wizard wizard = new Wizard(); | ||||
|         Goblin goblin = new Goblin(); | ||||
|  | ||||
|   | ||||
| @@ -2,15 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * With Composite we can treat tree hierarchies of objects | ||||
|  * with uniform interface (LetterComposite). In this example | ||||
|  * we have sentences composed of words composed of letters. | ||||
|  * With Composite we can treat tree hierarchies of objects with uniform | ||||
|  * interface (LetterComposite). In this example we have sentences composed of | ||||
|  * words composed of letters. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         System.out.println("Message from the orcs: "); | ||||
|  | ||||
|         LetterComposite orcMessage = new Messenger().messageFromOrcs(); | ||||
|   | ||||
| @@ -2,16 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Decorator pattern is more flexible alternative to | ||||
|  * subclassing. The decorator class implements the same | ||||
|  * interface as the target and uses composition to | ||||
|  * Decorator pattern is more flexible alternative to subclassing. The decorator | ||||
|  * class implements the same interface as the target and uses composition to | ||||
|  * "decorate" calls to the target. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         System.out.println("A simple looking troll approaches."); | ||||
|         Hostile troll = new Troll(); | ||||
|   | ||||
| @@ -5,17 +5,14 @@ import java.util.concurrent.Executors; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In Inventory we store the items with a given size. However, | ||||
|  * we do not store more items than the inventory size. To address | ||||
|  * concurrent access problems we use double checked locking to add | ||||
|  * item to inventory. In this method, the thread which gets the lock | ||||
|  * first adds the item.  | ||||
|  * In Inventory we store the items with a given size. However, we do not store | ||||
|  * more items than the inventory size. To address concurrent access problems we | ||||
|  * use double checked locking to add item to inventory. In this method, the | ||||
|  * thread which gets the lock first adds the item. | ||||
|  */ | ||||
| public class App { | ||||
|  | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
|     public static void main(String[] args) { | ||||
|         final Inventory inventory = new Inventory(1000); | ||||
|         ExecutorService executorService = Executors.newFixedThreadPool(3); | ||||
|         for (int i = 0; i < 3; i++) { | ||||
|   | ||||
| @@ -2,14 +2,12 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Facade (DwarvenGoldmineFacade) provides simpler interface to  | ||||
|  * subsystem. | ||||
|  * Facade (DwarvenGoldmineFacade) provides simpler interface to subsystem. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         DwarvenGoldmineFacade facade = new DwarvenGoldmineFacade(); | ||||
|         facade.startNewDay(); | ||||
|         facade.digOutGold(); | ||||
|   | ||||
| @@ -2,16 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In Factory Method we have an interface (Blacksmith) with a | ||||
|  * method for creating objects (manufactureWeapon). The concrete | ||||
|  * subclasses (OrcBlacksmith, ElfBlacksmith) then override the  | ||||
|  * method to produce objects of their liking. | ||||
|  * In Factory Method we have an interface (Blacksmith) with a method for | ||||
|  * creating objects (manufactureWeapon). The concrete subclasses (OrcBlacksmith, | ||||
|  * ElfBlacksmith) then override the method to produce objects of their liking. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         Blacksmith blacksmith; | ||||
|         Weapon weapon; | ||||
|  | ||||
|   | ||||
| @@ -2,15 +2,14 @@ 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. | ||||
|  * 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 ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         AlchemistShop alchemistShop = new AlchemistShop(); | ||||
|         alchemistShop.enumerate(); | ||||
|     } | ||||
|   | ||||
| @@ -4,12 +4,11 @@ import java.util.Stack; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Interpreter pattern breaks sentences into expressions (Expression) | ||||
|  * that can be evaluated and as a whole form the result. | ||||
|  * Interpreter pattern breaks sentences into expressions (Expression) that can | ||||
|  * be evaluated and as a whole form the result. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
| public class App { | ||||
|  | ||||
|     /** | ||||
|      * | ||||
| @@ -17,8 +16,7 @@ public class App | ||||
|      * This sample uses postfix, where operator comes after the operands | ||||
|      * | ||||
|      */ | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
|     public static void main(String[] args) { | ||||
|         String tokenString = "4 3 2 - 1 + *"; | ||||
|         Stack<Expression> stack = new Stack<>(); | ||||
|  | ||||
| @@ -46,11 +44,12 @@ public class App | ||||
|     } | ||||
|  | ||||
|     public static boolean isOperator(String s) { | ||||
| 		if (s.equals("+") || s.equals("-") || s.equals("*")) | ||||
|         if (s.equals("+") || s.equals("-") || s.equals("*")) { | ||||
|             return true; | ||||
| 		else | ||||
|         } else { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static Expression getOperatorInstance(String s, Expression left, | ||||
|             Expression right) { | ||||
|   | ||||
| @@ -2,15 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Iterator (ItemIterator) adds abstraction layer on top of a  | ||||
|  * collection (TreasureChest). This way the collection can change  | ||||
|  * its internal implementation without affecting its clients. | ||||
|  * Iterator (ItemIterator) adds abstraction layer on top of a collection | ||||
|  * (TreasureChest). This way the collection can change its internal | ||||
|  * implementation without affecting its clients. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         TreasureChest chest = new TreasureChest(); | ||||
|  | ||||
|         ItemIterator ringIterator = chest.Iterator(ItemType.RING); | ||||
|   | ||||
| @@ -2,15 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Mediator encapsulates how set of objects (PartyMember) interact. | ||||
|  * Instead of referring to each other directly they | ||||
|  * use the mediator (Party) interface. | ||||
|  * Mediator encapsulates how set of objects (PartyMember) interact. Instead of | ||||
|  * referring to each other directly they use the mediator (Party) interface. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         Party party = new PartyImpl(); | ||||
|         Hobbit hobbit = new Hobbit(); | ||||
|         Wizard wizard = new Wizard(); | ||||
|   | ||||
| @@ -4,17 +4,14 @@ import java.util.Stack; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Memento pattern is for storing and restoring object | ||||
|  * state. The object (Star) gives out a "memento"  | ||||
|  * (StarMemento) that contains the state of the object.  | ||||
|  * Later on the memento can be set back to the object  | ||||
|  * restoring the state. | ||||
|  * Memento pattern is for storing and restoring object state. The object (Star) | ||||
|  * gives out a "memento" (StarMemento) that contains the state of the object. | ||||
|  * Later on the memento can be set back to the object restoring the state. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         Stack<StarMemento> states = new Stack<>(); | ||||
|  | ||||
|         Star star = new Star(StarType.SUN, 10000000, 500000); | ||||
|   | ||||
| @@ -2,15 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Observer pattern defines one-to-many relationship | ||||
|  * between objects. The target object sends change | ||||
|  * notifications to its registered observers. | ||||
|  * Observer pattern defines one-to-many relationship between objects. The target | ||||
|  * object sends change notifications to its registered observers. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         Weather weather = new Weather(); | ||||
|         weather.addObserver(new Orcs()); | ||||
|   | ||||
| @@ -2,15 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In Prototype we have a factory class (HeroFactoryImpl) producing | ||||
|  * objects by cloning existing ones. In this example the factory's | ||||
|  * prototype objects are given as constructor parameters. | ||||
|  * In Prototype we have a factory class (HeroFactoryImpl) producing objects by | ||||
|  * cloning existing ones. In this example the factory's prototype objects are | ||||
|  * given as constructor parameters. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         HeroFactory factory; | ||||
|         Mage mage; | ||||
|         Warlord warlord; | ||||
|   | ||||
| @@ -2,14 +2,12 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Proxy (WizardTowerProxy) controls access to the | ||||
|  * actual object (WizardTower). | ||||
|  * Proxy (WizardTowerProxy) controls access to the actual object (WizardTower). | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         WizardTowerProxy tower = new WizardTowerProxy(); | ||||
|         tower.enter(new Wizard("Red wizard")); | ||||
|   | ||||
| @@ -2,14 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Singleton pattern ensures that the class (IvoryTower) can have only | ||||
|  * one existing instance and provides global access to that instance. | ||||
|  * Singleton pattern ensures that the class (IvoryTower) can have only one | ||||
|  * existing instance and provides global access to that instance. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         IvoryTower ivoryTower1 = IvoryTower.getInstance(); | ||||
|         IvoryTower ivoryTower2 = IvoryTower.getInstance(); | ||||
|   | ||||
| @@ -2,16 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * In State pattern the object (Mammoth) has internal | ||||
|  * state object (State) that defines the current | ||||
|  * behavior. The state object can be changed | ||||
|  * to alter the behavior. | ||||
|  * In State pattern the object (Mammoth) has internal state object (State) that | ||||
|  * defines the current behavior. The state object can be changed to alter the | ||||
|  * behavior. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         Mammoth mammoth = new Mammoth(); | ||||
|         mammoth.observe(); | ||||
|   | ||||
| @@ -2,14 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Strategy (DragonSlayingStrategy) encapsulates the algorithm to use. | ||||
|  * The object (DragonSlayer) can alter its behavior by changing its strategy. | ||||
|  * Strategy (DragonSlayingStrategy) encapsulates the algorithm to use. The | ||||
|  * object (DragonSlayer) can alter its behavior by changing its strategy. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         System.out.println("Green dragon spotted ahead!"); | ||||
|         DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy()); | ||||
|         dragonSlayer.goToBattle(); | ||||
|   | ||||
| @@ -2,15 +2,13 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Template Method (StealingMethod) defines skeleton for the | ||||
|  * algorithm and subclasses (HitAndRunMethod, SubtleMethod)  | ||||
|  * fill in the blanks. | ||||
|  * Template Method (StealingMethod) defines skeleton for the algorithm and | ||||
|  * subclasses (HitAndRunMethod, SubtleMethod) fill in the blanks. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|         HalflingThief thief = new HalflingThief(new HitAndRunMethod()); | ||||
|         thief.steal(); | ||||
|         thief.changeMethod(new SubtleMethod()); | ||||
|   | ||||
| @@ -2,15 +2,14 @@ package com.iluwatar; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Visitor pattern defines mechanism to apply operations | ||||
|  * (UnitVisitor) on nodes (Unit) in hierarchy. New operations  | ||||
|  * can be added without altering the node interface. | ||||
|  * Visitor pattern defines mechanism to apply operations (UnitVisitor) on nodes | ||||
|  * (Unit) in hierarchy. New operations can be added without altering the node | ||||
|  * interface. | ||||
|  * | ||||
|  */ | ||||
| public class App  | ||||
| { | ||||
|     public static void main( String[] args ) | ||||
|     { | ||||
| public class App { | ||||
|  | ||||
|     public static void main(String[] args) { | ||||
|  | ||||
|         Commander commander = new Commander( | ||||
|                 new Sergeant(new Soldier(), new Soldier(), new Soldier()), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user