public void execute(BankWindow bankWindow)
 {
     if (bankWindow.getCurrentOperation().getTimeOperation() != 0)
     {
         bankWindow.getCurrentOperation().doOperation();
     }
     else
     {
         switch (bankWindow.getClient().getNumberOperation())
         {
             case Credit.CREDIT: bankWindow.setCountCredits(bankWindow.getCountCredits() + 1); break;
             case Deposit.DEPOSIT: bankWindow.setCountDeposits(bankWindow.getCountDeposits() + 1); break;
             case Card.CARD: bankWindow.setCountCards(bankWindow.getCountCards() + 1); break;
             case Transfer.TRANSFER: bankWindow.setCountTransfers(bankWindow.getCountTransfers() + 1); break;
             case Payment.PAYMENT: bankWindow.setCountPayments(bankWindow.getCountPayments() + 1); break;
         }
         bankWindow.setCountAllOperations(bankWindow.getCountAllOperations() + 1);
         ObjectPoolClient pool = ObjectPoolClient.getInstance();
         pool.releaseClient(bankWindow.getClient());
         bankWindow.setClient(null);
         bankWindow.getManager().pushOperation(bankWindow.getCurrentOperation());
         bankWindow.setCurrentOperation(null);
         if(bankWindow.isBreak == true)
         {
             bankWindow.setState(new BankWindowBreakState());
             bankWindow.isBreak = false;
         }
         else
             bankWindow.setState(new BankWindowFreeState());
     }
 }
Ejemplo n.º 2
0
 public BankWindow(BankWindow bw)
 {
     this.number = bw.number;
     this.processOperation = new List<IOperation>();
     List<IOperation> oper = bw.getProcessOperation();
     for (int k = 0; k < oper.Count; k++)
     {
         this.addOperation(oper[k]);
     }
     if(bw.getClient() != null)
         this.client = new Client(bw.client);
     if (bw.getCurrentOperation() != null)
     {
         switch (bw.currentOperation.getNumberOperation())
         {
             case Credit.CREDIT: this.currentOperation = new Credit(); break;
             case Deposit.DEPOSIT: this.currentOperation = new Deposit(); break;
             case Card.CARD: this.currentOperation = new Card(); break;
             case Transfer.TRANSFER: this.currentOperation = new Transfer(); break;
             case Payment.PAYMENT: this.currentOperation = new Payment(); break;
         }
         this.currentOperation.setTimeOperation(bw.currentOperation.getTimeOperation());
     }
     this.manager = new OperationManager(bw.manager);
     if(bw.state.GetType() == typeof(BankWindowBusyState))
     {
         this.state = new BankWindowBusyState();
     }
     else
         if (bw.state.GetType() == typeof(BankWindowFreeState))
         {
             this.state = new BankWindowFreeState();
         }
         else
             if (bw.state.GetType() == typeof(BankWindowBreakState))
             {
                 this.state = new BankWindowBreakState();
             }
     this.isBreak = bw.isBreak;
     this.countAllOperations = bw.countAllOperations;
     this.countCredits = bw.countCredits;
     this.countDeposits = bw.countDeposits;
     this.countCards = bw.countCards;
     this.countTransfers = bw.countTransfers;
     this.countPayments = bw.countPayments;
 }