|
1 | 1 | package com.iluwatar; |
2 | 2 |
|
3 | 3 | /** |
4 | | - * |
| 4 | + * |
5 | 5 | * The essence of the Abstract Factory pattern is a factory interface |
6 | 6 | * (KingdomFactory) and its implementations (ElfKingdomFactory, |
7 | 7 | * OrcKingdomFactory). |
8 | | - * |
| 8 | + * |
9 | 9 | * The example uses both concrete implementations to create a king, a castle and |
10 | 10 | * an army. |
11 | | - * |
| 11 | + * |
12 | 12 | */ |
13 | 13 | public class App { |
14 | 14 |
|
15 | | - public static void main(String[] args) { |
16 | | - createKingdom(new ElfKingdomFactory()); |
17 | | - createKingdom(new OrcKingdomFactory()); |
18 | | - } |
| 15 | + public static void main(String[] args) { |
| 16 | + createKingdom(new ElfKingdomFactory()); |
| 17 | + createKingdom(new OrcKingdomFactory()); |
| 18 | + } |
19 | 19 |
|
20 | | - public static void createKingdom(KingdomFactory factory) { |
21 | | - King king = factory.createKing(); |
22 | | - Castle castle = factory.createCastle(); |
23 | | - Army army = factory.createArmy(); |
24 | | - System.out.println("The kingdom was created."); |
25 | | - System.out.println(king); |
26 | | - System.out.println(castle); |
27 | | - System.out.println(army); |
28 | | - } |
| 20 | + public static void createKingdom(KingdomFactory factory) { |
| 21 | + King king = factory.createKing(); |
| 22 | + Castle castle = factory.createCastle(); |
| 23 | + Army army = factory.createArmy(); |
| 24 | + System.out.println("The kingdom was created."); |
| 25 | + System.out.println(king); |
| 26 | + System.out.println(castle); |
| 27 | + System.out.println(army); |
| 28 | + } |
29 | 29 | } |