Esempio n. 1
0
        static void Main(string[] args)
        {
            //instantiate below
            Client          client2   = new Client(clientName, clientPhoneNumber, clientAddress, clientRepresentative);
            CheckingAccount checking1 = new CheckingAccount();
            SavingsAccount  savings1  = new SavingsAccount();

            do
            {
                Console.WriteLine("Select the number of your choice: ");
                Console.WriteLine("1: View Client Information");
                Console.WriteLine("2: View Account Balances");
                Console.WriteLine("3: Deposit Funds");
                Console.WriteLine("4: Withdraw Funds");
                Console.WriteLine("5: Quit");
                var userChoice = Console.ReadLine();
                Console.WriteLine();
                if (!Int32.TryParse(userChoice, out num))
                {
                    continue;
                }

                if (userChoice == "5")
                {
                    Environment.Exit(0);
                }

                Console.WriteLine("Choice = " + userChoice);

                if (userChoice == "1")
                {
                    client2.ClientWork();
                    Console.WriteLine();
                }
                else if (userChoice == "2")

                {
                    Console.WriteLine("1 - Checking Balance");
                    Console.WriteLine("2 - Savings Balance");
                    int accountSelection = int.Parse(Console.ReadLine());
                    if (accountSelection == 1)
                    {
                        checking1.CheckBalance();
                        Console.WriteLine();
                    }
                    else if (accountSelection == 2)
                    {
                        savings1.CheckBalance();
                        Console.WriteLine();
                    }
                }
                else if (userChoice == "3")
                {
                    Console.WriteLine("1 - Checking Deposit");
                    Console.WriteLine("2 - Savings Deposit");
                    int withdrawalSelection = int.Parse(Console.ReadLine());
                    if (withdrawalSelection == 1)
                    {
                        checking1.AccountDeposit();
                        Console.WriteLine();
                    }
                    else if (withdrawalSelection == 2)
                    {
                        savings1.AccountDeposit();
                        Console.WriteLine();
                    }
                }
                else if (userChoice == "4")
                {
                    Console.WriteLine("1 - Checking Withdrawal");
                    Console.WriteLine("2 - Savings Withdrawal");
                    int withdrawalSelection = int.Parse(Console.ReadLine());
                    if (withdrawalSelection == 1)
                    {
                        checking1.AccountWithdrawal();
                        Console.WriteLine();
                    }
                    else if (withdrawalSelection == 2)
                    {
                        savings1.AccountWithdrawal();
                        Console.WriteLine();
                    }
                }
            } while (true);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
start:                                          //redirect from password being incorrect
            Accounts account1 = new Accounts(); //instantiated each child-class
            CheckingAccount check1   = new CheckingAccount();
            ReserveAccount  reserve1 = new ReserveAccount();
            SavingsAccount  savings1 = new SavingsAccount();

            Console.WriteLine("Thank you for visiting The First National Bank of Andy! \nDo you have an account with us?");
            string existingCustomer = Console.ReadLine();  //I have a save option to bring back previous account info

            if (existingCustomer.ToUpper() == "Y" || existingCustomer.ToUpper() == "YES")
            {
                Console.Clear();
                StreamReader retrieveSave  = new StreamReader("..\\..\\BankLogin.txt"); //another input of "enter" to continue.
                int          numberOfLines = 12;
                string[]     lineArray     = new string[numberOfLines];                 //taking BankLogin.txt and turning lines into an array to read them
                for (int i = 1; i < numberOfLines; i++)
                {
                    lineArray[i] = retrieveSave.ReadLine();
                }
                account1.FirstName            = (lineArray[1]); //these are using the properties to change the variable amounts and string name
                account1.LastName             = (lineArray[2]);
                account1.UserName             = (lineArray[3]);
                account1.PassWord             = (lineArray[4]);
                account1.ClientNumber         = int.Parse(lineArray[5]); //all lines read as a string, so Parse will get them into an int or double
                check1.CheckBalance           = double.Parse(lineArray[6]);
                check1.CheckingAccountNumber  = int.Parse(lineArray[7]);
                reserve1.ReserveBalance       = double.Parse(lineArray[8]);
                reserve1.ReserveAccountNumber = int.Parse(lineArray[9]);
                savings1.SavingsBalance       = double.Parse(lineArray[10]);
                savings1.SavingsAccountNumber = int.Parse(lineArray[11]);
                retrieveSave.Close();

                check1.FirstName      = account1.FirstName; //this is getting all the info from the base class accounts
                reserve1.FirstName    = account1.FirstName; //into the sub-class accounts
                savings1.FirstName    = account1.FirstName;
                check1.LastName       = account1.LastName;
                reserve1.LastName     = account1.LastName;
                savings1.LastName     = account1.LastName;
                check1.ClientNumber   = account1.ClientNumber;
                reserve1.ClientNumber = account1.ClientNumber;
                savings1.ClientNumber = account1.ClientNumber;

                Console.WriteLine(account1.UserName + " please enter your password."); //password was set with streamwriter previously
                string loginAttempt = Console.ReadLine();
                if (loginAttempt.ToUpper() == account1.PassWord.ToUpper())             //uppercase or lowercase won't matter in password
                {
                    Console.WriteLine("Welcome back " + account1.FirstName + "!");
                    goto mainmenu;  //this sends it to the main menu
                }
                else
                {
                    Console.WriteLine("Your password attempt is incorrect. You will be redirected to the start.");
                    goto start;
                }
            }

            else //this else is for those who don't have a login and password
            {    //creating a new profile
                Console.Clear();
                Console.WriteLine("Let\'s set you up a new account!\nWhat is your first name?");
                account1.FirstName = Console.ReadLine();
                check1.FirstName   = account1.FirstName;
                reserve1.FirstName = account1.FirstName;
                savings1.FirstName = account1.FirstName;
                Console.WriteLine("Thank you, " + account1.FirstName + ". What is your last name?");
                account1.LastName = Console.ReadLine();
                check1.LastName   = account1.LastName;
                reserve1.LastName = account1.LastName;
                savings1.LastName = account1.LastName;
                Console.WriteLine("Please enter a username you would like to use.");
                account1.UserName = Console.ReadLine();
                Console.WriteLine("Please enter a password. Please remember this password to login in the future.");
                account1.PassWord = Console.ReadLine();
                account1.GenerateClientNumber();
                check1.ClientNumber   = account1.ClientNumber;
                reserve1.ClientNumber = account1.ClientNumber;
                savings1.ClientNumber = account1.ClientNumber;
                Console.WriteLine(account1.FirstName + ", your client ID number is " + account1.ClientNumber);
                Console.WriteLine("Here at FNB of Andy, we require all customers to open 3 accounts\nA Checking Account, a Reserve Account, and a Savings Account.");
                System.Threading.Thread.Sleep(5500); //this gives some time for the above lines to be read. Next method to be called clears all lines
                check1.GenerateCheckingAccount();    //these next 6 lines call to the inherited methods for initial deposits and account numbers
                check1.Deposit();
                reserve1.GenerateReserveAccount();
                reserve1.Deposit();
                savings1.GenerateSavingsAccount();
                savings1.Deposit();
            }

            //main menu
mainmenu:
            Console.WriteLine("\n" + account1.FirstName + ", please select the account you wish to view or exit.");
            Console.WriteLine("You may make a deposit, withdrawal, or view account balance in\nthe account you select.");
            Console.WriteLine("Select 1 to view Checking Account.");
            Console.WriteLine("Select 2 to view Reserve Account.");
            Console.WriteLine("Select 3 to view Savings Account.");
            Console.WriteLine("Select 4 to Exit and receive your receipt.");
            int selection = int.Parse(Console.ReadLine());

            if (selection == 1)  //if/else if for the 4 options. Selection 1 brings us to checking options
            {
                Console.Clear(); //console.clear is used to make console more readable
                Console.WriteLine("Checking Account Options:");
                Console.WriteLine("Select 1 to make a deposit.");
                Console.WriteLine("Select 2 to make a withdrawal.");
                Console.WriteLine("Select 3 to check balance.");
                Console.WriteLine("Select 4 to return to the main menu.");
                int checkMenu = int.Parse(Console.ReadLine());

                if (checkMenu == 1)
                {
                    check1.Deposit();
                }
                else if (checkMenu == 2)
                {
                    check1.Withdraw();
                }
                else if (checkMenu == 3)
                {
                    Console.Clear();
                    Console.WriteLine(check1.FirstName + ", your current checking balance is $" + check1.CheckBalance + ".");
                }
                else
                {
                    Console.Clear();
                    goto mainmenu;  //takes us back to the main menu
                }
            }
            else if (selection == 2)    //selection 2 brings us to reserve account options
            {
                Console.Clear();
                Console.WriteLine("Reserve Account Options:");
                Console.WriteLine("Select 1 to make a deposit.");
                Console.WriteLine("Select 2 to make a withdrawal.");
                Console.WriteLine("Select 3 to check balance.");
                Console.WriteLine("Select 4 to return to the main menu.");
                int resMenu = int.Parse(Console.ReadLine());

                if (resMenu == 1)   //nested if/else if to call upon particular inherited method
                {
                    reserve1.Deposit();
                }
                else if (resMenu == 2)
                {
                    reserve1.Withdraw();
                }
                else if (resMenu == 3)
                {
                    Console.Clear();
                    Console.WriteLine(check1.FirstName + ", your current reserve balance is $" + reserve1.ReserveBalance + ".");
                }
                else
                {
                    Console.Clear();
                    goto mainmenu;
                }
            }
            else if (selection == 3)    //selection 3 brings us to savings account options
            {
                Console.Clear();
                Console.WriteLine("Savings Account Options:");
                Console.WriteLine("Select 1 to make a deposit.");
                Console.WriteLine("Select 2 to make a withdrawal.");
                Console.WriteLine("Select 3 to check balance.");
                Console.WriteLine("Select 4 to return to the main menu.");
                int savMenu = int.Parse(Console.ReadLine());

                if (savMenu == 1)
                {
                    savings1.Deposit();
                }
                else if (savMenu == 2)
                {
                    savings1.Withdraw();
                }
                else if (savMenu == 3)
                {
                    Console.Clear();
                    Console.WriteLine(check1.FirstName + ", your current savings balance is $" + savings1.SavingsBalance + ".");
                }
                else
                {
                    Console.Clear();
                    goto mainmenu;
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Thank you for banking with FNB of Andy. Have a great day!");
                StreamWriter bankLogin = new StreamWriter("..\\..\\BankLogin.txt"); //this will write or overwrite the txt
                using (bankLogin)                                                   //that will be used to read when console is
                {                                                                   //reopened and saved bank info is selected.
                    bankLogin.WriteLine(account1.FirstName);
                    bankLogin.WriteLine(account1.LastName);
                    bankLogin.WriteLine(account1.UserName);
                    bankLogin.WriteLine(account1.PassWord);
                    bankLogin.WriteLine(account1.ClientNumber);
                    bankLogin.WriteLine(check1.CheckBalance);
                    bankLogin.WriteLine(check1.CheckingAccountNumber);
                    bankLogin.WriteLine(reserve1.ReserveBalance);
                    bankLogin.WriteLine(reserve1.ReserveAccountNumber);
                    bankLogin.WriteLine(savings1.SavingsBalance);
                    bankLogin.WriteLine(savings1.SavingsAccountNumber);
                }

                Environment.Exit(0);
            }
            goto mainmenu;  //if user did not exit, this will send back to main menu
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            int userInput;

            ClientInformation userclientInformation = new ClientInformation();
            Accounts          userAccounts          = new Accounts();
            CheckingAccount   userCheckingAccount   = new CheckingAccount();
            SavingsAccount    userSavingsAccount    = new SavingsAccount();



            string balance  = " ";
            string deposit  = " ";
            string withdraw = " ";


            do
            {
                Console.WriteLine("");
                Console.WriteLine("Welcome to the Corgi Banking Application.");
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("Type 1 to view client information.");
                Console.WriteLine("Type 2 to view account balance.");
                Console.WriteLine("Type 3 to deposit funds.");
                Console.WriteLine("Type 4 to withdraw funds.");
                Console.WriteLine("Type 5 to exit program");
                Console.WriteLine("");

                userInput = int.Parse(Console.ReadLine());


                switch (userInput)
                {
                case 1:
                    //// declare client information
                    Console.WriteLine("Client Information:");
                    Console.WriteLine(userclientInformation.ClientName);
                    Console.WriteLine(userclientInformation.ClientAddress);
                    Console.WriteLine(userclientInformation.ClientEmailAddress);
                    Console.WriteLine("");
                    break;

                case 2:
                    //// View Balances
                    Console.WriteLine("Type \"a\" to review checking account balance.");
                    Console.WriteLine("");
                    Console.WriteLine("Type \"b\" to review savings account balance.");
                    Console.WriteLine("");
                    balance = Console.ReadLine();
                    balance = balance.ToLower();

                    if (balance == "a")
                    {
                        userCheckingAccount.CheckingAccountNumber();
                        userCheckingAccount.CheckingBalance();
                        Console.WriteLine("");
                    }
                    if (balance == "b")
                    {
                        userSavingsAccount.SavingsAccountNumber();
                        userSavingsAccount.SavingsBalance();

                        Console.Write("");
                    }
                    break;

                case 3:
                    //// to deposit funds and get balances
                    Console.WriteLine("Type \"c\" to deposit funds into checking account.");
                    Console.WriteLine("");
                    Console.WriteLine("Type \"d\" to deposit funds into savings account.");
                    deposit = Console.ReadLine();
                    deposit = deposit.ToLower();

                    if (deposit == "c")
                    {
                        userCheckingAccount.BalanceAfterDeposit();
                    }

                    if (deposit == "d")
                    {
                        userSavingsAccount.BalanceAfterDeposit();
                    }

                    break;

                case 4:
                    //// to withdraw funds and get balances
                    Console.WriteLine("Type \"e\" to withdraw funds from checking account.");
                    Console.WriteLine("");
                    Console.WriteLine("Type \"f\" to withdraw funds from savings account.");
                    Console.WriteLine("");
                    withdraw = Console.ReadLine();
                    withdraw = withdraw.ToLower();

                    if (withdraw == "e")
                    {
                        userCheckingAccount.BalanceAfterWithdraw();
                    }

                    if (withdraw == "f")
                    {
                        userSavingsAccount.BalanceAfterWithdraw();
                    }
                    break;

                case 5:
                    // to exit
                    break;
                }
            } while (userInput != 5);
            Console.Write("");
            Console.WriteLine("Thank you for using Corgi Banking. Have a nice day.");
            Console.WriteLine("");
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //Must instantiate one client object
            //Must instantiate one checking account object
            //Must instantiate one savings account object
            //All menu options listed above must have functionality behind them
            //Program should run until user selects 'Exit'

            //SWITCH CASE??

            Client          firstClient   = new Client();
            CheckingAccount firstChecking = new CheckingAccount(129304, 567.80m);
            SavingsAccount  firstSavings  = new SavingsAccount(129305, 100.00m, 10.00m);

            Console.WriteLine("Hello, {0}! Please select an option.", firstClient.FirstName);
            Console.WriteLine();
            bool isUsing = true;

            while (isUsing == true)
            {
                Console.WriteLine("Please select an option:");
                ShowOptions();
                int userChoice = int.Parse(Console.ReadLine());

                switch (userChoice)
                {
                case 1:
                {
                    Console.WriteLine("Name: {0} {1}", firstClient.FirstName, firstClient.LastName);
                    Console.WriteLine("Age: {0}", firstClient.Age);
                    Console.WriteLine();
                    break;
                }

                case 2:
                {
                    Console.WriteLine();
                    bool choseOption = true;
                    while (choseOption == true)
                    {
                        Console.WriteLine("Which account would you like to view the balance of?");
                        Console.WriteLine("a. Checking Account");
                        Console.WriteLine("b. Savings Account");
                        string accountChoice = Console.ReadLine();
                        Console.WriteLine();

                        if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase))
                        {
                            Console.WriteLine("Your checking account balance is ${0}", firstChecking.AccountBalance);
                            choseOption = false;
                        }

                        else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase))
                        {
                            Console.WriteLine("Your savings account balance is ${0}", firstSavings.AccountBalance);
                            choseOption = false;
                        }

                        else
                        {
                            Console.WriteLine("Please select 'a' or 'b'.");
                        }
                        Console.WriteLine();
                    }
                    break;
                }

                case 3:
                {
                    Console.WriteLine();
                    Console.WriteLine("How much would you like to deposit? Please do not include \"$\" or \",\"");
                    decimal depositAmount = decimal.Parse(Console.ReadLine());

                    bool choseOption = true;
                    while (choseOption == true)
                    {
                        Console.WriteLine("Which account would you like to deposit into?");
                        Console.WriteLine("a. Checking Account");
                        Console.WriteLine("b. Savings Account");
                        string accountChoice = Console.ReadLine();
                        Console.WriteLine();

                        if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase))
                        {
                            firstChecking.Deposit(depositAmount);
                            Console.WriteLine("Your checking account balance is now ${0}", firstChecking.AccountBalance);
                            choseOption = false;
                        }

                        else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase))
                        {
                            firstSavings.Deposit(depositAmount);
                            Console.WriteLine("Your savings account balance is now ${0}", firstSavings.AccountBalance);
                            choseOption = false;
                        }

                        else
                        {
                            Console.WriteLine("Please select 'a' or 'b'.");
                        }
                        Console.WriteLine();
                    }
                    break;
                }

                case 4:
                {
                    Console.WriteLine();
                    Console.WriteLine("How much would you like to withdraw? Please do not include \"$\" or \",\"");
                    decimal withdrawAmount = decimal.Parse(Console.ReadLine());

                    bool choseOption = true;
                    while (choseOption == true)
                    {
                        Console.WriteLine("Which account would you like to withdraw from?");
                        Console.WriteLine("a. Checking Account");
                        Console.WriteLine("b. Savings Account");
                        string accountChoice = Console.ReadLine();
                        Console.WriteLine();

                        if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase))
                        {
                            firstChecking.Withdraw(withdrawAmount);
                            Console.WriteLine("Your checking account balance is now ${0}.", firstChecking.AccountBalance);
                            choseOption = false;
                        }

                        else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase))
                        {
                            firstSavings.Withdraw(withdrawAmount);
                            Console.WriteLine("Your savings account balance is now ${0}.", firstSavings.AccountBalance);
                            choseOption = false;
                        }

                        else
                        {
                            Console.WriteLine("Please select 'a' or 'b'.");
                        }
                        Console.WriteLine();
                    }

                    break;
                }

                case 5:

                    isUsing = false;
                    break;


                default:
                {
                    Console.WriteLine("That is not an option; please select one of the menu options.");
                }
                break;
                }
            }

            Console.WriteLine();
            Console.WriteLine("Thank you! See you next time.");
        }
        static void Main(string[] args)
        {
            string userOption;

            CheckingAccount check   = new CheckingAccount();
            SavingsAccount  save    = new SavingsAccount();
            ReserveAccount  reserve = new ReserveAccount();



MainMenu:
            Console.WriteLine("Please select a number from the list below and press enter.");

            List <string> clientOptions = new List <string>();        //Main Menu of options

            clientOptions.Add("1. View Client Information");
            clientOptions.Add("2. View Account Information");
            clientOptions.Add("3. Make a Deposit");
            clientOptions.Add("4. Make a Withdrawal");
            clientOptions.Add("5. Exit");

            foreach (string option in clientOptions)
            {
                Console.WriteLine(option);
            }

            userOption = Console.ReadLine();

            if (userOption == "1")
            {
                //display client information
                StreamReader reader = new StreamReader("ClientInfo.txt");
                using (reader)
                {
                    int    lineNumber = 1;
                    string line       = reader.ReadLine();

                    while (line != null)
                    {
                        lineNumber++;
                        Console.WriteLine(line);
                        line = reader.ReadLine();
                    }
                }
                Console.WriteLine();
            }
            else if (userOption == "2")     //User account info
            {
AccountBalanceMenu:
                Console.WriteLine("View which account balance: \n1. Checking \n2. Savings \n3. Reserve");
                string accountInfoInput = Console.ReadLine();
                if (accountInfoInput == "1")
                {
                    check.AccountBalance();         //shows balance
                }
                else if (accountInfoInput == "2")
                {
                    save.AccountBalance();          //shows balance
                }
                else if (accountInfoInput == "3")
                {
                    reserve.AccountBalance();         //shows balance
                }
                else
                {
                    Console.WriteLine("That is not a valid selection.  Please try again.");
                    goto AccountBalanceMenu;
                }
            }
            else if (userOption == "3")     //Make a deposit
            {
                // AccountSelection:
                Console.WriteLine("Into which account: \n1. Checking \n2. Savings \n3. Reserve");
                string userAccountInput = Console.ReadLine();

                if (userAccountInput == "1")   //Deposit -> Checking
                {
CheckingDepositInput:
                    Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign.");
                    try
                    {
                        check.CheckingDeposit = decimal.Parse(Console.ReadLine());
                        check.Deposit();                   //shows deposit amount and new balance and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You have entered non-numeric characters. Please try again.");
                        goto CheckingDepositInput;
                    }
                }

                if (userAccountInput == "2")   //  Deposit -> Savings
                {
SavingsDepositInput:
                    Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign.");
                    try
                    {
                        save.SavingsDeposit = decimal.Parse(Console.ReadLine());
                        save.Deposit();         //shows deposit amount and new balance and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You entered non-numeric characters. Please try again.");
                        goto SavingsDepositInput;
                    }
                }
                if (userAccountInput == "3")   //Deposit -> Reserve
                {
ReserveDepositInput:
                    Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign.");
                    try
                    {
                        reserve.ReserveDeposit = decimal.Parse(Console.ReadLine());
                        reserve.Deposit();      //shows deposit amount and new balance and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You have entered non-numeric characters. Please try again.");
                        goto ReserveDepositInput;
                    }
                }
            }    //  End of 3 .Make a deposit



            else if (userOption == "4")     //  Withdraw funds
            {
                // AccountSelection:
                Console.WriteLine("Into which account: \n1. Checking \n2. Savings \n3. Reserve");
                string userAccountInputW = Console.ReadLine();

                if (userAccountInputW == "1")   //Withdraw -> Checking
                {
CheckingWithdrawalInput:
                    Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign.");
                    try
                    {
                        check.CheckingWithdrawal = decimal.Parse(Console.ReadLine());
                        check.Withdrawal();       //show withdrawal amount and new balance and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You have entered non-numeric characters. Please try again.");
                        goto CheckingWithdrawalInput;
                    }
                }

                if (userAccountInputW == "2")   //  Withdraw -> Savings
                {
SavingsWithdrawalInput:
                    Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign.");
                    try
                    {
                        save.SavingsWithdrawal = decimal.Parse(Console.ReadLine());
                        save.Withdrawal();      //shows withdrawal amount and new savings and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You have entered non-numeric characters. Please try again.");
                        goto SavingsWithdrawalInput;
                    }
                }
                if (userAccountInputW == "3")   //  Withdraw -> Reserve
                {
ReserveWithdrawalInput:
                    Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign.");
                    try
                    {
                        reserve.ReserveWithdrawal = decimal.Parse(Console.ReadLine());
                        reserve.Withdrawal();       //show withdrawal amount and new balance and writes to text file
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("You have entered non-numeric characters. Please try again.");
                        goto ReserveWithdrawalInput;
                    }
                }
            }
            else if (userOption == "5")     //  Exit
            {
                Environment.Exit(0);
            }

            else
            {
                Console.WriteLine("That is not a valid option.  Please start over.");
                goto MainMenu;
            }
            goto MainMenu;
        } //static void main
Esempio n. 6
0
        static void Main(string[] args)
        {
            //open streamwriter to create text file
            StreamWriter accountReserve  = new StreamWriter("ReserveAccount.txt");
            StreamWriter accountSavings  = new StreamWriter("SavingsAccount.txt");
            StreamWriter accountChecking = new StreamWriter("CheckingAccount.txt");


            //get member name
            Console.WriteLine("Please enter your name.");
            string memberName = Console.ReadLine();

            Console.Clear();

            //create objects to use classes
            SavingsAccount  savings  = new SavingsAccount(memberName);
            CheckingAccount checking = new CheckingAccount(memberName);
            ReserveAccount  reserve  = new ReserveAccount(memberName);

            //streamwriter .txt files
            accountChecking.WriteLine("Gringott's Member " + memberName);
            accountChecking.WriteLine("Account Number: " + checking.AccountNumber);
            accountChecking.WriteLine("Account Type: Checking Account");
            accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);

            accountSavings.WriteLine("Gringott's Member " + memberName);
            accountSavings.WriteLine("Account Number: " + savings.AccountNumber);
            accountSavings.WriteLine("Account Type: Savings Account");
            accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);

            accountReserve.WriteLine("Gringott's Member " + memberName);
            accountReserve.WriteLine("Account Number: " + reserve.AccountNumber);
            accountReserve.WriteLine("Account Type: Reserve Account");
            accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);

            //loop for menu
            while (true)
            {
                //menu
                Console.WriteLine("Welcome to Gringott's Bank for Wizards and Witches. Please make a selection.");
                Console.WriteLine("1: View Member Info");
                Console.WriteLine("View Account Balance of:" + memberName);
                Console.WriteLine("\t2: Checking Account");
                Console.WriteLine("\t3: Savings Account");
                Console.WriteLine("\t4: Reserve Account");
                Console.WriteLine("5: Deposit Funds");
                Console.WriteLine("6: Withdrawal Funds");


                //member choice for which action on menu
                int action = int.Parse(Console.ReadLine());

                Console.Clear();

                //switch/case actions
                switch (action)
                {
                case 1:
                    savings.ClientInfo();
                    break;

                case 2:
                    checking.ViewAccountBalance();
                    break;

                case 3:
                    savings.ViewAccountBalance();
                    break;

                case 4:
                    reserve.ViewAccountBalance();
                    break;

                case 5:
                    Console.WriteLine("Please make a selection.");
                    Console.WriteLine("1: Checking Account");
                    Console.WriteLine("2: Savings Account");
                    Console.WriteLine("3: Reserve Account");

                    int choice = int.Parse(Console.ReadLine());

                    Console.WriteLine("Enter deposit amount.");

                    int deposit = int.Parse(Console.ReadLine());


                    // switch/case for deposit selection
                    switch (choice)
                    {
                    case 1:
                        checking.Deposit(deposit);
                        Console.WriteLine("Your account balance is " + checking.AccountBalance);
                        accountChecking.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);
                        break;

                    case 2:
                        savings.Deposit(deposit);
                        Console.WriteLine("Your account balance is " + savings.AccountBalance);
                        accountSavings.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);
                        break;

                    case 3:
                        reserve.Deposit(deposit);
                        Console.WriteLine("Your account balance is " + reserve.AccountBalance);
                        accountReserve.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);
                        break;

                    default:
                        break;
                    }
                    break;

                case 6:
                    Console.WriteLine("Please make a selection.");
                    Console.WriteLine("1: Checking Account");
                    Console.WriteLine("2: Savings Account");
                    Console.WriteLine("3: Reserve Account");

                    int pick = int.Parse(Console.ReadLine());

                    Console.WriteLine("Enter withdrawal amount.");

                    int withdrawal = int.Parse(Console.ReadLine());

                    //switch/case for withdrawing
                    switch (pick)
                    {
                    case 1:
                        checking.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + checking.AccountBalance);
                        accountChecking.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);
                        break;

                    case 2:
                        savings.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + savings.AccountBalance);
                        accountSavings.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);
                        break;

                    case 3:
                        reserve.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + reserve.AccountBalance);
                        accountReserve.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);
                        break;
                    }
                    break;

                default:
                    //quits
                    break;
                }


                Console.WriteLine("Do you need more time?");
                string yesOrNo = Console.ReadLine();
                if (yesOrNo.ToLower() == "y")
                {
                    Console.Clear();
                }
                else
                {
                    //quits the program if "no"
                    Console.Clear();
                    break;
                }
            }

            //closes the streamwriters
            accountReserve.Close();
            accountSavings.Close();
            accountChecking.Close();

            Quit();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Bank of Gatlantiss.");
            Console.WriteLine("It is nice to see you again.");

            Client          mikeClient = new Client();
            CheckingAccount mikeCh     = new CheckingAccount();
            SavingsAccount  mikeSv     = new SavingsAccount();

            //need one general object, one checking object, one savings object

            bool isBanking = true;

            while (isBanking == true)
            {
                Console.WriteLine("Please choose from the following options (choose a number):");
                Console.WriteLine("\t1.\tView your account information.");
                Console.WriteLine("\t2.\tView your total account balance.");
                Console.WriteLine("\t3.\tWithdraw funds");
                Console.WriteLine("\t4.\tDeposit funds");
                Console.WriteLine("\t5.\tEnd Banking");
                int choice = int.Parse(Console.ReadLine()); //this line reads user input

                if (choice == 1)                            //user checks client info
                {
                    mikeClient.ClientInfo();
                }

                if (choice == 2)  //user checks balances
                {
                    Console.WriteLine();
                    Console.WriteLine("Which account would you like to check?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountInfo();
                        mikeCh.InterestEarned();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountInfo();
                        mikeSv.InterestEarned();
                    }
                }

                if (choice == 3)  //withdrawals
                {
                    Console.WriteLine();
                    Console.WriteLine("From which account would you like to withdraw funds?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountWithdrawal();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountWithdrawal();
                    }
                }

                if (choice == 4)  //deposits
                {
                    Console.WriteLine();
                    Console.WriteLine("To which account would you like to deposit funds?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountDeposit();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountDeposit();
                    }
                }

                if (choice == 5)  //quit program
                {
                    Console.WriteLine("Thank you for banking with us today!");
                    Console.WriteLine("I hope we've EARNED your trust!");
                    Console.WriteLine("Press ENTER to leave the bank.");
                    Console.ReadLine();
                    isBanking = false;  //ends loop
                }
            }

            Environment.Exit(0);  //exits program after loop ends
        }