Exemplo n.º 1
0
        public static void ProcessAccount(Account acc)
        {
            Console.WriteLine("balance = {0}", acc.Balance);
            string       cmd;
            InputWrapper iw = new InputWrapper();

            Console.WriteLine("Enter command, quit to exit");
            cmd = iw.getString(">> ");
            while (!cmd.Equals("quit"))
            {
                if (cmd.Equals("deposit"))
                {
                    decimal amount = iw.getDecimal("amount: ");
                    acc.Deposit(amount);
                    Console.WriteLine("balance = {0}", acc.Balance);
                }
                else if (cmd.Equals("withdraw"))
                {
                    decimal amount = iw.getDecimal("amount: ");
                    acc.Withdraw(amount);
                    Console.WriteLine("balance = {0}", acc.Balance);
                }
                else if (cmd.Equals("owner"))
                {
                    string owner = iw.getString("new owner name: ");
                    acc.Owner = owner;
                    show(acc);
                }
                else if (cmd.Equals("show"))
                {
                    show(acc);
                }
                else
                {
                    accountHelp();
                }
                cmd = iw.getString(">> ");
            }
        }
        public static void DisplayTest()
        {
            Bank         bank = new Bank();
            InputWrapper iw   = new InputWrapper();
            string       cmd;

            Console.WriteLine("Enter command, quit to exit");
            help();
            cmd = iw.getString("> ");
            while (!cmd.Equals("quit"))
            {
                if (cmd.Equals("open"))
                {
                    decimal bal   = iw.getDecimal("starting balance: ");
                    string  owner = iw.getString("owner: ");
                    int     id    = bank.AddAccount(bal, owner);
                    Console.WriteLine("Account opened, id = {0}", id);
                }
                else if (cmd.Equals("close"))
                {
                    int id = iw.getInt("account id: ");
                    bank.DeleteAccount(id);
                }
                else if (cmd.Equals("show"))
                {
                    ShowArray(bank.GetAccounts());
                }
                else if (cmd.Equals("account"))
                {
                    int     id  = iw.getInt("account id: ");
                    Account acc = bank.FindAccount(id);
                    Atm.ProcessAccount(acc);
                }
                else
                {
                    help();
                }
                cmd = iw.getString("> ");
            }
        }