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

View File

@ -1,14 +1,19 @@
package com.iluwatar.mediator;
import org.junit.Test;
import com.iluwatar.mediator.App;
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}
package com.iluwatar.mediator;
import org.junit.Test;
import com.iluwatar.mediator.App;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}