#108 Consistent package naming throughout the examples

This commit is contained in:
Ilkka Seppala
2015-07-24 11:32:22 +03:00
parent af92d8dde5
commit 3d488ec15a
128 changed files with 963 additions and 873 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="com.iluwatar.factorymethod.OrcBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/OrcBlacksmith.java" binary="false"
<class id="1" language="java" name="com.iluwatar.factory.method.OrcBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/OrcBlacksmith.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="280" x="-46" y="239"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -11,8 +11,9 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="2" language="java" name="com.iluwatar.factorymethod.Blacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/Blacksmith.java" binary="false" corner="BOTTOM_RIGHT">
<interface id="2" language="java" name="com.iluwatar.factory.method.Blacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/Blacksmith.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="88" width="280" x="114" y="385"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -20,8 +21,9 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<enumeration id="3" language="java" name="com.iluwatar.factorymethod.WeaponType" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/WeaponType.java" binary="false" corner="BOTTOM_RIGHT">
<enumeration id="3" language="java" name="com.iluwatar.factory.method.WeaponType" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="196" width="210" x="793" y="385"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -29,8 +31,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</enumeration>
<class id="4" language="java" name="com.iluwatar.factorymethod.OrcWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/OrcWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<class id="4" language="java" name="com.iluwatar.factory.method.OrcWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="106" width="178" x="806" y="239"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -38,8 +40,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="com.iluwatar.factorymethod.ElfWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/ElfWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<class id="5" language="java" name="com.iluwatar.factory.method.ElfWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="106" width="172" x="594" y="239"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -47,8 +49,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="6" language="java" name="com.iluwatar.factorymethod.Weapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/Weapon.java" binary="false" corner="BOTTOM_RIGHT">
<interface id="6" language="java" name="com.iluwatar.factory.method.Weapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="70" width="159" x="594" y="385"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -56,8 +58,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="7" language="java" name="com.iluwatar.factorymethod.ElfBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factorymethod/ElfBlacksmith.java" binary="false"
<class id="7" language="java" name="com.iluwatar.factory.method.ElfBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/ElfBlacksmith.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="280" x="274" y="239"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -67,37 +69,45 @@
</display>
</class>
<realization id="8">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="6"/>
</realization>
<realization id="9">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</realization>
<association id="10">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="11" name="weaponType"/>
<multiplicity id="12" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="13">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</realization>
<association id="14">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="15" name="weaponType"/>
<multiplicity id="16" minimum="0" maximum="1"/>
<realization id="9">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="2"/>
</realization>
<realization id="10">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="6"/>
</realization>
<association id="11">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="12" name="weaponType">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="13" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="17">
<end type="SOURCE" refId="7"/>
<realization id="14">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</realization>
<association id="15">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="16" name="weaponType">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="17" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>

View File

@@ -1,28 +1,28 @@
package com.iluwatar.factorymethod;
/**
*
* In Factory Method we have an interface (Blacksmith) with a method for
* creating objects (manufactureWeapon). The concrete subclasses (OrcBlacksmith,
* ElfBlacksmith) then override the method to produce objects of their liking.
*
*/
public class App {
public static void main(String[] args) {
Blacksmith blacksmith;
Weapon weapon;
blacksmith = new OrcBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.AXE);
System.out.println(weapon);
blacksmith = new ElfBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SHORT_SWORD);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
}
}
package com.iluwatar.factory.method;
/**
*
* In Factory Method we have an interface (Blacksmith) with a method for
* creating objects (manufactureWeapon). The concrete subclasses (OrcBlacksmith,
* ElfBlacksmith) then override the method to produce objects of their liking.
*
*/
public class App {
public static void main(String[] args) {
Blacksmith blacksmith;
Weapon weapon;
blacksmith = new OrcBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.AXE);
System.out.println(weapon);
blacksmith = new ElfBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SHORT_SWORD);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
}
}

View File

@@ -1,12 +1,12 @@
package com.iluwatar.factorymethod;
/**
*
* The interface containing method for producing objects.
*
*/
public interface Blacksmith {
Weapon manufactureWeapon(WeaponType weaponType);
}
package com.iluwatar.factory.method;
/**
*
* The interface containing method for producing objects.
*
*/
public interface Blacksmith {
Weapon manufactureWeapon(WeaponType weaponType);
}

View File

@@ -1,14 +1,14 @@
package com.iluwatar.factorymethod;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class ElfBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {
return new ElfWeapon(weaponType);
}
}
package com.iluwatar.factory.method;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class ElfBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {
return new ElfWeapon(weaponType);
}
}

View File

@@ -1,16 +1,16 @@
package com.iluwatar.factorymethod;
public class ElfWeapon implements Weapon {
private WeaponType weaponType;
public ElfWeapon(WeaponType weaponType) {
this.weaponType = weaponType;
}
@Override
public String toString() {
return "Elven " + weaponType;
}
}
package com.iluwatar.factory.method;
public class ElfWeapon implements Weapon {
private WeaponType weaponType;
public ElfWeapon(WeaponType weaponType) {
this.weaponType = weaponType;
}
@Override
public String toString() {
return "Elven " + weaponType;
}
}

View File

@@ -1,14 +1,14 @@
package com.iluwatar.factorymethod;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class OrcBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {
return new OrcWeapon(weaponType);
}
}
package com.iluwatar.factory.method;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class OrcBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {
return new OrcWeapon(weaponType);
}
}

View File

@@ -1,16 +1,16 @@
package com.iluwatar.factorymethod;
public class OrcWeapon implements Weapon {
private WeaponType weaponType;
public OrcWeapon(WeaponType weaponType) {
this.weaponType = weaponType;
}
@Override
public String toString() {
return "Orcish " + weaponType;
}
}
package com.iluwatar.factory.method;
public class OrcWeapon implements Weapon {
private WeaponType weaponType;
public OrcWeapon(WeaponType weaponType) {
this.weaponType = weaponType;
}
@Override
public String toString() {
return "Orcish " + weaponType;
}
}

View File

@@ -0,0 +1,5 @@
package com.iluwatar.factory.method;
public interface Weapon {
}

View File

@@ -1,17 +1,17 @@
package com.iluwatar.factorymethod;
public enum WeaponType {
SHORT_SWORD("short sword"), SPEAR("spear"), AXE("axe"), UNDEFINED("");
private String title;
WeaponType(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}
package com.iluwatar.factory.method;
public enum WeaponType {
SHORT_SWORD("short sword"), SPEAR("spear"), AXE("axe"), UNDEFINED("");
private String title;
WeaponType(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}

View File

@@ -1,5 +0,0 @@
package com.iluwatar.factorymethod;
public interface Weapon {
}

View File

@@ -1,14 +1,14 @@
package com.iluwatar.factorymethod;
import org.junit.Test;
import com.iluwatar.factorymethod.App;
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}
package com.iluwatar.factory.method;
import org.junit.Test;
import com.iluwatar.factory.method.App;
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}