Ejemplo n.º 1
0
 // MESSAGES
 public void msgCollectRent() {
   log.add(new LoggedEvent("Recieved msgEndOfDay, all tenants now should have rent due"));
   if (!test) {
     log("Time to collect rent from all of my tenants!");
   }
   synchronized (tenants) {
     for (MyTenant t : tenants) {
       t.numOutstandingPayments++;
       t.newPayment = true;
       if (t.numOutstandingPayments > 0) {
         t.paymentsUpToDate = false;
       }
     }
   }
   this.p.stateChanged();
 }
Ejemplo n.º 2
0
 public void msgFixAppliance(Person p, String a) {
   log.add(
       new LoggedEvent(
           "Recieved msgFixAppliance from tenant, tenant should now have "
               + a
               + " in needsMaintenance"));
   synchronized (tenants) {
     for (MyTenant t : tenants) {
       if (t.tenant.equals(p)) {
         t.needsMaintenance.add(a);
         t.maintenance = true;
       }
     }
   }
   this.p.stateChanged();
 }
Ejemplo n.º 3
0
 // ACTIONS
 private void collectRent(MyTenant mt) {
   if (!test) {
     log("Collecting rent now");
   }
   mt.tenant.msgRentDue(this, mt.rate);
   mt.newPayment = false;
   p.stateChanged();
 }
Ejemplo n.º 4
0
 public void msgHereIsMyRent(
     Person p,
     double amount) { // for the normative scenario, assuming tenant always pays correct amount for
   // rent
   log.add(
       new LoggedEvent(
           "Recieved msgHereIsMyRent from tenant, tenant should now have no outstanding payments due"));
   if (!test) {
     log("Yay, " + p.getName() + " payed their rent!");
   }
   earnings += amount;
   synchronized (tenants) {
     for (MyTenant t : tenants) {
       if (t.tenant.equals(p)) {
         t.numOutstandingPayments--;
         if (t.numOutstandingPayments <= 0) {
           t.paymentsUpToDate = true;
         }
       }
     }
   }
   this.p.stateChanged();
 }