#107 Improve JavaDoc for Prototype
This commit is contained in:
parent
8fb0ec1bf9
commit
0db6581cfd
@ -1,36 +1,40 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* In Prototype we have a factory class (HeroFactoryImpl) producing objects by
|
* In Prototype we have a factory class ({@link HeroFactoryImpl}) producing objects by
|
||||||
* cloning existing ones. In this example the factory's prototype objects are
|
* cloning the existing ones. In this example the factory's prototype objects are
|
||||||
* given as constructor parameters.
|
* given as constructor parameters.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
/**
|
||||||
HeroFactory factory;
|
* Program entry point
|
||||||
Mage mage;
|
* @param args command line args
|
||||||
Warlord warlord;
|
*/
|
||||||
Beast beast;
|
public static void main(String[] args) {
|
||||||
|
HeroFactory factory;
|
||||||
factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(),
|
Mage mage;
|
||||||
new ElfBeast());
|
Warlord warlord;
|
||||||
mage = factory.createMage();
|
Beast beast;
|
||||||
warlord = factory.createWarlord();
|
|
||||||
beast = factory.createBeast();
|
factory = new HeroFactoryImpl(new ElfMage(), new ElfWarlord(),
|
||||||
System.out.println(mage);
|
new ElfBeast());
|
||||||
System.out.println(warlord);
|
mage = factory.createMage();
|
||||||
System.out.println(beast);
|
warlord = factory.createWarlord();
|
||||||
|
beast = factory.createBeast();
|
||||||
factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(),
|
System.out.println(mage);
|
||||||
new OrcBeast());
|
System.out.println(warlord);
|
||||||
mage = factory.createMage();
|
System.out.println(beast);
|
||||||
warlord = factory.createWarlord();
|
|
||||||
beast = factory.createBeast();
|
factory = new HeroFactoryImpl(new OrcMage(), new OrcWarlord(),
|
||||||
System.out.println(mage);
|
new OrcBeast());
|
||||||
System.out.println(warlord);
|
mage = factory.createMage();
|
||||||
System.out.println(beast);
|
warlord = factory.createWarlord();
|
||||||
}
|
beast = factory.createBeast();
|
||||||
}
|
System.out.println(mage);
|
||||||
|
System.out.println(warlord);
|
||||||
|
System.out.println(beast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public abstract class Beast extends Prototype {
|
/**
|
||||||
|
*
|
||||||
@Override
|
* Beast
|
||||||
public abstract Beast clone() throws CloneNotSupportedException;
|
*
|
||||||
|
*/
|
||||||
}
|
public abstract class Beast extends Prototype {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Beast clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class ElfBeast extends Beast {
|
/**
|
||||||
|
*
|
||||||
public ElfBeast() {
|
* ElfBeast
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public ElfBeast(ElfBeast beast) {
|
public class ElfBeast extends Beast {
|
||||||
}
|
|
||||||
|
public ElfBeast() {
|
||||||
@Override
|
}
|
||||||
public Beast clone() throws CloneNotSupportedException {
|
|
||||||
return new ElfBeast(this);
|
public ElfBeast(ElfBeast beast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Beast clone() throws CloneNotSupportedException {
|
||||||
return "Elven eagle";
|
return new ElfBeast(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Elven eagle";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class ElfMage extends Mage {
|
/**
|
||||||
|
*
|
||||||
public ElfMage() {
|
* ElfMage
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public ElfMage(ElfMage mage) {
|
public class ElfMage extends Mage {
|
||||||
}
|
|
||||||
|
public ElfMage() {
|
||||||
@Override
|
}
|
||||||
public Mage clone() throws CloneNotSupportedException {
|
|
||||||
return new ElfMage(this);
|
public ElfMage(ElfMage mage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Mage clone() throws CloneNotSupportedException {
|
||||||
return "Elven mage";
|
return new ElfMage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Elven mage";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class ElfWarlord extends Warlord {
|
/**
|
||||||
|
*
|
||||||
public ElfWarlord() {
|
* ElfWarlord
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public ElfWarlord(ElfWarlord warlord) {
|
public class ElfWarlord extends Warlord {
|
||||||
}
|
|
||||||
|
public ElfWarlord() {
|
||||||
@Override
|
}
|
||||||
public Warlord clone() throws CloneNotSupportedException {
|
|
||||||
return new ElfWarlord(this);
|
public ElfWarlord(ElfWarlord warlord) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Warlord clone() throws CloneNotSupportedException {
|
||||||
return "Elven warlord";
|
return new ElfWarlord(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Elven warlord";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public abstract class Mage extends Prototype {
|
/**
|
||||||
|
*
|
||||||
@Override
|
* Mage
|
||||||
public abstract Mage clone() throws CloneNotSupportedException;
|
*
|
||||||
|
*/
|
||||||
}
|
public abstract class Mage extends Prototype {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Mage clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class OrcBeast extends Beast {
|
/**
|
||||||
|
*
|
||||||
public OrcBeast() {
|
* OrcBeast
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public OrcBeast(OrcBeast beast) {
|
public class OrcBeast extends Beast {
|
||||||
}
|
|
||||||
|
public OrcBeast() {
|
||||||
@Override
|
}
|
||||||
public Beast clone() throws CloneNotSupportedException {
|
|
||||||
return new OrcBeast(this);
|
public OrcBeast(OrcBeast beast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Beast clone() throws CloneNotSupportedException {
|
||||||
return "Orcish wolf";
|
return new OrcBeast(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Orcish wolf";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class OrcMage extends Mage {
|
/**
|
||||||
|
*
|
||||||
public OrcMage() {
|
* OrcMage
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public OrcMage(OrcMage mage) {
|
public class OrcMage extends Mage {
|
||||||
}
|
|
||||||
|
public OrcMage() {
|
||||||
@Override
|
}
|
||||||
public Mage clone() throws CloneNotSupportedException {
|
|
||||||
return new OrcMage(this);
|
public OrcMage(OrcMage mage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Mage clone() throws CloneNotSupportedException {
|
||||||
return "Orcish mage";
|
return new OrcMage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Orcish mage";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public class OrcWarlord extends Warlord {
|
/**
|
||||||
|
*
|
||||||
public OrcWarlord() {
|
* OrcWarlord
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
public OrcWarlord(OrcWarlord warlord) {
|
public class OrcWarlord extends Warlord {
|
||||||
}
|
|
||||||
|
public OrcWarlord() {
|
||||||
@Override
|
}
|
||||||
public Warlord clone() throws CloneNotSupportedException {
|
|
||||||
return new OrcWarlord(this);
|
public OrcWarlord(OrcWarlord warlord) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public Warlord clone() throws CloneNotSupportedException {
|
||||||
return "Orcish warlord";
|
return new OrcWarlord(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Orcish warlord";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public abstract class Prototype implements Cloneable {
|
/**
|
||||||
|
*
|
||||||
@Override
|
* Prototype
|
||||||
public abstract Object clone() throws CloneNotSupportedException;
|
*
|
||||||
|
*/
|
||||||
}
|
public abstract class Prototype implements Cloneable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Object clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
public abstract class Warlord extends Prototype {
|
/**
|
||||||
|
*
|
||||||
@Override
|
* Warlord
|
||||||
public abstract Warlord clone() throws CloneNotSupportedException;
|
*
|
||||||
|
*/
|
||||||
}
|
public abstract class Warlord extends Prototype {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Warlord clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package com.iluwatar.prototype;
|
package com.iluwatar.prototype;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.iluwatar.prototype.App;
|
import com.iluwatar.prototype.App;
|
||||||
|
|
||||||
public class AppTest {
|
/**
|
||||||
|
*
|
||||||
@Test
|
* Application test
|
||||||
public void test() {
|
*
|
||||||
String[] args = {};
|
*/
|
||||||
App.main(args);
|
public class AppTest {
|
||||||
}
|
|
||||||
}
|
@Test
|
||||||
|
public void test() {
|
||||||
|
String[] args = {};
|
||||||
|
App.main(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user