Esempio n. 1
0
        static void Main(string[] args)
        {
            Savings  DGilbertSavings  = new Savings("Dan", "Gilbert", "savings", "1029384756", 4700000000);
            Checking DGilbertChecking = new Checking("Dan", "Gilbert", "checking", "1290347856", 20000000);
            Reserve  DGilbertReserve  = new Reserve("Dan", "Gilbert", "reserve", "2109438765", 12500000);

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Hello Dan Gilbert,\n\nPlease choose an account below:\n\n");
                Console.WriteLine("Checking Account \t[Enter \"1\"]");
                Console.WriteLine("Reserve Account \t[Enter \"2\"]");
                Console.WriteLine("Savings Account \t[Enter \"3\"]");
                Console.WriteLine("Exit \t\t\t[Enter \"0\"]");

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

                if (accChoice == 1)
                {
                    Console.Clear();
                    DGilbertChecking.DisplayAccountInfo("checking");
                    Console.WriteLine("Account Summary [Enter \"1\"]");
                    Console.WriteLine("Deposit \t[Enter \"2\"]");
                    Console.WriteLine("Withdraw \t[Enter \"3\"]");
                    int accAction = int.Parse(Console.ReadLine());
                    if (accAction == 1)
                    {
                        Console.Clear();
                        Console.WriteLine(DGilbertChecking.AccountSummary("DGilbertChecking"));
                        Console.ReadLine();
                    }
                    else if (accAction == 2)
                    {
                        DGilbertChecking.Deposit();
                    }
                    else if (accAction == 3)
                    {
                        DGilbertChecking.Withdraw();
                    }
                }
                else if (accChoice == 2)
                {
                    Console.Clear();
                    DGilbertChecking.DisplayAccountInfo("reserve");
                    Console.WriteLine("Account Summary [Enter \"1\"]");
                    Console.WriteLine("Deposit \t[Enter \"2\"]");
                    Console.WriteLine("Withdraw \t[Enter \"3\"]");
                    int accAction = int.Parse(Console.ReadLine());
                    if (accAction == 1)
                    {
                        Console.Clear();
                        Console.WriteLine(DGilbertReserve.AccountSummary("DGilbertReserve"));
                        Console.ReadLine();
                    }
                    else if (accAction == 2)
                    {
                        DGilbertReserve.Deposit();
                    }
                    else if (accAction == 3)
                    {
                        DGilbertReserve.Withdraw();
                    }
                }
                else if (accChoice == 3)
                {
                    Console.Clear();
                    DGilbertChecking.DisplayAccountInfo("savings");
                    Console.WriteLine("Account Summary [Enter \"1\"]");
                    Console.WriteLine("Deposit \t[Enter \"2\"]");
                    Console.WriteLine("Withdraw \t[Enter \"3\"]");
                    int accAction = int.Parse(Console.ReadLine());
                    if (accAction == 1)
                    {
                        Console.ReadLine();
                        Console.WriteLine(DGilbertSavings.AccountSummary("DGilbertSavings"));
                        Console.ReadLine();
                    }
                    else if (accAction == 2)
                    {
                        DGilbertSavings.Deposit();
                    }
                    else if (accAction == 3)
                    {
                        DGilbertSavings.Withdraw();
                    }
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Checking spend     = new Checking();
            Reserve  shortTerm = new Reserve();
            Savings  longTerm  = new Savings();

            int userChoice = 0;

            do
            {
                Console.WriteLine("Welcome to Gringotts Wizard Bank. Please select an option to continue:");
                Console.WriteLine("1. View Wizard Information \n2. View vault balance \n3. Deposit Galleons \n4. Withdraw Galleons \n5. Exit");
                userChoice = int.Parse(Console.ReadLine());

                if (userChoice == 1) //shows client information
                {
                    spend.getInformation();
                }
                else if (userChoice == 2) //choose an account balance to view
                {
                    Console.WriteLine("Please choose a balance to view:\n1.Checking\n2.Reserve\n3.Savings");
                    int option = int.Parse(Console.ReadLine());
                    if (option == 1)
                    {
                        spend.getBalance();
                    }
                    else if (option == 2)
                    {
                        shortTerm.getBalance();
                    }
                    else if (option == 3)
                    {
                        longTerm.getBalance();
                    }
                }
                else if (userChoice == 3) //deposit funds into a section of account
                {
                    Console.WriteLine("Please choose the section you wish to deposit funds into:\n1.Checking\n2.Reserve\n3.Savings");
                    int option = int.Parse(Console.ReadLine());
                    if (option == 1)
                    {
                        spend.Deposit();
                    }
                    else if (option == 2)
                    {
                        shortTerm.Deposit();
                    }
                    else if (option == 3)
                    {
                        longTerm.Deposit();
                    }
                }
                else if (userChoice == 4) //withdraw funds from a section of account
                {
                    Console.WriteLine("Please choose the section you wish to withdraw funds from: \n1. Checking\n2. Reserve\n3. Savings");
                    int option = int.Parse(Console.ReadLine());
                    if (option == 1)
                    {
                        spend.Withdraw();
                    }
                    else if (option == 2)
                    {
                        shortTerm.Withdraw();
                    }
                    else if (option == 3)
                    {
                        longTerm.Withdraw();
                    }
                }
                else if (userChoice == 5) //quits the program
                {
                    Environment.Exit(0);
                }
            }while (userChoice < 6 && userChoice > 0);

            StreamWriter saveAccount = new StreamWriter("..\\..\\..Savings.txt");

            using (saveAccount)
            {
                saveAccount.WriteLine(u) //trying to get the stream writer to work
                //don't know if it's meant to go here or into each class
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //switches backgroung/foreground colors
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();

            //ask client for information
            Console.WriteLine("Welcome to SSB Bank! What is your first name?\n");
            string firstName = Console.ReadLine();

            //forces user to input non-integer name
            //bypasses error if user does not enter a value
            int value = 0;

            while (int.TryParse(firstName, out value) || firstName == "")
            {
                Console.WriteLine("\nPlease enter a valid name\n");
                string firstName2 = Console.ReadLine();
                firstName = firstName2;
            }

            //capitalizes first letter
            firstName.ToLower();
            firstName = firstName.First().ToString().ToUpper() + firstName.Substring(1);

            Console.WriteLine("\nPlease enter your last name:\n");
            string lastName = Console.ReadLine();

            //forces user to input non-integer name
            //bypasses error if user does not enter a value
            value = 0;
            while (int.TryParse(lastName, out value) || lastName == "")
            {
                Console.WriteLine("\nPlease enter a valid name\n");
                string lastName2 = Console.ReadLine();
                lastName = lastName2;
            }

            //capitalizes first letter
            lastName.ToLower();
            lastName = lastName.First().ToString().ToUpper() + lastName.Substring(1);

            Console.WriteLine("\nWhat state do you live in?\n");
            string state = Console.ReadLine();

            //forces user to input non-integer name
            //bypasses error if user does not enter a value
            value = 0;
            while (int.TryParse(state, out value) || state == "")
            {
                Console.WriteLine("\nPlease enter a valid state\n");
                string state2 = Console.ReadLine();
                state = state2;
            }

            //capitalizes state name
            state = state.ToUpper();

            Console.WriteLine("\nWhat city do you live in?\n");
            string city = Console.ReadLine();

            //forces user to input non-integer name
            //bypasses error if user does not enter a value
            value = 0;
            while (int.TryParse(city, out value) || city == "")
            {
                Console.WriteLine("\nPlease enter a valid city\n");
                string city2 = Console.ReadLine();
                city = city2;
            }

            //capitalizes first letter
            city.ToLower();
            city = city.First().ToString().ToUpper() + city.Substring(1);

            Console.WriteLine("\nPlease enter your email address:\n");
            string email = Console.ReadLine();

            //bypasses error if user does not enter a value
            //forces user to enter "@"
            while (email == "" || email.Contains("@") == false)
            {
                Console.WriteLine("\nPlease enter a valid email\n");
                string email2 = Console.ReadLine();
                email = email2;
            }

            //ask client to deposit funds into bank accounts
            Console.Clear();
            Console.WriteLine("\nHello, " + firstName + " " + lastName + "! In order to partner with SSB, you will need to make deposits into your new accounts.\n");

            Console.WriteLine("How much would you like to deposit into your Checking Account?\n");

            //stores user input as string
            string chInput = Console.ReadLine();

            //bypasses error if user presses enter without entering value
            //bypasses error if user enters a letter
            value = -1;
            while (!int.TryParse(chInput, out value) || chInput == "")
            {
                Console.WriteLine("\nPlease enter a valid number\n");
                string chInput2 = Console.ReadLine();
                chInput = chInput2;
            }

            //stores user input as integer
            int chDep = int.Parse(chInput);

            Console.WriteLine("\nHow much would you like to deposit into your Saving Account?\n");

            //stores user input as string
            string sInput = Console.ReadLine();

            //bypasses error if user presses enter without entering value
            //bypasses error if user enters a letter
            value = -1;
            while (!int.TryParse(sInput, out value) || sInput == "")
            {
                Console.WriteLine("\nPlease enter a valid number\n");
                string sInput2 = Console.ReadLine();
                sInput = sInput2;
            }

            //stores user input as integer
            int sDep = int.Parse(sInput);

            Console.WriteLine("\nHow much would you like to deposit into your Reserve Account?\n");

            //stores user input as string
            string rInput = Console.ReadLine();

            //bypasses error if user presses enter without entering value
            //bypasses error if user enters a letter
            value = -1;
            while (!int.TryParse(rInput, out value) || rInput == "")
            {
                Console.WriteLine("\nPlease enter a valid number\n");
                string rInput2 = Console.ReadLine();
                rInput = rInput2;
            }

            //stores user input as integer
            int rDep = int.Parse(rInput);

            //generates account numbers
            Random num          = new Random();
            int    chAcctNumGen = num.Next(10000);
            int    sAcctNumGen  = chAcctNumGen + 1;
            int    rAcctNumGen  = sAcctNumGen + 1;

            string checkingAcctNum = "27274662" + chAcctNumGen.ToString();
            string savingAcctNum   = "27274662" + sAcctNumGen.ToString();
            string reserveAcctNum  = "27274662" + rAcctNumGen.ToString();

            //instantiates account objects in Checking, Saving, Reserve
            Checking CheckingAccount = new Checking(checkingAcctNum)
            {
                AccountNum = checkingAcctNum
            };
            Saving SavingAccount = new Saving(savingAcctNum)
            {
                AccountNum = savingAcctNum
            };
            Reserve ReserveAccount = new Reserve(reserveAcctNum)
            {
                AccountNum = reserveAcctNum
            };

            //inputs balance into account objects
            CheckingAccount.CheckingBalance = chDep;
            SavingAccount.SavingBalance     = sDep;
            ReserveAccount.ReserveBalance   = rDep;

            //instantiaties client object in Account Class
            Account Client = new Account();

            Client.FirstName    = firstName;
            Client.LastName     = lastName;
            Client.City         = city;
            Client.State        = state;
            Client.Email        = email;
            Client.TotalBalance = chDep + sDep + rDep;

            //instantiate streamwriters
            StreamWriter CheckingWriter = new StreamWriter("CheckingAccount.txt");

            CheckingWriter.WriteLine("Name of Client: " + Client.FullName);
            CheckingWriter.WriteLine("Checking Account Number: " + CheckingAccount.AccountNum);
            CheckingWriter.WriteLine("");
            CheckingWriter.WriteLine("\tBeginning of Statement Balance: $" + CheckingAccount.CheckingBalance);
            CheckingWriter.WriteLine("");

            StreamWriter SavingWriter = new StreamWriter("SavingAccount.txt");

            SavingWriter.WriteLine("Name of Client: " + Client.FullName);
            SavingWriter.WriteLine("Saving Account Number: " + SavingAccount.AccountNum);
            SavingWriter.WriteLine("");
            SavingWriter.WriteLine("\tBeginning of Statement Balance: $" + SavingAccount.SavingBalance);
            SavingWriter.WriteLine("");

            StreamWriter ReserveWriter = new StreamWriter("ReserveAccount.txt");

            ReserveWriter.WriteLine("Name of Client: " + Client.FullName);
            ReserveWriter.WriteLine("Saving Account Number: " + ReserveAccount.AccountNum);
            ReserveWriter.WriteLine("");
            ReserveWriter.WriteLine("\tBeginning of Statement Balance: $" + ReserveAccount.ReserveBalance);
            ReserveWriter.WriteLine("");

            //clears console before displaying menu items
            Console.Clear();

            while (true)
            {
Menu:
                Console.Clear();
                Console.WriteLine("     ..######...######..########.....########.....###....##....##.##....##");
                Console.WriteLine("     .##....##.##....##.##.....##....##.....##...##.##...###...##.##...##.");
                Console.WriteLine("     .##.......##.......##.....##....##.....##..##...##..####..##.##..##..");
                Console.WriteLine("     ..######...######..########.....########..##.....##.##.##.##.#####...");
                Console.WriteLine("     .......##.......##.##.....##....##.....##.#########.##..####.##..##..");
                Console.WriteLine("     .##....##.##....##.##.....##....##.....##.##.....##.##...###.##...##.");
                Console.WriteLine("     ..######...######..########.....########..##.....##.##....##.##....##");
                Console.WriteLine("\n");

                Console.WriteLine("\t1 - View Client Information");
                Console.WriteLine("\t2 - View Total Balance");
                Console.WriteLine("\t\t3 - Checking");
                Console.WriteLine("\t\t4 - Saving");
                Console.WriteLine("\t\t5 - Reserve");
                Console.WriteLine("\t6 - Deposit Funds");
                Console.WriteLine("\t7 - Withdraw Funds");
                Console.WriteLine("\t8 - Exit\n");

                //stores user input as string
                string userInput = Console.ReadLine();

                //bypasses error if user presses enter without entering value
                while (userInput == "")
                {
                    Console.WriteLine("\nPlease enter a valid number");
                    string userInput2 = Console.ReadLine();
                    userInput = userInput2;
                }

                //bypasses error if user enters a letter
                value = -1;
                while (!int.TryParse(userInput, out value))
                {
                    Console.WriteLine("\nPlease enter a valid number");
                    string userInput2 = Console.ReadLine();
                    userInput = userInput2;
                }

                //stores user input as integer
                int input = int.Parse(userInput);

                //prevents user from entering values out of range
                while (input < 1 || input > 8)
                {
                    Console.WriteLine("\nPlease enter a valid number");
                    int input2 = int.Parse(Console.ReadLine());
                    input = input2;
                }

                //quit program
                if (input == 8)
                {
                    Console.Clear();
                    CheckingWriter.Close();
                    SavingWriter.Close();
                    ReserveWriter.Close();
                    break;
                }

                //actions to be completed based on user input
                if (input == 1)
                {
                    Console.Clear();

                    Client.DisplayInfo();

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 2)
                {
                    Console.Clear();

                    Client.DisplayTotalBalance();

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 3)
                {
                    Console.Clear();

                    CheckingAccount.DisplayBalance();

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 4)
                {
                    Console.Clear();
                    SavingAccount.DisplayBalance();
                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 5)
                {
                    Console.Clear();

                    ReserveAccount.DisplayBalance();

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 6)
                {
                    Console.Clear();

                    Console.WriteLine("To which account would you like to make a deposit?\n");
                    Console.WriteLine("1 - Checking\n2 - Saving\n3 - Reserve\n");
                    string acctInput = Console.ReadLine();

                    //bypasses error if user presses enter without entering value
                    //bypasses error if user enters a letter
                    value = -1;
                    while (!int.TryParse(acctInput, out value) || acctInput == "")
                    {
                        Console.WriteLine("\nPlease enter a valid number\n");
                        string acctInput2 = Console.ReadLine();
                        acctInput = acctInput2;
                    }

                    //stores user input as integer
                    int acct = int.Parse(acctInput);

                    //prevents user from entering values out of range
                    while (acct < 1 || acct > 3)
                    {
                        Console.WriteLine("\nPlease enter a valid number\n");
                        int acct2 = int.Parse(Console.ReadLine());
                        acct = acct2;
                    }

                    if (acct == 1)
                    {
                        Console.WriteLine("\nHow much would you like to deposit into your Checking Account?\n");
                        string depInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(depInput, out value) || depInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string depInput2 = Console.ReadLine();
                            depInput = depInput2;
                        }

                        //stores user input as integer
                        int dep = int.Parse(depInput);

                        //prevents user from entering values out of range
                        while (dep <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int dep2 = int.Parse(Console.ReadLine());
                            dep = dep2;
                        }

                        CheckingAccount.Deposit(dep);
                        CheckingAccount.DisplayBalance();

                        //streamwriter
                        CheckingWriter.WriteLine("\t" + DateTime.Now + "\t" + "(+) $" + dep + "\tUpdated Balance: $" + CheckingAccount.CheckingBalance);
                    }
                    else if (acct == 2)
                    {
                        Console.WriteLine("\nHow much would you like to deposit into your Saving Account?\n");
                        string depInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(depInput, out value) || depInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string depInput2 = Console.ReadLine();
                            depInput = depInput2;
                        }

                        //stores user input as integer
                        int dep = int.Parse(depInput);

                        //prevents user from entering values out of range
                        while (dep <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int dep2 = int.Parse(Console.ReadLine());
                            dep = dep2;
                        }

                        SavingAccount.Deposit(dep);
                        SavingAccount.DisplayBalance();

                        //streamwriter
                        SavingWriter.WriteLine("\t" + DateTime.Now + "\t" + "(+) $" + dep + "\tUpdated Balance: $" + SavingAccount.SavingBalance);
                    }
                    else if (acct == 3)
                    {
                        Console.WriteLine("\nHow much would you like to deposit into your Reserve Account?\n");
                        string depInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(depInput, out value) || depInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string depInput2 = Console.ReadLine();
                            depInput = depInput2;
                        }

                        //stores user input as integer
                        int dep = int.Parse(depInput);

                        //prevents user from entering values out of range
                        while (dep <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int dep2 = int.Parse(Console.ReadLine());
                            dep = dep2;
                        }

                        ReserveAccount.Deposit(dep);
                        ReserveAccount.DisplayBalance();

                        //streamwriter
                        ReserveWriter.WriteLine("\t" + DateTime.Now + "\t" + "(+) $" + dep + "\tUpdated Balance: $" + ReserveAccount.ReserveBalance);
                    }

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
                else if (input == 7)
                {
                    Console.Clear();

                    Console.WriteLine("From which account would you like to make a withdrawal?\n");
                    Console.WriteLine("1 - Checking\n2 - Saving\n3 - Reserve\n");
                    string acctInput = Console.ReadLine();

                    //bypasses error if user presses enter without entering value
                    //bypasses error if user enters a letter
                    value = -1;
                    while (!int.TryParse(acctInput, out value) || acctInput == "")
                    {
                        Console.WriteLine("\nPlease enter a valid number\n");
                        string acctInput2 = Console.ReadLine();
                        acctInput = acctInput2;
                    }

                    //stores user input as integer
                    int acct = int.Parse(acctInput);

                    //prevents user from entering values out of range
                    while (acct < 1 || acct > 3)
                    {
                        Console.WriteLine("\nPlease enter a valid number\n");
                        int acct2 = int.Parse(Console.ReadLine());
                        acct = acct2;
                    }

                    if (acct == 1)
                    {
                        Console.WriteLine("\nHow much would you like to withdraw from your Checking Account?\n");
                        string withInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(withInput, out value) || withInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string withInput2 = Console.ReadLine();
                            withInput = withInput2;
                        }

                        //stores user input as integer
                        int with = int.Parse(withInput);

                        //prevents user from entering values out of range
                        while (with <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int with2 = int.Parse(Console.ReadLine());
                            with = with2;
                        }

                        CheckingAccount.Withdraw(with);
                        CheckingAccount.DisplayBalance();

                        //streamwriter
                        CheckingWriter.WriteLine("\t" + DateTime.Now + "\t" + "(-) $" + with + "\tUpdated Balance: $" + CheckingAccount.CheckingBalance);
                    }
                    else if (acct == 2)
                    {
                        Console.WriteLine("\nHow much would you like to withdraw from your Saving Account?\n");
                        string withInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(withInput, out value) || withInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string withInput2 = Console.ReadLine();
                            withInput = withInput2;
                        }

                        //stores user input as integer
                        int with = int.Parse(withInput);

                        //prevents user from entering values out of range
                        while (with <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int with2 = int.Parse(Console.ReadLine());
                            with = with2;
                        }

                        SavingAccount.Withdraw(with);
                        SavingAccount.DisplayBalance();

                        //streamwriter
                        SavingWriter.WriteLine("\t" + DateTime.Now + "\t" + "(-) $" + with + "\tUpdated Balance: $" + SavingAccount.SavingBalance);
                    }
                    else if (acct == 3)
                    {
                        Console.WriteLine("\nHow much would you like to withdraw from your Reserve Account?\n");
                        string withInput = Console.ReadLine();

                        //bypasses error if user presses enter without entering value
                        //bypasses error if user enters a letter
                        value = -1;
                        while (!int.TryParse(withInput, out value) || withInput == "")
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            string withInput2 = Console.ReadLine();
                            withInput = withInput2;
                        }

                        //stores user input as integer
                        int with = int.Parse(withInput);

                        //prevents user from entering values out of range
                        while (with <= 0)
                        {
                            Console.WriteLine("\nPlease enter a valid number\n");
                            int with2 = int.Parse(Console.ReadLine());
                            with = with2;
                        }

                        ReserveAccount.Withdraw(with);
                        ReserveAccount.DisplayBalance();

                        //streamwriter
                        ReserveWriter.WriteLine("\t" + DateTime.Now + "\t" + "(-) $" + with + "\tUpdated Balance: $" + ReserveAccount.ReserveBalance);
                    }

                    Console.WriteLine("\nPress any key to access main menu...\n");
                    Console.ReadKey();
                    goto Menu;
                }
            }
            Console.WriteLine("Thank you for your business.\n");
        }