public void msgRestaurantFull(int waitingSpot) {
    this.waitingSpot = waitingSpot;
    int randomChoice = ranGenerator.nextInt(6);

    // Hacks to demonstrate working code. "patient" will always wait while "impatient" will leave
    if (name.equals("patient")) {
      log("I'm in no hurry, I'll wait around.");
      goingInside = true;
      person.stateChanged();
      return;
    }
    if (name.equals("impatient")) {
      log("I don't have time to wait around!");
      event = AgentEvent.leaving;
      person.stateChanged();
      return;
    }

    if (randomChoice == 0) {
      log("I don't have time to wait around!");
      event = AgentEvent.leaving;
    } else if (randomChoice > 0) {
      log("I'm in no hurry, I'll wait around.");
      goingInside = true;
    }
    person.stateChanged();
  }
  private void leaveRestaurant() {
    check = null;
    log("I'm leaving! Goodbye!");
    customerGui.DoExitRestaurant();

    person.setGuiVisible();
    person.setRoleInactive(this);
  }
Esempio n. 3
0
 public void HeartAttack() {
   for (PersonAgent p : cp.people) {
     if (p.job != null) {
       if (p.job.type == JobType.professor) {
         p.msgHaveHeartAttack();
       }
     }
   }
 }
Esempio n. 4
0
 public void finish() {
   for (PersonAgent p : cp.people) {
     if (p.job != null) {
       if (p.job.type == JobType.student) {
         p.msgGoBotherTheCPs();
       }
     }
   }
 }
Esempio n. 5
0
  public void CallScenarioB(CityPanel c) {
    //	All workplaces fully employed.
    //	Day starts and all workers go to work.
    //	Three not-working persons eat at home, then visit all the workplaces in different orders.
    //	[one should walk; one should take a car; one should take a bus.]

    workShift();
    setDanielRestClosed(c);
    oneBuildEmployed(c);

    PersonAgent p = new PersonAgent("Driver", "None", "Wealthy");
    p.GiveCar();
    p.addItem("Juice", 0, 2, 2);
    p.setBus(false);
    c.addPerson(p);

    PersonAgent p2 = new PersonAgent("Busser", "None", "Average");
    p2.setBus(true);
    c.addPerson(p2);

    PersonAgent p3 = new PersonAgent("Walker", "None", "Poor");
    p3.setBus(false);
    p3.setHungry();
    c.addPerson(p3);
  }
Esempio n. 6
0
  public void CallScenarioA(CityPanel c) { // for points 1-4
    // 	A:
    //	All workplaces (markets, all restaurants, banks) fully employed.
    //	Day starts and all workers go to work.
    //	One not-working person eats at home, then visits all the workplaces by walking.
    //	Roads should have appropriate complexity [e.g. intersections with stop signs and/or signals]

    workShift();
    setDanielRestClosed(c);
    oneBuildEmployed(c);
    PersonAgent p = new PersonAgent("Scen A", "None", "Wealthy");
    p.addItem("Juice", 0, 2, 2);
    c.addPerson(p);
    p.setHungry();
    p.setBus(false);
  }
Esempio n. 7
0
 // ACTIONS
 private void collectRent(MyTenant mt) {
   if (!test) {
     log("Collecting rent now");
   }
   mt.tenant.msgRentDue(this, mt.rate);
   mt.newPayment = false;
   p.stateChanged();
 }
Esempio n. 8
0
 private void fixAppliance(final MyTenant mt) {
   System.out.println("Time for me to fix the appliance");
   if (!test) {
     log("Going to fix a tenant's appliance.");
   }
   final String temp = mt.needsMaintenance.remove(0);
   if (!test) {
     PersonTask pt = new PersonTask("goToApartment");
     p.DoGoTo(mt.tenant.getHouse().getName(), pt);
     if (temp.equals("Stove")) {
       gui.goToStove();
     } else if (temp.equals("Oven")) {
       gui.goToOven();
     } else if (temp.equals("Microwave")) {
       gui.goToStove();
     }
     try {
       atDest.acquire();
     } catch (InterruptedException e) {
     }
   }
   fix.schedule(
       new TimerTask() {
         @Override
         public void run() {
           System.out.println("sending msg fixed");
           mt.tenant.msgFixed(temp);
           mt.maintenance = false;
           if (!test) {
             log("All fixed, time to go home");
             gui.goToExit();
             try {
               atDest.acquire();
             } catch (InterruptedException e) {
             }
             gui.setPresent(false);
             mt.house.getAnimationPanel().notInHouse(gui);
             setRoleInactive = true;
           }
           p.stateChanged();
           return;
         }
       },
       4000);
 }
 public void msgAnimationDoneLeaving() {
   event = AgentEvent.leaving;
   person.stateChanged();
 }
 public void msgGotHungry() { // from animation
   log("I'm hungry");
   event = AgentEvent.gotHungry;
   person.stateChanged();
 }
 public void msgFollowMe(Restaurant1WaiterRole w, Restaurant1Menu m) {
   waiter = w;
   menu = m;
   event = AgentEvent.followWaiter;
   person.stateChanged();
 }
Esempio n. 12
0
  public void CallScenarioJ(CityPanel c) {
    //	Fully employed workplaces [enough people to fill all the workplace roles].
    //	Fully populated city [enough people to be wandering around doing interesting things]. At
    // least 50 people.
    //	All restaurants integrated.
    //	At least 2 instances of other workspaces (your decision as to how many more you want).
    //	People make decisions to eat at home.
    //	People make decisions to eat at particular restaurants.
    //	Enough vehicle traffic to show stopping/starting at intersections.
    //	Vehicles stop for pedestrians with right of way.

    workShift();
    setDanielRestClosed(c);
    fillWork(c);

    PersonAgent p2 = new PersonAgent("No Job 1", "None", "Wealthy");
    PersonAgent p3 = new PersonAgent("No Job 2", "None", "Poor");
    PersonAgent p4 = new PersonAgent("No Job 3", "None", "Average");
    PersonAgent p5 = new PersonAgent("Robber", "Crook", "Average");
    PersonAgent p6 = new PersonAgent("Chris", "None", "Wealthy");
    PersonAgent p7 = new PersonAgent("No Job 6", "None", "Poor");

    p5.setHungry();
    p4.setHungry();

    c.addPerson(p2);
    c.addPerson(p3);
    c.addPerson(p4);
    c.addPerson(p5);
    c.addPerson(p6);
    c.addPerson(p7);

    PersonAgent p998 = new PersonAgent("No Job 1", "None", "Wealthy");
    PersonAgent p999 = new PersonAgent("No Job 2", "None", "Poor");
    PersonAgent p99 = new PersonAgent("No Job 3", "None", "Average");
    PersonAgent p995 = new PersonAgent("Robber", "Crook", "Average");
    PersonAgent p996 = new PersonAgent("Chris", "None", "Wealthy");
    PersonAgent p997 = new PersonAgent("No Job 6", "None", "Poor");
    p995.GiveCar();
    p996.GiveCar();
    p999.GiveCar();
    p999.setHungry();
    p99.setHungry();

    c.addPerson(p998);
    c.addPerson(p999);
    c.addPerson(p99);
    c.addPerson(p995);
    c.addPerson(p996);
    c.addPerson(p997);

    PersonAgent p = new PersonAgent("Norman", "None", "Wealthy");
    p.GiveCar();
    p.addItem("Juice", 0, 2, 2);
    c.addPerson(p);

    PersonAgent p8 = new PersonAgent("Aleena", "None", "Average");
    c.addPerson(p8);

    PersonAgent p9 = new PersonAgent("Daniel", "None", "Wealthy");
    p9.GiveCar();
    p9.setHungry();
    c.addPerson(p9);
  }
 public void msgAnimationFinishedGoToSeat() {
   // from animation
   event = AgentEvent.seated;
   person.stateChanged();
 }
 public void msgWhatDoYouWant() {
   event = AgentEvent.askedToOrder;
   person.stateChanged();
 }
Esempio n. 15
0
  public void collisionTest(CityPanel c) {
    //		c.createBusSystem();
    //
    c.addPerson("Person1", "No AI", "Wealthy");
    PersonAgent p1 = c.people.lastElement();
    p1.setPosition(100, 165);
    p1.addItem("Car", 1);

    c.addPerson("Person4", "No AI", "Wealthy");
    PersonAgent p4 = c.people.lastElement();
    p4.setPosition(100, 137);
    p4.addItem("Car", 1);

    c.addPerson("Person2", "No AI", "Wealthy");
    PersonAgent p2 = c.people.lastElement();
    p2.setPosition(100, 530);
    p2.addItem("Car", 1);

    c.addPerson("Person3", "No AI", "Wealthy");
    PersonAgent p3 = c.people.lastElement();
    p3.setPosition(100, 90);

    c.addPerson("Person5", "No AI", "Wealthy");
    PersonAgent p5 = c.people.lastElement();
    p5.setPosition(300, 100);
    p5.addItem("Car", 1);

    c.addPerson("Person6", "No AI", "Wealthy");
    PersonAgent p6 = c.people.lastElement();
    p6.setPosition(100, 450);

    c.addPerson("Person7", "No AI", "Wealthy");
    PersonAgent p7 = c.people.lastElement();
    p7.setPosition(350, 520);
    p7.addItem("Car", 1);

    p1.msgGoToMarket("Car", 1);
    p4.msgGoToMarket("Car", 1);
    //
    p2.msgGoToHome("Sleep");
    p3.msgGoToMarket("Car", 1);
    //
    p6.msgGoToMarket("Car", 1);
  }
 public void msgPleaseReorder() {
   event = AgentEvent.reordering;
   person.stateChanged();
 }
 public void msgFeelFreeToWait(int spot) {
   waitingSpot = spot;
   person.stateChanged();
 }
 public void msgHereIsYourFood(String choice) {
   event = AgentEvent.startedEating;
   person.stateChanged();
 }
 public void msgHereIsChange(double change) {
   money += change;
   event = AgentEvent.leaving;
   person.stateChanged();
 }
 public void msgHereIsYourBill(Restaurant1Check c) {
   check = c;
   person.stateChanged();
 }
Esempio n. 21
0
 public void deactivate() {
   setRoleInactive = false;
   p.setRoleInactive(this);
   p.setGuiVisible();
   p.stateChanged();
 }
 public void msgAtDestination() {
   atDestination.release();
   person.stateChanged();
 }