protected override BankWindow createOperations(int number, OperationManager manager)
 {
     OperationFactory factory = new OperationFactory();
     BankWindow bankWindow = new BankWindow(number, manager);
     Random r = new Random();
     List<int> operations = new List<int>();
     int count = r.Next(1, NUMBER_OF_OPERATION + 1);
     while (true)
     {
         bool flag = true;
         int numberOperation = r.Next(1, NUMBER_OF_OPERATION + 1);
         for (int k = 0; k < operations.Count; k++)
         {
             if (numberOperation == operations[k])
                 flag = false;
         }
         if (flag)
         {
             bankWindow.addOperation(factory.createOperation(numberOperation));
             operations.Add(numberOperation);
             count--;
         }
         if (count == 0) break;
     }
     return bankWindow;
 }
 protected override BankWindow createOperations(int number, OperationManager manager)
 {
     OperationFactory factory = new OperationFactory();
     BankWindow bankWindow = new BankWindow(number, manager, new BankWindowFreeState());
     bankWindow.addOperation(factory.createOperation(Transfer.TRANSFER));
     bankWindow.addOperation(factory.createOperation(Payment.PAYMENT));
     return bankWindow;
 }
 protected override BankWindow createOperations(int number, OperationManager manager)
 {
     OperationFactory factory = new OperationFactory();
     BankWindow bankWindow = new BankWindow(number, manager);
     bankWindow.addOperation(factory.createOperation(Credit.CREDIT));
     bankWindow.addOperation(factory.createOperation(Deposit.DEPOSIT));
     return bankWindow;
 }
 protected override BankWindow createOperations(int number, OperationManager manager)
 {
     OperationFactory factory = new OperationFactory();
     BankWindow bankWindow = new BankWindow(number, manager, new BankWindowFreeState());
     bankWindow.addOperation(factory.createOperation(Deposit.DEPOSIT));
     bankWindow.addOperation(factory.createOperation(Card.CARD));
     bankWindow.addOperation(factory.createOperation(Transfer.TRANSFER));
     return bankWindow;
 }
 public OperationManager(OperationManager man)
 {
     this.operations = new List<IOperation>();
     for (int i = 0; i < man.operations.Count; i++)
     {
         switch (man.operations[i].getNumberOperation())
         {
             case Credit.CREDIT: this.operations.Add(new Credit()); break;
             case Deposit.DEPOSIT: this.operations.Add(new Deposit()); break;
             case Card.CARD: this.operations.Add(new Card()); break;
             case Transfer.TRANSFER: this.operations.Add(new Transfer()); break;
             case Payment.PAYMENT: this.operations.Add(new Payment()); break;
         }
     }
 }
Esempio n. 6
0
        public BankWindow(int number, OperationManager manager)
        {
            this.number = number;
            this.processOperation = new List<IOperation>();
            this.isFree = true;
            this.client = null;
            this.currentOperation = null;
            this.manager = manager;

            this.countCredits = 0;
            this.countDeposits = 0;
            this.countTransfers = 0;
            this.countCards = 0;
            this.countPayments = 0;
        }
Esempio n. 7
0
 public void build(BankWindowCreator creator, int number, OperationManager manager)
 {
     bankWindow = creator.createWindow(number, manager);
     List<IOperation> operations = bankWindow.getProcessOperation();
     for (int i = 0; i < operations.Count; i++)
     {
         switch (operations[i].getNumberOperation())
         {
             case Credit.CREDIT: operations[i].setNameOperation("Credits"); break;
             case Deposit.DEPOSIT: operations[i].setNameOperation("Deposits"); break;
             case Card.CARD: operations[i].setNameOperation("Cards"); break;
             case Transfer.TRANSFER: operations[i].setNameOperation("Transfers"); break;
             case Payment.PAYMENT: operations[i].setNameOperation("Payments"); break;
         }
     }
     bankWindow.setBuilder(new EngBuilder());
 }
Esempio n. 8
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;
 }
Esempio n. 9
0
 public Bank()
 {
     this.listBankWindows = new List<BankWindow>();
     this.clientQueue = new ClientQueue();
     this.periodTimer = 1000;
     this.numberOfNewClients = 0;
     this.timer = new Timer(periodTimer);
     this.timer.Elapsed += OnTimedEvent;
     this.countBankWindows = 0;
     this.nameClients = new List<string>();
     //this.timerActive = false;
     this.manager = new OperationManager();
     string line;
     System.IO.StreamReader file = new System.IO.StreamReader(@"nameClients.txt",System.Text.Encoding.Default);
     while ((line = file.ReadLine()) != null)
     {
         this.nameClients.Add(line);
     }
     file.Close();
 }
Esempio n. 10
0
        public Bank(Bank bank)
        {
            this.manager = new OperationManager(bank.manager);
            this.listBankWindows = new List<BankWindow>();
            for (int i = 0; i < bank.countBankWindows; i++)
            {
                BankWindow bw = new BankWindow(bank.listBankWindows[i]);
                bw.setManager(this.manager);
                this.listBankWindows.Add(bw);
            }

            this.clientQueue = new ClientQueue(bank.clientQueue);
            this.timer = new Timer(bank.periodTimer);
            this.periodTimer = bank.periodTimer;

            this.timer.Elapsed += OnTimedEvent;
            this.numberOfNewClients = bank.numberOfNewClients;
            this.countBankWindows = bank.countBankWindows;
            this.nameClients = bank.nameClients;
            //this.timerActive = bank.timerActive;
        }
Esempio n. 11
0
 public void construct(BankWindowCreator creator, int number, OperationManager manager)
 {
     builder.build(creator, number, manager);
 }
 protected abstract BankWindow createOperations(int number, OperationManager manager);
 public BankWindow createWindow(int number, OperationManager manager)
 {
     BankWindow bankWindow = null;
     bankWindow = createOperations(number, manager);
     return bankWindow;
 }
Esempio n. 14
0
 public void build(BankWindowCreator creator, int number, OperationManager manager)
 {
     bankWindow = creator.createWindow(number, manager);
     bankWindow.setBuilder(new RusBuilder());
 }
Esempio n. 15
0
 public void setManager(OperationManager manager)
 {
     this.manager = manager;
 }