/**
  * Processes a withdrawal. If there is enough money, withdraws that amount. If not, just quits
  * with an error message.
  *
  * @param b - BankClient
  */
 private void processWithdrawal(BankClient b) {
   for (Account a : Accounts) {
     if (a.client == b) {
       if (transactionAmount > a.amount) {
         AlertLog.getInstance()
             .logMessage(
                 AlertTag.BANK_TELLER,
                 name,
                 "Error: Attempted to withdraw more money than is available in account.");
         b.msgTransactionCompleted(0);
       } else if (transactionAmount <= a.amount) {
         a.amount = a.amount - transactionAmount;
         AlertLog.getInstance()
             .logMessage(
                 AlertTag.BANK_TELLER,
                 name,
                 "$" + transactionAmount + " has been withdrawn from the account.");
         b.msgTransactionCompleted(transactionAmount);
       }
       state = requestState.none;
       announcer.msgTransactionComplete(LineNum, this, b);
       myClient = null;
     }
   }
 }
 /**
  * Greeting the client
  *
  * @param b - BankClient
  */
 private void receiveClient(BankClient b) {
   AlertLog.getInstance().logMessage(AlertTag.BANK_TELLER, name, "Recieving new client");
   AlertLog.getInstance()
       .logMessage(AlertTag.BANK_TELLER, name, "Hello " + b + ", how may I help you.");
   b.msgMayIHelpYou();
   state = requestState.pending;
 }
 private void WakeUp() {
   print(" is going to work");
   AlertLog.getInstance().logMessage(AlertTag.PERSON, this.name, "Going to work");
   goToWork = true;
   tiredLevel = 0;
   homeState = HomeState.idle;
   hungerLevel += 5;
 }
 /**
  * Opens new account
  *
  * @param b - BankClient
  */
 private void openAccount(BankClient b) {
   Account a = new Account(b, 0);
   AlertLog.getInstance()
       .logMessage(AlertTag.BANK_TELLER, name, "New bank account has been opened for " + b);
   Database.INSTANCE.addToDatabase(a);
   b.msgAccountOpened(a);
   state = requestState.notBeingHelped;
 }
 /**
  * Processes a deposit. If the account exists, deposits the asked amount into the account.
  *
  * @param b - BankClient
  */
 private void processDeposit(BankClient b) {
   AlertLog.getInstance().logMessage(AlertTag.BANK_TELLER, name, "Ok, hold on.");
   for (Account a : Accounts) {
     if (a.client == b) {
       a.amount = a.amount + transactionAmount;
       AlertLog.getInstance()
           .logMessage(
               AlertTag.BANK_TELLER,
               name,
               "$" + transactionAmount + " has been deposited into the account.");
       b.msgTransactionCompleted(transactionAmount - (2 * transactionAmount));
       state = requestState.none;
       announcer.msgTransactionComplete(LineNum, this, b);
       myClient = null;
     }
   }
 }
 @Override
 protected void takeOrderToCook(MyCustomer customer) {
   // do go to stuff;
   host.msgWaiterBusy(this);
   AlertLog.getInstance()
       .logMessage(
           AlertTag.WAITER,
           getName(),
           "Adding " + customer.customer + "'s order to shared data for cook");
   customer.state = CustomerState.AtCook;
   Directory.sharedInstance()
       .getRestaurants()
       .get(0)
       .getMonitor()
       .insert(new Order(this, customer.choice, customer.table, customer.seatNum));
   ;
 }
 public Vector<Item> getStockItems() {
   inventory = ((Restaurant4CookRole) cook).getInventory();
   AlertLog.getInstance().logInfo(AlertTag.GUI, "Rest 5", inventory.toString());
   return inventory;
 }
 protected void ReactToFire() {
   System.out.println(name + ": Stop, Drop, and Roll ");
   AlertLog.getInstance().logMessage(AlertTag.PERSON, this.name, "Stop, Drop, and Roll");
   emergencyState = EmergencyState.none;
 }
Beispiel #9
0
 @Override
 public void print(String msg) {
   this.getPerson().printViaRole("Landlord", msg);
   AlertLog.getInstance()
       .logMessage(AlertTag.HOUSE, "LandlordRole " + this.getPerson().getName(), msg);
 }