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

@ -5,7 +5,7 @@ public enum Action {
HUNT, TALE, GOLD, ENEMY;
public String toString() {
String s = "";
switch (this) {
case ENEMY:

View File

@ -1,28 +1,28 @@
package com.iluwatar;
/**
*
*
* Mediator encapsulates how set of objects (PartyMember) interact. Instead of
* referring to each other directly they use the mediator (Party) interface.
*
*
*/
public class App {
public static void main(String[] args) {
Party party = new PartyImpl();
Hobbit hobbit = new Hobbit();
Wizard wizard = new Wizard();
Rogue rogue = new Rogue();
Hunter hunter = new Hunter();
public static void main(String[] args) {
Party party = new PartyImpl();
Hobbit hobbit = new Hobbit();
Wizard wizard = new Wizard();
Rogue rogue = new Rogue();
Hunter hunter = new Hunter();
party.addMember(hobbit);
party.addMember(wizard);
party.addMember(rogue);
party.addMember(hunter);
party.addMember(hobbit);
party.addMember(wizard);
party.addMember(rogue);
party.addMember(hunter);
hobbit.act(Action.ENEMY);
wizard.act(Action.TALE);
rogue.act(Action.GOLD);
hunter.act(Action.HUNT);
}
hobbit.act(Action.ENEMY);
wizard.act(Action.TALE);
rogue.act(Action.GOLD);
hunter.act(Action.HUNT);
}
}

View File

@ -3,12 +3,12 @@ package com.iluwatar;
/**
*
* Mediator interface.
*
*
*/
public interface Party {
void addMember(PartyMember member);
void act(PartyMember actor, Action action);
}

View File

@ -6,14 +6,14 @@ import java.util.List;
public class PartyImpl implements Party {
private List<PartyMember> members;
public PartyImpl() {
members = new ArrayList<>();
}
@Override
public void act(PartyMember actor, Action action) {
for (PartyMember member: members) {
for (PartyMember member : members) {
if (member != actor) {
member.partyAction(action);
}
@ -25,13 +25,13 @@ public class PartyImpl implements Party {
members.add(member);
member.joinedParty(this);
}
// somebody hunts for food, call for dinner
// somebody spots enemy, alert everybody
// somebody finds gold, deal the gold with everybody
// somebody tells a tale, call everybody to listen
}

View File

@ -3,12 +3,12 @@ package com.iluwatar;
/**
*
* Interface for party members interacting with Party.
*
*
*/
public interface PartyMember {
void joinedParty(Party party);
void partyAction(Action action);
void act(Action action);

View File

@ -31,7 +31,7 @@ public abstract class PartyMemberBase implements PartyMember {
}
System.out.println(s);
}
@Override
public void act(Action action) {
if (party != null) {
@ -42,5 +42,5 @@ public abstract class PartyMemberBase implements PartyMember {
@Override
public abstract String toString();
}