This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
RenterRole
Matthew Pohlmann edited this page Jan 1, 2014
·
1 revision
####Description A renter is a Resident who additionally must pay rent to his/her Landlord when rent is due.
####Class Signature
public class RenterRole extends ResidentRole implements Renter{}
####Data
Landlord myLandlord;
double amtRentOwed;
####Scheduler
if (amtRentOwed>0) then,
if (myPerson.getMoney()>=amtRentOwed) then,
PayRent(myLandlord, amtRentOwed);
else
//WithdrawMoneyPerson(amtRentOwed-myPerson.getMoney());
####Messages
public void msgRentDueYouOwe (double amt) {
amtRentOwed += amt;
stateChanged();
}
public void msgRentLateYouOweAdditional (double amt) {
amtRentOwed += amt;
stateChanged();
}
####Actions
private void PayRent (Landlord l, double amt) {
l.msgHereIsRentPayment(this, amt);
amtRentOwed -= amt;
getPerson().removeMoney(amt);
}
public void startInteraction(Intention intent) {
if (intent == Intention.ResidencePayRent){
state = ResidentState.payingRent;
stateChanged();
}
super.startInteraction(intent);
}