static void Main(string[] args) { Bank first = new Bank(); Account ein = new Account(0, 0000,100); Account one = new Account(1, 1111, 100); first.accounts.Add(ein); first.accounts.Add(one); first.CreateAccount(2222, 20000); //this tests that creataccount adds the account properly to accounts for (int x = 0; x < first.accounts.Count; x++) Console.WriteLine(first.accounts[x].accountNum); Console.ReadLine(); //tests basic functions one.Deposit(1000); one.Deposit(1000); one.Withdraw(300); one.Deposit(1000); one.Withdraw(900); one.Deposit(10000); one.Withdraw(9998000); one.Deposit(1000); one.Withdraw(300); Console.ReadLine(); // ATM test Atm zero = new Atm(); zero.ExecuteInput(first); zero.ExecuteInput(first); zero.ExecuteInput(first); Console.ReadLine(); }
public bool SelectAccount(Bank bank) { Console.WriteLine("Enter Account Number: "); accountNum = (Convert.ToInt32(Console.ReadLine())); Console.WriteLine("Enter Pin Number: "); int pin = (Convert.ToInt32(Console.ReadLine())); if (bank.Verify(accountNum, pin)) { return true; } else return false; }
public void ExecuteInput(Bank bank) { if (this.SelectAccount(bank)) { string input; Console.WriteLine("Enter your transaction: (Use deposit or withdraw)"); input = Console.ReadLine(); if (input == "deposit") { Console.WriteLine("Enter Deposit Amount: "); float amount = (Convert.ToSingle(Console.ReadLine())); (bank.accounts[accountNum]).Deposit(amount); } else if (input == "withdraw") { Console.WriteLine("Enter Deposit Amount: "); float amount = (Convert.ToSingle(Console.ReadLine())); (bank.accounts[accountNum]).Withdraw(amount); } /// else if (input == "transfer") /// { /// Console.WriteLine("Enter Transfer Amount: "); /// float amount = (Convert.ToSingle(Console.ReadLine())); /// Console.WriteLine("Enter Account Number To Transfer To: "); /// int targetAccount = (Convert.ToInt32(Console.ReadLine())); /// bank.Transfer(amount, a, targetAccount); /// } /// else Console.WriteLine("Invalid Command. Please enter deposit or withdraw"); } else if ((this.SelectAccount(bank)) == false) { Console.WriteLine("Access Denied. Re enter pin."); } }