Made example App a bit easier to understand
This commit is contained in:
parent
f64ba22c64
commit
b5d4445d63
@ -52,14 +52,6 @@ public class App {
|
||||
setArmy(factory.createArmy());
|
||||
}
|
||||
|
||||
ElfKingdomFactory getElfKingdomFactory() {
|
||||
return new ElfKingdomFactory();
|
||||
}
|
||||
|
||||
OrcKingdomFactory getOrcKingdomFactory() {
|
||||
return new OrcKingdomFactory();
|
||||
}
|
||||
|
||||
King getKing(final KingdomFactory factory) {
|
||||
return factory.createKing();
|
||||
}
|
||||
@ -107,17 +99,13 @@ public class App {
|
||||
App app = new App();
|
||||
|
||||
System.out.println("Elf Kingdom");
|
||||
KingdomFactory elfKingdomFactory;
|
||||
elfKingdomFactory = app.getElfKingdomFactory();
|
||||
app.createKingdom(elfKingdomFactory);
|
||||
app.createKingdom(new ElfKingdomFactory());
|
||||
System.out.println(app.getArmy().getDescription());
|
||||
System.out.println(app.getCastle().getDescription());
|
||||
System.out.println(app.getKing().getDescription());
|
||||
|
||||
System.out.println("\nOrc Kingdom");
|
||||
KingdomFactory orcKingdomFactory;
|
||||
orcKingdomFactory = app.getOrcKingdomFactory();
|
||||
app.createKingdom(orcKingdomFactory);
|
||||
app.createKingdom(new OrcKingdomFactory());
|
||||
System.out.println(app.getArmy().getDescription());
|
||||
System.out.println(app.getCastle().getDescription());
|
||||
System.out.println(app.getKing().getDescription());
|
||||
|
@ -36,8 +36,8 @@ public class AbstractFactoryTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
elfFactory = app.getElfKingdomFactory();
|
||||
orcFactory = app.getOrcKingdomFactory();
|
||||
elfFactory = new ElfKingdomFactory();
|
||||
orcFactory = new OrcKingdomFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user