Formatted all files to the same standard
This commit is contained in:
@ -1,29 +1,29 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
createKingdom(new ElfKingdomFactory());
|
||||
createKingdom(new OrcKingdomFactory());
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
createKingdom(new ElfKingdomFactory());
|
||||
createKingdom(new OrcKingdomFactory());
|
||||
}
|
||||
|
||||
public static void createKingdom(KingdomFactory factory) {
|
||||
King king = factory.createKing();
|
||||
Castle castle = factory.createCastle();
|
||||
Army army = factory.createArmy();
|
||||
System.out.println("The kingdom was created.");
|
||||
System.out.println(king);
|
||||
System.out.println(castle);
|
||||
System.out.println(army);
|
||||
}
|
||||
public static void createKingdom(KingdomFactory factory) {
|
||||
King king = factory.createKing();
|
||||
Castle castle = factory.createCastle();
|
||||
Army army = factory.createArmy();
|
||||
System.out.println("The kingdom was created.");
|
||||
System.out.println(king);
|
||||
System.out.println(castle);
|
||||
System.out.println(army);
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class ElfArmy implements Army {
|
||||
public String toString() {
|
||||
return "This is the Elven Army!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class ElfCastle implements Castle {
|
||||
public String toString() {
|
||||
return "This is the Elven castle!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class ElfKing implements King {
|
||||
public String toString() {
|
||||
return "This is the Elven king!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.iluwatar;
|
||||
/**
|
||||
*
|
||||
* Concrete factory.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ElfKingdomFactory implements KingdomFactory {
|
||||
|
||||
|
@ -3,12 +3,14 @@ package com.iluwatar;
|
||||
/**
|
||||
*
|
||||
* The factory interface.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface KingdomFactory {
|
||||
|
||||
Castle createCastle();
|
||||
|
||||
King createKing();
|
||||
|
||||
Army createArmy();
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class OrcArmy implements Army {
|
||||
public String toString() {
|
||||
return "This is the Orcish Army!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class OrcCastle implements Castle {
|
||||
public String toString() {
|
||||
return "This is the Orcish castle!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ public class OrcKing implements King {
|
||||
public String toString() {
|
||||
return "This is the Orc king!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.iluwatar;
|
||||
/**
|
||||
*
|
||||
* Concrete factory.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class OrcKingdomFactory implements KingdomFactory {
|
||||
|
||||
|
Reference in New Issue
Block a user