From 0db6581cfd2f16033169dc78e0929e08745a579a Mon Sep 17 00:00:00 2001 From: Ilkka Seppala Date: Fri, 21 Aug 2015 22:45:03 +0300 Subject: [PATCH] #107 Improve JavaDoc for Prototype --- .../main/java/com/iluwatar/prototype/App.java | 76 ++++++++++--------- .../java/com/iluwatar/prototype/Beast.java | 21 +++-- .../java/com/iluwatar/prototype/ElfBeast.java | 47 +++++++----- .../java/com/iluwatar/prototype/ElfMage.java | 47 +++++++----- .../com/iluwatar/prototype/ElfWarlord.java | 47 +++++++----- .../java/com/iluwatar/prototype/Mage.java | 21 +++-- .../java/com/iluwatar/prototype/OrcBeast.java | 47 +++++++----- .../java/com/iluwatar/prototype/OrcMage.java | 47 +++++++----- .../com/iluwatar/prototype/OrcWarlord.java | 47 +++++++----- .../com/iluwatar/prototype/Prototype.java | 21 +++-- .../java/com/iluwatar/prototype/Warlord.java | 21 +++-- .../java/com/iluwatar/prototype/AppTest.java | 33 ++++---- 12 files changed, 267 insertions(+), 208 deletions(-) diff --git a/prototype/src/main/java/com/iluwatar/prototype/App.java b/prototype/src/main/java/com/iluwatar/prototype/App.java index b10de963b..4003862cb 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/App.java +++ b/prototype/src/main/java/com/iluwatar/prototype/App.java @@ -1,36 +1,40 @@ -package com.iluwatar.prototype; - -/** - * - * In Prototype we have a factory class (HeroFactoryImpl) producing objects by - * cloning existing ones. In this example the factory's prototype objects are - * given as constructor parameters. - * - */ -public class App { - - public static void main(String[] args) { - HeroFactory factory; - Mage mage; - Warlord warlord; - Beast beast; - - factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(), - new ElfBeast()); - mage = factory.createMage(); - warlord = factory.createWarlord(); - beast = factory.createBeast(); - System.out.println(mage); - System.out.println(warlord); - System.out.println(beast); - - factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(), - new OrcBeast()); - mage = factory.createMage(); - warlord = factory.createWarlord(); - beast = factory.createBeast(); - System.out.println(mage); - System.out.println(warlord); - System.out.println(beast); - } -} +package com.iluwatar.prototype; + +/** + * + * In Prototype we have a factory class ({@link HeroFactoryImpl}) producing objects by + * cloning the existing ones. In this example the factory's prototype objects are + * given as constructor parameters. + * + */ +public class App { + + /** + * Program entry point + * @param args command line args + */ + public static void main(String[] args) { + HeroFactory factory; + Mage mage; + Warlord warlord; + Beast beast; + + factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(), + new ElfBeast()); + mage = factory.createMage(); + warlord = factory.createWarlord(); + beast = factory.createBeast(); + System.out.println(mage); + System.out.println(warlord); + System.out.println(beast); + + factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(), + new OrcBeast()); + mage = factory.createMage(); + warlord = factory.createWarlord(); + beast = factory.createBeast(); + System.out.println(mage); + System.out.println(warlord); + System.out.println(beast); + } +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/Beast.java b/prototype/src/main/java/com/iluwatar/prototype/Beast.java index 96cbfb2c8..028fa11b8 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/Beast.java +++ b/prototype/src/main/java/com/iluwatar/prototype/Beast.java @@ -1,8 +1,13 @@ -package com.iluwatar.prototype; - -public abstract class Beast extends Prototype { - - @Override - public abstract Beast clone() throws CloneNotSupportedException; - -} +package com.iluwatar.prototype; + +/** + * + * Beast + * + */ +public abstract class Beast extends Prototype { + + @Override + public abstract Beast clone() throws CloneNotSupportedException; + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java b/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java index 17ac87511..b2b517207 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java +++ b/prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class ElfBeast extends Beast { - - public ElfBeast() { - } - - public ElfBeast(ElfBeast beast) { - } - - @Override - public Beast clone() throws CloneNotSupportedException { - return new ElfBeast(this); - } - - @Override - public String toString() { - return "Elven eagle"; - } - -} +package com.iluwatar.prototype; + +/** + * + * ElfBeast + * + */ +public class ElfBeast extends Beast { + + public ElfBeast() { + } + + public ElfBeast(ElfBeast beast) { + } + + @Override + public Beast clone() throws CloneNotSupportedException { + return new ElfBeast(this); + } + + @Override + public String toString() { + return "Elven eagle"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java b/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java index c41ce2dd6..b502350c3 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java +++ b/prototype/src/main/java/com/iluwatar/prototype/ElfMage.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class ElfMage extends Mage { - - public ElfMage() { - } - - public ElfMage(ElfMage mage) { - } - - @Override - public Mage clone() throws CloneNotSupportedException { - return new ElfMage(this); - } - - @Override - public String toString() { - return "Elven mage"; - } - -} +package com.iluwatar.prototype; + +/** + * + * ElfMage + * + */ +public class ElfMage extends Mage { + + public ElfMage() { + } + + public ElfMage(ElfMage mage) { + } + + @Override + public Mage clone() throws CloneNotSupportedException { + return new ElfMage(this); + } + + @Override + public String toString() { + return "Elven mage"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java b/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java index 465c1d046..7f5829797 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java +++ b/prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class ElfWarlord extends Warlord { - - public ElfWarlord() { - } - - public ElfWarlord(ElfWarlord warlord) { - } - - @Override - public Warlord clone() throws CloneNotSupportedException { - return new ElfWarlord(this); - } - - @Override - public String toString() { - return "Elven warlord"; - } - -} +package com.iluwatar.prototype; + +/** + * + * ElfWarlord + * + */ +public class ElfWarlord extends Warlord { + + public ElfWarlord() { + } + + public ElfWarlord(ElfWarlord warlord) { + } + + @Override + public Warlord clone() throws CloneNotSupportedException { + return new ElfWarlord(this); + } + + @Override + public String toString() { + return "Elven warlord"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/Mage.java b/prototype/src/main/java/com/iluwatar/prototype/Mage.java index 99cee8893..7ba192487 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/Mage.java +++ b/prototype/src/main/java/com/iluwatar/prototype/Mage.java @@ -1,8 +1,13 @@ -package com.iluwatar.prototype; - -public abstract class Mage extends Prototype { - - @Override - public abstract Mage clone() throws CloneNotSupportedException; - -} +package com.iluwatar.prototype; + +/** + * + * Mage + * + */ +public abstract class Mage extends Prototype { + + @Override + public abstract Mage clone() throws CloneNotSupportedException; + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java b/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java index bae7d360e..2af2fefa9 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java +++ b/prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class OrcBeast extends Beast { - - public OrcBeast() { - } - - public OrcBeast(OrcBeast beast) { - } - - @Override - public Beast clone() throws CloneNotSupportedException { - return new OrcBeast(this); - } - - @Override - public String toString() { - return "Orcish wolf"; - } - -} +package com.iluwatar.prototype; + +/** + * + * OrcBeast + * + */ +public class OrcBeast extends Beast { + + public OrcBeast() { + } + + public OrcBeast(OrcBeast beast) { + } + + @Override + public Beast clone() throws CloneNotSupportedException { + return new OrcBeast(this); + } + + @Override + public String toString() { + return "Orcish wolf"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java b/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java index a329ca61b..1f52a25d9 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java +++ b/prototype/src/main/java/com/iluwatar/prototype/OrcMage.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class OrcMage extends Mage { - - public OrcMage() { - } - - public OrcMage(OrcMage mage) { - } - - @Override - public Mage clone() throws CloneNotSupportedException { - return new OrcMage(this); - } - - @Override - public String toString() { - return "Orcish mage"; - } - -} +package com.iluwatar.prototype; + +/** + * + * OrcMage + * + */ +public class OrcMage extends Mage { + + public OrcMage() { + } + + public OrcMage(OrcMage mage) { + } + + @Override + public Mage clone() throws CloneNotSupportedException { + return new OrcMage(this); + } + + @Override + public String toString() { + return "Orcish mage"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java b/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java index 2832c3835..53814d1c2 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java +++ b/prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java @@ -1,21 +1,26 @@ -package com.iluwatar.prototype; - -public class OrcWarlord extends Warlord { - - public OrcWarlord() { - } - - public OrcWarlord(OrcWarlord warlord) { - } - - @Override - public Warlord clone() throws CloneNotSupportedException { - return new OrcWarlord(this); - } - - @Override - public String toString() { - return "Orcish warlord"; - } - -} +package com.iluwatar.prototype; + +/** + * + * OrcWarlord + * + */ +public class OrcWarlord extends Warlord { + + public OrcWarlord() { + } + + public OrcWarlord(OrcWarlord warlord) { + } + + @Override + public Warlord clone() throws CloneNotSupportedException { + return new OrcWarlord(this); + } + + @Override + public String toString() { + return "Orcish warlord"; + } + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/Prototype.java b/prototype/src/main/java/com/iluwatar/prototype/Prototype.java index 2329f1e6d..eb2520c35 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/Prototype.java +++ b/prototype/src/main/java/com/iluwatar/prototype/Prototype.java @@ -1,8 +1,13 @@ -package com.iluwatar.prototype; - -public abstract class Prototype implements Cloneable { - - @Override - public abstract Object clone() throws CloneNotSupportedException; - -} +package com.iluwatar.prototype; + +/** + * + * Prototype + * + */ +public abstract class Prototype implements Cloneable { + + @Override + public abstract Object clone() throws CloneNotSupportedException; + +} diff --git a/prototype/src/main/java/com/iluwatar/prototype/Warlord.java b/prototype/src/main/java/com/iluwatar/prototype/Warlord.java index 930320d97..bfd5c594a 100644 --- a/prototype/src/main/java/com/iluwatar/prototype/Warlord.java +++ b/prototype/src/main/java/com/iluwatar/prototype/Warlord.java @@ -1,8 +1,13 @@ -package com.iluwatar.prototype; - -public abstract class Warlord extends Prototype { - - @Override - public abstract Warlord clone() throws CloneNotSupportedException; - -} +package com.iluwatar.prototype; + +/** + * + * Warlord + * + */ +public abstract class Warlord extends Prototype { + + @Override + public abstract Warlord clone() throws CloneNotSupportedException; + +} diff --git a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java index ecb576038..030f5472c 100644 --- a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java +++ b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java @@ -1,14 +1,19 @@ -package com.iluwatar.prototype; - -import org.junit.Test; - -import com.iluwatar.prototype.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.prototype; + +import org.junit.Test; + +import com.iluwatar.prototype.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +}