35 lines
655 B
Java
Raw Normal View History

2014-08-21 20:06:49 +03:00
package com.iluwatar;
/**
*
* 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) {
System.out.println(this + " " + action.getDescription());
2014-08-21 20:06:49 +03: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-08-21 20:06:49 +03:00
}