Skip to content

Commit 5b06c52

Browse files
committed
Merge pull request iluwatar#291 from tainarareis/abstract-factory
Issue iluwatar#286: Added main method in Abstract Factory Example
2 parents 033f8e7 + 3452817 commit 5b06c52

File tree

1 file changed

+30
-0
lines changed
  • abstract-factory/src/main/java/com/iluwatar/abstractfactory

1 file changed

+30
-0
lines changed

abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class App {
2323
private Castle castle;
2424
private Army army;
2525

26+
2627
/**
2728
* Creates kingdom
2829
*
@@ -77,4 +78,33 @@ public Army getArmy() {
7778
private void setArmy(final Army army) {
7879
this.army = army;
7980
}
81+
82+
83+
/**
84+
* Program entry point
85+
*
86+
* @param args command line args
87+
*/
88+
public static void main(String[] args) {
89+
90+
App app = new App();
91+
92+
System.out.println("Elf Kingdom");
93+
KingdomFactory elfKingdomFactory;
94+
elfKingdomFactory = app.getElfKingdomFactory();
95+
app.createKingdom(elfKingdomFactory);
96+
System.out.println(app.getArmy().getDescription());
97+
System.out.println(app.getCastle().getDescription());
98+
System.out.println(app.getKing().getDescription());
99+
100+
System.out.println("\nOrc Kingdom");
101+
KingdomFactory orcKingdomFactory;
102+
orcKingdomFactory = app.getOrcKingdomFactory();
103+
app.createKingdom(orcKingdomFactory);
104+
System.out.println(app.getArmy().getDescription());
105+
System.out.println(app.getCastle().getDescription());
106+
System.out.println(app.getKing().getDescription());
107+
108+
}
109+
80110
}

0 commit comments

Comments
 (0)