#107 JavaDoc improvements for Abstract Factory example

This commit is contained in:
Ilkka Seppala 2015-08-17 23:06:44 +03:00
parent 0d2df99013
commit fd85a2f848
13 changed files with 217 additions and 164 deletions

View File

@ -1,29 +1,37 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
/** /**
* *
* The essence of the Abstract Factory pattern is a factory interface * The essence of the Abstract Factory pattern is a factory interface
* (KingdomFactory) and its implementations (ElfKingdomFactory, * ({@link KingdomFactory}) and its implementations ({@link ElfKingdomFactory},
* OrcKingdomFactory). * {@link OrcKingdomFactory}).
* * <p>
* The example uses both concrete implementations to create a king, a castle and * The example uses both concrete implementations to create a king, a castle and
* an army. * an army.
* *
*/ */
public class App { public class App {
public static void main(String[] args) { /**
createKingdom(new ElfKingdomFactory()); * Program entry point
createKingdom(new OrcKingdomFactory()); * @param args command line arguments
} */
public static void main(String[] args) {
public static void createKingdom(KingdomFactory factory) { createKingdom(new ElfKingdomFactory());
King king = factory.createKing(); createKingdom(new OrcKingdomFactory());
Castle castle = factory.createCastle(); }
Army army = factory.createArmy();
System.out.println("The kingdom was created."); /**
System.out.println(king); * Creates kingdom
System.out.println(castle); * @param factory
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);
}
}

View File

@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public interface Army { /**
*
} * Army interface
*
*/
public interface Army {
}

View File

@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public interface Castle { /**
*
} * Castle interface
*
*/
public interface Castle {
}

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class ElfArmy implements Army { /**
*
@Override * ElfArmy
public String toString() { *
return "This is the Elven Army!"; */
} public class ElfArmy implements Army {
} @Override
public String toString() {
return "This is the Elven Army!";
}
}

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class ElfCastle implements Castle { /**
*
@Override * ElfCastle
public String toString() { *
return "This is the Elven castle!"; */
} public class ElfCastle implements Castle {
} @Override
public String toString() {
return "This is the Elven castle!";
}
}

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class ElfKing implements King { /**
*
@Override * ElfKing
public String toString() { *
return "This is the Elven king!"; */
} public class ElfKing implements King {
} @Override
public String toString() {
return "This is the Elven king!";
}
}

View File

@ -1,22 +1,22 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
/** /**
* *
* Concrete factory. * ElfKingdomFactory concrete factory.
* *
*/ */
public class ElfKingdomFactory implements KingdomFactory { public class ElfKingdomFactory implements KingdomFactory {
public Castle createCastle() { public Castle createCastle() {
return new ElfCastle(); return new ElfCastle();
} }
public King createKing() { public King createKing() {
return new ElfKing(); return new ElfKing();
} }
public Army createArmy() { public Army createArmy() {
return new ElfArmy(); return new ElfArmy();
} }
} }

View File

@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public interface King { /**
*
} * King interface
*
*/
public interface King {
}

View File

@ -1,16 +1,16 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
/** /**
* *
* The factory interface. * KingdomFactory factory interface.
* *
*/ */
public interface KingdomFactory { public interface KingdomFactory {
Castle createCastle(); Castle createCastle();
King createKing(); King createKing();
Army createArmy(); Army createArmy();
} }

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class OrcArmy implements Army { /**
*
@Override * OrcArmy
public String toString() { *
return "This is the Orcish Army!"; */
} public class OrcArmy implements Army {
} @Override
public String toString() {
return "This is the Orcish Army!";
}
}

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class OrcCastle implements Castle { /**
*
@Override * OrcCastle
public String toString() { *
return "This is the Orcish castle!"; */
} public class OrcCastle implements Castle {
} @Override
public String toString() {
return "This is the Orcish castle!";
}
}

View File

@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
public class OrcKing implements King { /**
*
@Override * OrcKing
public String toString() { *
return "This is the Orc king!"; */
} public class OrcKing implements King {
} @Override
public String toString() {
return "This is the Orc king!";
}
}

View File

@ -1,22 +1,22 @@
package com.iluwatar.abstractfactory; package com.iluwatar.abstractfactory;
/** /**
* *
* Concrete factory. * OrcKingdomFactory concrete factory.
* *
*/ */
public class OrcKingdomFactory implements KingdomFactory { public class OrcKingdomFactory implements KingdomFactory {
public Castle createCastle() { public Castle createCastle() {
return new OrcCastle(); return new OrcCastle();
} }
public King createKing() { public King createKing() {
return new OrcKing(); return new OrcKing();
} }
public Army createArmy() { public Army createArmy() {
return new OrcArmy(); return new OrcArmy();
} }
} }