#107 Improve JavaDoc for Prototype

This commit is contained in:
Ilkka Seppala 2015-08-21 22:45:03 +03:00
parent 8fb0ec1bf9
commit 0db6581cfd
12 changed files with 267 additions and 208 deletions

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -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;
}

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}
}