Exemplo n.º 1
0
        private void setState(EBorrowState state)
        {
            Console.WriteLine("Setting state: " + state);

            this._state = state;

            switch (state)
            {
                case EBorrowState.INITIALIZED:
                    _reader.Listener = this;
                    _scanner.Listener = this;
                    _currentControl = new SwipeCardControl(this);
                    _reader.Enabled = true;
                    _scanner.Enabled = false;
                    break;

                case EBorrowState.BORROWING_RESTRICTED:
                    _currentControl = new RestrictedControl(this);
                    _reader.Enabled = false;
                    _scanner.Enabled = false;
                    _currentControl.DisplayErrorMessage(String.Format("Member {0} cannot borrow at this time.", _borrower.ID));
                    break;

                case EBorrowState.SCANNING_BOOKS:
                    _currentControl = new ScanBookControl(this);
                    _reader.Enabled = false;
                    _scanner.Enabled = true;
                    _bookList = new List<IBook>();
                    _loanList = new List<ILoan>();
                    break;

                case EBorrowState.CONFIRMING_LOANS:
                    _currentControl = new ConfirmLoanControl(this);
                    _reader.Enabled = false;
                    _scanner.Enabled = false;
                    //display pending loans
                    foreach (ILoan loan in _loanList)
                    {
                        _currentControl.DisplayConfirmingLoan(loan.ToString());
                    }
                    break;

                case EBorrowState.COMPLETED:
                    _reader.Enabled = false;
                    _scanner.Enabled = false;
                    StringBuilder bld = new StringBuilder();
                    foreach (ILoan loan in _loanList)
                    {
                        _loanDAO.CommitLoan(loan);
                        bld.Append(loan.ToString() + "\n\n");
                    }
                    _printer.print(bld.ToString());
                    close();
                    return;

                case EBorrowState.CANCELLED:
                    _reader.Enabled = false;
                    _scanner.Enabled = false;
                    close();
                    return;

                default:
                    throw new ApplicationException("Unknown state");
            }
            _display.Display = _currentControl;
        }
Exemplo n.º 2
0
 public override void DisplayConfirmingLoan(string loanDetails)
 {
     _currentControl.DisplayConfirmingLoan(loanDetails);
 }