Added comments for Abstract Factory example.
This commit is contained in:
parent
601bd6bb98
commit
5aead88e5e
@ -1,5 +1,14 @@
|
|||||||
package com.iluwatar;
|
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 class App
|
||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Concrete factory.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ElfKingdomFactory implements KingdomFactory {
|
public class ElfKingdomFactory implements KingdomFactory {
|
||||||
|
|
||||||
public Castle createCastle() {
|
public Castle createCastle() {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The factory interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface KingdomFactory {
|
public interface KingdomFactory {
|
||||||
|
|
||||||
Castle createCastle();
|
Castle createCastle();
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Concrete factory.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class OrcKingdomFactory implements KingdomFactory {
|
public class OrcKingdomFactory implements KingdomFactory {
|
||||||
|
|
||||||
public Castle createCastle() {
|
public Castle createCastle() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user