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; }
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); }
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); }
protected void goHome() { // int homeNumber = (int)((int)(Math.random()*11)); destinationBuilding = cityData.buildings.get(this.home.buildingNumber); boolean busser = false; boolean driver = false; if (once) { if (bus == true) { busser = true; } if (car == true) { driver = true; } if (bus || car) { walk = true; bus = false; car = false; } } if (once) { if (busser) { bus = true; walk = false; } if (driver) { car = true; walk = false; } } once = false; personGui.DoGoToBuilding( this.home.buildingNumber); // 11 need to be replaced by the person's data of home number try { atBuilding.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } currentBuilding = destinationBuilding; personGui.DoGoIntoBuilding(); if (home instanceof Home) { currentBuilding.EnterBuilding(this, ""); } if (home instanceof Apartment) { Apartment a = (Apartment) home; a.EnterBuilding(this, ""); personGui.DoGoToRoom(roomNumber); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } a.rooms.get(roomNumber).EnterBuilding(this, ""); } bigState = BigState.atHome; homeState = HomeState.onCouch; // hungerLevel = 10000000; }