Formatted all files to the same standard

This commit is contained in:
matthew
2014-10-08 13:42:12 +01:00
parent 53a2a8b150
commit 3da9ad5469
151 changed files with 952 additions and 870 deletions

View File

@ -1,28 +1,28 @@
package com.iluwatar;
/**
*
*
* 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;
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 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);
}
blacksmith = new ElfBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SHORT_SWORD);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
}
}

View File

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

View File

@ -3,7 +3,7 @@ package com.iluwatar;
/**
*
* Concrete subclass for creating new objects.
*
*
*/
public class ElfBlacksmith implements Blacksmith {

View File

@ -12,5 +12,5 @@ public class ElfWeapon implements Weapon {
public String toString() {
return "Elven " + weaponType;
}
}

View File

@ -3,7 +3,7 @@ package com.iluwatar;
/**
*
* Concrete subclass for creating new objects.
*
*
*/
public class OrcBlacksmith implements Blacksmith {

View File

@ -12,5 +12,5 @@ public class OrcWeapon implements Weapon {
public String toString() {
return "Orcish " + weaponType;
}
}

View File

@ -7,13 +7,18 @@ public enum WeaponType {
@Override
public String toString() {
String s = "";
switch(this) {
case SHORT_SWORD: s = "short sword"; break;
case SPEAR: s = "spear"; break;
case AXE: s = "axe"; break;
switch (this) {
case SHORT_SWORD:
s = "short sword";
break;
case SPEAR:
s = "spear";
break;
case AXE:
s = "axe";
break;
}
return s;
}
}