2014-08-21 20:06:49 +03:00
|
|
|
package com.iluwatar;
|
|
|
|
|
2015-01-07 21:19:28 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Abstract base class for party members.
|
|
|
|
*
|
|
|
|
*/
|
2014-08-21 20:06:49 +03:00
|
|
|
public abstract class PartyMemberBase implements PartyMember {
|
|
|
|
|
|
|
|
protected Party party;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void joinedParty(Party party) {
|
|
|
|
System.out.println(this + " joins the party");
|
|
|
|
this.party = party;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void partyAction(Action action) {
|
2015-02-10 09:48:22 +02:00
|
|
|
System.out.println(this + " " + action.getDescription());
|
2014-08-21 20:06:49 +03:00
|
|
|
}
|
2014-10-08 13:42:12 +01:00
|
|
|
|
2014-08-21 20:06:49 +03:00
|
|
|
@Override
|
|
|
|
public void act(Action action) {
|
|
|
|
if (party != null) {
|
|
|
|
System.out.println(this + " " + action.toString());
|
|
|
|
party.act(this, action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public abstract String toString();
|
2014-10-08 13:42:12 +01:00
|
|
|
|
2014-08-21 20:06:49 +03:00
|
|
|
}
|