X Tutup
Skip to content

Commit 252f938

Browse files
committed
iluwatar#107 Improve JavaDoc for Mediator example
1 parent add57d4 commit 252f938

File tree

3 files changed

+71
-62
lines changed

3 files changed

+71
-62
lines changed
Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
package com.iluwatar.mediator;
2-
3-
/**
4-
*
5-
* Mediator encapsulates how a set of objects (PartyMember) interact. Instead of
6-
* referring to each other directly they use a mediator (Party) interface.
7-
*
8-
*/
9-
public class App {
10-
11-
public static void main(String[] args) {
12-
13-
// create party and members
14-
Party party = new PartyImpl();
15-
Hobbit hobbit = new Hobbit();
16-
Wizard wizard = new Wizard();
17-
Rogue rogue = new Rogue();
18-
Hunter hunter = new Hunter();
19-
20-
// add party members
21-
party.addMember(hobbit);
22-
party.addMember(wizard);
23-
party.addMember(rogue);
24-
party.addMember(hunter);
25-
26-
// perform actions -> the other party members
27-
// are notified by the party
28-
hobbit.act(Action.ENEMY);
29-
wizard.act(Action.TALE);
30-
rogue.act(Action.GOLD);
31-
hunter.act(Action.HUNT);
32-
}
33-
}
1+
package com.iluwatar.mediator;
2+
3+
/**
4+
*
5+
* Mediator encapsulates how a set of objects ({@link PartyMember}) interact. Instead of
6+
* referring to each other directly they use a mediator ({@link Party}) interface.
7+
*
8+
*/
9+
public class App {
10+
11+
/**
12+
* Program entry point
13+
* @param args command line args
14+
*/
15+
public static void main(String[] args) {
16+
17+
// create party and members
18+
Party party = new PartyImpl();
19+
Hobbit hobbit = new Hobbit();
20+
Wizard wizard = new Wizard();
21+
Rogue rogue = new Rogue();
22+
Hunter hunter = new Hunter();
23+
24+
// add party members
25+
party.addMember(hobbit);
26+
party.addMember(wizard);
27+
party.addMember(rogue);
28+
party.addMember(hunter);
29+
30+
// perform actions -> the other party members
31+
// are notified by the party
32+
hobbit.act(Action.ENEMY);
33+
wizard.act(Action.TALE);
34+
rogue.act(Action.GOLD);
35+
hunter.act(Action.HUNT);
36+
}
37+
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
package com.iluwatar.mediator;
2-
3-
/**
4-
*
5-
* Interface for party members interacting with Party.
6-
*
7-
*/
8-
public interface PartyMember {
9-
10-
void joinedParty(Party party);
11-
12-
void partyAction(Action action);
13-
14-
void act(Action action);
15-
}
1+
package com.iluwatar.mediator;
2+
3+
/**
4+
*
5+
* Interface for party members interacting with {@link Party}.
6+
*
7+
*/
8+
public interface PartyMember {
9+
10+
void joinedParty(Party party);
11+
12+
void partyAction(Action action);
13+
14+
void act(Action action);
15+
}
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
package com.iluwatar.mediator;
2-
3-
import org.junit.Test;
4-
5-
import com.iluwatar.mediator.App;
6-
7-
public class AppTest {
8-
9-
@Test
10-
public void test() {
11-
String[] args = {};
12-
App.main(args);
13-
}
14-
}
1+
package com.iluwatar.mediator;
2+
3+
import org.junit.Test;
4+
5+
import com.iluwatar.mediator.App;
6+
7+
/**
8+
*
9+
* Application test
10+
*
11+
*/
12+
public class AppTest {
13+
14+
@Test
15+
public void test() {
16+
String[] args = {};
17+
App.main(args);
18+
}
19+
}

0 commit comments

Comments
 (0)
X Tutup