コード例 #1
0
ファイル: LandlordRole.java プロジェクト: trevorar/SimCity
 // 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();
 }
コード例 #2
0
ファイル: LandlordRole.java プロジェクト: trevorar/SimCity
 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();
 }
コード例 #3
0
ファイル: LandlordRole.java プロジェクト: trevorar/SimCity
 // ACTIONS
 private void collectRent(MyTenant mt) {
   if (!test) {
     log("Collecting rent now");
   }
   mt.tenant.msgRentDue(this, mt.rate);
   mt.newPayment = false;
   p.stateChanged();
 }
コード例 #4
0
ファイル: LandlordRole.java プロジェクト: trevorar/SimCity
 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();
 }