Esempio n. 1
0
    public static void Main()
    {
        Bank         bank = new Bank();
        InputWrapper iw   = new InputWrapper();
        string       cmd;

        Console.WriteLine("Enter command, quit to exit");
        cmd = iw.getString("> ");
        while (!cmd.Equals("quit"))
        {
            if (cmd.Equals("open"))
            {
                AccountType type;
                string      stype = iw.getString("account type: ");
                switch (stype)
                {
                case "checking":
                    type = AccountType.Checking;
                    break;

                case "savings":
                    type = AccountType.Savings;
                    break;

                default:
                    type = AccountType.Invalid;
                    break;
                }
                if (type == AccountType.Invalid)
                {
                    Console.WriteLine("Valid account types are checking/savings");
                    continue;
                }
                decimal bal   = iw.getDecimal("starting balance: ");
                string  owner = iw.getString("owner: ");
                int     id    = bank.AddAccount(type, 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("> ");
        }
    }
Esempio n. 2
0
    public static void Main()
    {
        Bank         bank = new Bank();
        InputWrapper iw   = new InputWrapper();
        string       cmd;

        Console.WriteLine("Enter command, quit to exit");
        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("> ");
        }
    }