//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : HeroFactory.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public interface HeroFactory {
public Mage createMage();
public Warlord createWarlord();
public Beast createBeast();
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : HeroFactoryImpl.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class HeroFactoryImpl implements HeroFactory {
public Mage mage;
public Warlord warlord;
public Beast beast;
public HeroFactoryImpl(Mage mage, Warlord warlord, Beast beast) {
this.mage = mage;
this.warlord = warlord;
this.beast = beast;
}
public Mage createMage() {
try {
return mage.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
public Warlord createWarlord() {
try {
return warlord.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
public Beast createBeast() {
try {
return beast.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Prototype.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public abstract class Prototype {
public abstract Object clone() throws CloneNotSupportedException;
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Beast.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public abstract class Beast extends Prototype {
public abstract Beast clone() throws CloneNotSupportedException;
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Mage.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public abstract class Mage extends Prototype {
public abstract Mage clone() throws CloneNotSupportedException;
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Warlord.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public abstract class Warlord extends Prototype {
public abstract Warlord clone() throws CloneNotSupportedException;
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : OrcWarlorc.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class OrcWarlord extends Warlord {
private OrcWarlord orcWarlord;
public OrcWarlord() {
}
public OrcWarlord(OrcWarlord orcWarlord) {
this.orcWarlord = orcWarlord;
}
public String toString() {
return "Orcish warlord";
}
@Override
public Warlord clone() throws CloneNotSupportedException {
return new OrcWarlord(this);
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : OrcMage.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class OrcMage extends Mage {
private OrcMage orcMage;
public OrcMage() {
}
public OrcMage(OrcMage orcMage) {
this.orcMage = orcMage;
}
public String toString() {
return "Orcish mage";
}
@Override
public Mage clone() throws CloneNotSupportedException {
return new OrcMage(this);
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : OrcBeast.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class OrcBeast extends Beast {
private OrcBeast orcBeast;
public OrcBeast() {
}
public OrcBeast(OrcBeast orcBeast) {
this.orcBeast = orcBeast;
}
public String toString() {
return "Orcish wolf";
}
@Override
public Beast clone() throws CloneNotSupportedException {
return new OrcBeast(this);
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : ElfWarlord.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class ElfWarlord extends Warlord {
private ElfWarlord elfWarlord;
public ElfWarlord() {
}
public ElfWarlord(ElfWarlord elfWarlord) {
this.elfWarlord = elfWarlord;
}
public String toString() {
return "Elven warlord";
}
@Override
public Warlord clone() throws CloneNotSupportedException {
return new ElfWarlord(this);
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : ElfMage.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class ElfMage extends Mage {
private ElfMage elfMage = null;
public ElfMage() {
}
public ElfMage(ElfMage elfMage) {
this.elfMage = elfMage;
}
@Override
public Mage clone() throws CloneNotSupportedException {
return new ElfMage(this);
}
public String toString() {
return "Elven mage";
}
}
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : ElfBeast.java
// @ Date : 2016/8/22
// @ Author : wuchao
//
//
public class ElfBeast extends Beast {
private ElfBeast elfBeast = null;
public ElfBeast() {
}
public ElfBeast(ElfBeast elfBeast) {
this.elfBeast = elfBeast;
}
@Override
public Beast clone() throws CloneNotSupportedException {
return new ElfBeast(this);
}
@Override
public String toString() {
return "Elven eagle";
}
}
java设计模式进阶_prototype
最新推荐文章于 2024-09-01 16:58:50 发布