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
LandlordRole
Matthew Pohlmann edited this page Jan 1, 2014
·
1 revision
####Description A landlord keeps track of his properties and collects rent from Renters when rent is due. He also performs maintenance when necessary.
####Class Signature
public class LandlordRole extends Role implements Landlord{}
####Data
List<myProperty> myProperties;
double latePenalty;
boolean closingTime;
enum RentState {notDue, dueNotNotified, dueNotified, lateNotNotified, lateNotified, paid};
private class myProperty {
Residence residence;
Renter renter;
double amtDue;
WeekDay dayDue;
RentState state;
boolean needsMaintenance;
myProperty(Residence res, Renter ren, double a, Date d) {
residence = res;
renter = ren;
amtDue = a;
dayDue = d;
}
public boolean needsMaintenance() {
return needsMaintenance;
}
}
####Scheduler
if Ǝ myProperty mP in myProperties ∋ mP.state == RentState.paid then,
mP.state = notDue;
if Ǝ myProperty mP in myProperties ∋ getTomorrow() == mP.dayDue && mP.state == RentState.notDue then,
mP.state = dueNotNotified;
if Ǝ myProperty mP in myProperties ∋ getToday() == mP.dayDue && mP.state == RentState.dueNotified then,
mP.state = lateNotNotified;
if Ǝ myProperty mP in myProperties ∋ mP.state == dueNotNotified then,
RequestRent(mP);
if Ǝ myProperty mP in myProperties ∋ mP.state == lateNotNotified then,
RequestLateRent(mP);
if Ǝ myProperty mP in myProperties ∋ mP.needsMaintainence() then,
FixProperty(mP);
####Messages
public void msgHereIsRentPayment(Renter r, double amt) {
if Ǝ myProperty mP in myProperties ∋ mP.renter == r then,
mP.state = paid;
}
public void msgPropertyNeedsMaintenance(Renter r, Residence res) {
if Ǝ myProperty mP in myProperties ∋ mP.residence == res then,
mP.needsMaintenance = true;
}
####Actions
private void RequestRent(myProperty mP) {
mP.renter.msgRentDueYouOwe(mP.amtDue);
mP.state = dueNotified;
}
private void RequestLateRent(myProperty mP) {
mP.renter.msgRentLateYouOweAdditional(latePenalty);
mP.state = lateNotified;
}
private void FixProperty(myProperty mP) {
//perform maintenance task on property
mP.residence.performMaintenance(); //will likely be more specific
}
private void exitOffice() {
isActive = false;
myPerson.goOffWork();
}
####Utilities
public void addProperty(Residence res, Renter renter, double rentAmount, Date rentDueDate) {
myProperty mP = new myProperty(res, renter, rentAmount, rentDueDate);
myProperties.add(mP);
}