Skip to content

Commit

Permalink
Merge branch 'javadoc'
Browse files Browse the repository at this point in the history
  • Loading branch information
iluwatar committed Aug 21, 2015
2 parents 5ce932c + d220a07 commit cbab406
Show file tree
Hide file tree
Showing 252 changed files with 3,737 additions and 2,819 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
package com.iluwatar.abstractfactory;

/**
*
* 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 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);
}
}
package com.iluwatar.abstractfactory;

/**
*
* The essence of the Abstract Factory pattern is a factory interface
* ({@link KingdomFactory}) and its implementations ({@link ElfKingdomFactory},
* {@link OrcKingdomFactory}).
* <p>
* The example uses both concrete implementations to create a king, a castle and
* an army.
*
*/
public class App {

/**
* Program entry point
* @param args command line arguments
*/
public static void main(String[] args) {
createKingdom(new ElfKingdomFactory());
createKingdom(new OrcKingdomFactory());
}

/**
* Creates kingdom
* @param factory
*/
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory;

public interface Army {

}
package com.iluwatar.abstractfactory;

/**
*
* Army interface
*
*/
public interface Army {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory;

public interface Castle {

}
package com.iluwatar.abstractfactory;

/**
*
* Castle interface
*
*/
public interface Castle {

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class ElfArmy implements Army {

@Override
public String toString() {
return "This is the Elven Army!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* ElfArmy
*
*/
public class ElfArmy implements Army {

@Override
public String toString() {
return "This is the Elven Army!";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class ElfCastle implements Castle {

@Override
public String toString() {
return "This is the Elven castle!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* ElfCastle
*
*/
public class ElfCastle implements Castle {

@Override
public String toString() {
return "This is the Elven castle!";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class ElfKing implements King {

@Override
public String toString() {
return "This is the Elven king!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* ElfKing
*
*/
public class ElfKing implements King {

@Override
public String toString() {
return "This is the Elven king!";
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.iluwatar.abstractfactory;

/**
*
* Concrete factory.
*
*/
public class ElfKingdomFactory implements KingdomFactory {

public Castle createCastle() {
return new ElfCastle();
}

public King createKing() {
return new ElfKing();
}

public Army createArmy() {
return new ElfArmy();
}

}
package com.iluwatar.abstractfactory;

/**
*
* ElfKingdomFactory concrete factory.
*
*/
public class ElfKingdomFactory implements KingdomFactory {

public Castle createCastle() {
return new ElfCastle();
}

public King createKing() {
return new ElfKing();
}

public Army createArmy() {
return new ElfArmy();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.iluwatar.abstractfactory;

public interface King {

}
package com.iluwatar.abstractfactory;

/**
*
* King interface
*
*/
public interface King {

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.iluwatar.abstractfactory;

/**
*
* The factory interface.
*
*/
public interface KingdomFactory {

Castle createCastle();

King createKing();

Army createArmy();

}
package com.iluwatar.abstractfactory;

/**
*
* KingdomFactory factory interface.
*
*/
public interface KingdomFactory {

Castle createCastle();

King createKing();

Army createArmy();

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class OrcArmy implements Army {

@Override
public String toString() {
return "This is the Orcish Army!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* OrcArmy
*
*/
public class OrcArmy implements Army {

@Override
public String toString() {
return "This is the Orcish Army!";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class OrcCastle implements Castle {

@Override
public String toString() {
return "This is the Orcish castle!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* OrcCastle
*
*/
public class OrcCastle implements Castle {

@Override
public String toString() {
return "This is the Orcish castle!";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.iluwatar.abstractfactory;

public class OrcKing implements King {

@Override
public String toString() {
return "This is the Orc king!";
}

}
package com.iluwatar.abstractfactory;

/**
*
* OrcKing
*
*/
public class OrcKing implements King {

@Override
public String toString() {
return "This is the Orc king!";
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.iluwatar.abstractfactory;

/**
*
* Concrete factory.
*
*/
public class OrcKingdomFactory implements KingdomFactory {

public Castle createCastle() {
return new OrcCastle();
}

public King createKing() {
return new OrcKing();
}

public Army createArmy() {
return new OrcArmy();
}

}
package com.iluwatar.abstractfactory;

/**
*
* OrcKingdomFactory concrete factory.
*
*/
public class OrcKingdomFactory implements KingdomFactory {

public Castle createCastle() {
return new OrcCastle();
}

public King createKing() {
return new OrcKing();
}

public Army createArmy() {
return new OrcArmy();
}

}
Loading

0 comments on commit cbab406

Please sign in to comment.