Skip to content

Commit cbab406

Browse files
committed
Merge branch 'javadoc'
2 parents 5ce932c + d220a07 commit cbab406

File tree

252 files changed

+3737
-2819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+3737
-2819
lines changed
Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
/**
4-
*
5-
* The essence of the Abstract Factory pattern is a factory interface
6-
* (KingdomFactory) and its implementations (ElfKingdomFactory,
7-
* OrcKingdomFactory).
8-
*
9-
* The example uses both concrete implementations to create a king, a castle and
10-
* an army.
11-
*
12-
*/
13-
public class App {
14-
15-
public static void main(String[] args) {
16-
createKingdom(new ElfKingdomFactory());
17-
createKingdom(new OrcKingdomFactory());
18-
}
19-
20-
public static void createKingdom(KingdomFactory factory) {
21-
King king = factory.createKing();
22-
Castle castle = factory.createCastle();
23-
Army army = factory.createArmy();
24-
System.out.println("The kingdom was created.");
25-
System.out.println(king);
26-
System.out.println(castle);
27-
System.out.println(army);
28-
}
29-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* The essence of the Abstract Factory pattern is a factory interface
6+
* ({@link KingdomFactory}) and its implementations ({@link ElfKingdomFactory},
7+
* {@link OrcKingdomFactory}).
8+
* <p>
9+
* The example uses both concrete implementations to create a king, a castle and
10+
* an army.
11+
*
12+
*/
13+
public class App {
14+
15+
/**
16+
* Program entry point
17+
* @param args command line arguments
18+
*/
19+
public static void main(String[] args) {
20+
createKingdom(new ElfKingdomFactory());
21+
createKingdom(new OrcKingdomFactory());
22+
}
23+
24+
/**
25+
* Creates kingdom
26+
* @param factory
27+
*/
28+
public static void createKingdom(KingdomFactory factory) {
29+
King king = factory.createKing();
30+
Castle castle = factory.createCastle();
31+
Army army = factory.createArmy();
32+
System.out.println("The kingdom was created.");
33+
System.out.println(king);
34+
System.out.println(castle);
35+
System.out.println(army);
36+
}
37+
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public interface Army {
4-
5-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* Army interface
6+
*
7+
*/
8+
public interface Army {
9+
10+
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public interface Castle {
4-
5-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* Castle interface
6+
*
7+
*/
8+
public interface Castle {
9+
10+
}
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public class ElfArmy implements Army {
4-
5-
@Override
6-
public String toString() {
7-
return "This is the Elven Army!";
8-
}
9-
10-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* ElfArmy
6+
*
7+
*/
8+
public class ElfArmy implements Army {
9+
10+
@Override
11+
public String toString() {
12+
return "This is the Elven Army!";
13+
}
14+
15+
}
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public class ElfCastle implements Castle {
4-
5-
@Override
6-
public String toString() {
7-
return "This is the Elven castle!";
8-
}
9-
10-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* ElfCastle
6+
*
7+
*/
8+
public class ElfCastle implements Castle {
9+
10+
@Override
11+
public String toString() {
12+
return "This is the Elven castle!";
13+
}
14+
15+
}
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public class ElfKing implements King {
4-
5-
@Override
6-
public String toString() {
7-
return "This is the Elven king!";
8-
}
9-
10-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* ElfKing
6+
*
7+
*/
8+
public class ElfKing implements King {
9+
10+
@Override
11+
public String toString() {
12+
return "This is the Elven king!";
13+
}
14+
15+
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
/**
4-
*
5-
* Concrete factory.
6-
*
7-
*/
8-
public class ElfKingdomFactory implements KingdomFactory {
9-
10-
public Castle createCastle() {
11-
return new ElfCastle();
12-
}
13-
14-
public King createKing() {
15-
return new ElfKing();
16-
}
17-
18-
public Army createArmy() {
19-
return new ElfArmy();
20-
}
21-
22-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* ElfKingdomFactory concrete factory.
6+
*
7+
*/
8+
public class ElfKingdomFactory implements KingdomFactory {
9+
10+
public Castle createCastle() {
11+
return new ElfCastle();
12+
}
13+
14+
public King createKing() {
15+
return new ElfKing();
16+
}
17+
18+
public Army createArmy() {
19+
return new ElfArmy();
20+
}
21+
22+
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public interface King {
4-
5-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* King interface
6+
*
7+
*/
8+
public interface King {
9+
10+
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
/**
4-
*
5-
* The factory interface.
6-
*
7-
*/
8-
public interface KingdomFactory {
9-
10-
Castle createCastle();
11-
12-
King createKing();
13-
14-
Army createArmy();
15-
16-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* KingdomFactory factory interface.
6+
*
7+
*/
8+
public interface KingdomFactory {
9+
10+
Castle createCastle();
11+
12+
King createKing();
13+
14+
Army createArmy();
15+
16+
}
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
package com.iluwatar.abstractfactory;
2-
3-
public class OrcArmy implements Army {
4-
5-
@Override
6-
public String toString() {
7-
return "This is the Orcish Army!";
8-
}
9-
10-
}
1+
package com.iluwatar.abstractfactory;
2+
3+
/**
4+
*
5+
* OrcArmy
6+
*
7+
*/
8+
public class OrcArmy implements Army {
9+
10+
@Override
11+
public String toString() {
12+
return "This is the Orcish Army!";
13+
}
14+
15+
}

0 commit comments

Comments
 (0)