#107 Improve JavaDoc for Mediator example

This commit is contained in:
Ilkka Seppala 2015-08-19 22:12:05 +03:00
parent add57d4066
commit 252f93899f
3 changed files with 71 additions and 62 deletions

View File

@ -1,33 +1,37 @@
package com.iluwatar.mediator; package com.iluwatar.mediator;
/** /**
* *
* Mediator encapsulates how a set of objects (PartyMember) interact. Instead of * Mediator encapsulates how a set of objects ({@link PartyMember}) interact. Instead of
* referring to each other directly they use a mediator (Party) interface. * referring to each other directly they use a mediator ({@link Party}) interface.
* *
*/ */
public class App { public class App {
public static void main(String[] args) { /**
* Program entry point
// create party and members * @param args command line args
Party party = new PartyImpl(); */
Hobbit hobbit = new Hobbit(); public static void main(String[] args) {
Wizard wizard = new Wizard();
Rogue rogue = new Rogue(); // create party and members
Hunter hunter = new Hunter(); Party party = new PartyImpl();
Hobbit hobbit = new Hobbit();
// add party members Wizard wizard = new Wizard();
party.addMember(hobbit); Rogue rogue = new Rogue();
party.addMember(wizard); Hunter hunter = new Hunter();
party.addMember(rogue);
party.addMember(hunter); // add party members
party.addMember(hobbit);
// perform actions -> the other party members party.addMember(wizard);
// are notified by the party party.addMember(rogue);
hobbit.act(Action.ENEMY); party.addMember(hunter);
wizard.act(Action.TALE);
rogue.act(Action.GOLD); // perform actions -> the other party members
hunter.act(Action.HUNT); // are notified by the party
} hobbit.act(Action.ENEMY);
} wizard.act(Action.TALE);
rogue.act(Action.GOLD);
hunter.act(Action.HUNT);
}
}

View File

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

View File

@ -1,14 +1,19 @@
package com.iluwatar.mediator; package com.iluwatar.mediator;
import org.junit.Test; import org.junit.Test;
import com.iluwatar.mediator.App; import com.iluwatar.mediator.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);
}
}