public BankWindow(int number, BankWindowState state) { this.number = number; this.processOperation = new List<IOperation>(); this.client = null; this.currentOperation = null; this.state = state; this.countCredits = 0; this.countDeposits = 0; this.countTransfers = 0; this.countCards = 0; this.countPayments = 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; }
public void setState(BankWindowState state) { this.state = state; }
//задать клиента public void setClient(Client client) { OperationFactory factory = new OperationFactory(); this.client = client; if (this.client != null) { switch (client.getNumberOperation()) { case Credit.CREDIT: currentOperation = factory.createOperation(Credit.CREDIT); break; case Deposit.DEPOSIT: currentOperation = factory.createOperation(Deposit.DEPOSIT); break; case Card.CARD: currentOperation = factory.createOperation(Card.CARD); break; case Transfer.TRANSFER: currentOperation = factory.createOperation(Transfer.TRANSFER); break; case Payment.PAYMENT: currentOperation = factory.createOperation(Payment.PAYMENT); break; } Random r = new Random(); this.currentOperation.setTimeOperation(r.Next(this.currentOperation.getMinTimeOperation(), this.currentOperation.getMinTimeOperation())); this.state = new BankWindowBusyState(); } notify(); }