Exemplo n.º 1
0
  protected void goToRestaurant() {
    int restNumber;
    if (!goToWork || jobBuilding == null) {

      while (true) {
        restNumber = (int) (Math.random() * 7);
        if (restNumber >= 6) {
          bigState = BigState.goHome;
          return;
        } else if ((cityData.restaurants.get(restNumber)).isOpen()) break;
      }
      destinationBuilding = cityData.restaurants.get(restNumber);
    } else {
      destinationBuilding = jobBuilding;
    }

    if (destinationBuilding != currentBuilding) {
      System.out.println("Going to restaurant as " + desiredRole);
      GoToDestination();

      personGui.DoGoToBuilding(destinationBuilding.buildingNumber);
      try {
        atBuilding.acquire();
      } catch (InterruptedException e) {
        //   Auto-generated catch block
        e.printStackTrace();
      }
      currentBuilding = destinationBuilding;
    }

    Building restaurant = destinationBuilding;

    if (goToWork && !desiredRole.equals("Customer")) {
      if (desiredRole.equals("Host") && !restaurant.hasHost()) {
        personGui.DoGoIntoBuilding();
        currentBuilding.EnterBuilding(this, desiredRole);
        return;
      } else if (restaurant.openToEmployee()) {
        if (desiredRole.equals("Waiter") || desiredRole.equals("Cook")) {
          personGui.DoGoIntoBuilding();
          currentBuilding.EnterBuilding(this, desiredRole);
          return;
        } else if (desiredRole.equals("Cashier") && !restaurant.hasCashier()) {
          personGui.DoGoIntoBuilding();
          currentBuilding.EnterBuilding(this, desiredRole);
          return;
        }
      }
    }

    // This is only reached if the person is unemployed
    if (desiredRole.equals("Customer") && restaurant.isOpen()) {
      personGui.DoGoIntoBuilding();
      currentBuilding.EnterBuilding(this, desiredRole);
      bigState = BigState.waiting;
      return;
    }
    bigState = BigState.goHome;
    homeState = HomeState.onCouch;
  }
Exemplo n.º 2
0
  protected void goToMarket() {
    int marketNumber = 0;
    destinationBuilding = cityData.markets.get(0);

    GoToDestination();

    personGui.DoGoToBuilding(19);
    currentBuilding = cityData.buildings.get(19);
    atBuilding.drainPermits();
    try {
      atBuilding.acquire();
    } catch (InterruptedException e) {
      //   Auto-generated catch block
      e.printStackTrace();
    }
    personGui.DoGoIntoBuilding();
    currentBuilding.EnterBuilding(this, desiredRole);
  }
Exemplo n.º 3
0
  protected void goToBank() {
    int bankNumber = 0;
    destinationBuilding = cityData.banks.get(bankNumber);
    GoToDestination();

    personGui.DoGoToBuilding(18);
    currentBuilding = cityData.buildings.get(18);
    atBuilding.drainPermits();

    try {
      atBuilding.acquire();
      if (currentBuilding.type == BuildingType.bank) print("made it past at Building acquire");
    } catch (InterruptedException e) {
      //   Auto-generated catch block
      e.printStackTrace();
    }
    personGui.DoGoIntoBuilding();
    print("entering the building and desired role is " + desiredRole);
    currentBuilding.EnterBuilding(this, desiredRole);
  }