Пример #1
0
        public static void Main(string[] args)
        {
            Account  account  = new Account();
            Savings  savings  = new Savings(10000);
            Checking checking = new Checking(2000);

            string clientInfo          = account.DisplayAccountHolderFullName();
            string checkingAccountType = checking.AccountType;
            string savingsAccountType  = savings.AccountType;

            IList <string> checkingAccountSummary = new List <string>();
            IList <string> savingsAccountSummary  = new List <string>();

            checkingAccountSummary.Add(clientInfo);
            checkingAccountSummary.Add(checkingAccountType);

            savingsAccountSummary.Add(clientInfo);
            savingsAccountSummary.Add(savingsAccountType);

            string userChoice = "";

            do
            {
                string checkingDepositAmount = ($"Transaction: +${checking.DepositAmount} at {DateTime.Now}" +
                                                $"Current Balance: ${checking.Balance}");
                string savingsDepositAmount = ($"Transaction: +${savings.DepositAmount} at {DateTime.Now}" +
                                               $"Current Balance: ${savings.Balance}");
                string checkingWithrdawAmount = ($"Transaction: -${checking.WithdrawAmount} at {DateTime.Now}" +
                                                 $"Current Balance: ${checking.Balance}");
                string savingsWithrdawAmount = ($"Transaction: -${savings.WithdrawAmount} at {DateTime.Now}" +
                                                $"Current Balance: ${savings.Balance}");

                if (checking.DepositAmount > 0)
                {
                    checkingAccountSummary.Add(checkingDepositAmount);
                    checking.DepositAmount = 0;
                }

                if (savings.DepositAmount > 0)
                {
                    savingsAccountSummary.Add(savingsDepositAmount);
                    savings.DepositAmount = 0;
                }

                if (checking.WithdrawAmount > 0)
                {
                    checkingAccountSummary.Add(checkingWithrdawAmount);
                    checking.WithdrawAmount = 0;
                }

                if (savings.WithdrawAmount > 0)
                {
                    savingsAccountSummary.Add(savingsWithrdawAmount);
                    savings.WithdrawAmount = 0;
                }

                account.DisplayFirstMessage();
                Console.ReadLine();

                account.DisplayMenu();
                userChoice = Console.ReadLine();

                switch (userChoice.ToUpper())
                {
                case "I":
                    Console.Clear();
                    Console.WriteLine(clientInfo);
                    break;

                case "CB":
                    Console.Clear();
                    checking.AccountBalance();
                    Console.WriteLine("Checking Account Balance: ${0}", checking.Balance);
                    break;

                case "SB":
                    Console.Clear();
                    savings.AccountBalance();
                    Console.WriteLine("Savings Account Balance: ${0}", savings.Balance);
                    break;

                case "CD":
                    Console.Clear();
                    Console.WriteLine("How much would you like to deposit?");
                    checking.DepositAmount = double.Parse(Console.ReadLine());
                    Console.WriteLine("You deposited: ${0}", checking.DepositAmount);
                    checking.DepositBalance(checking.DepositAmount);
                    break;

                case "SD":
                    Console.Clear();
                    Console.WriteLine("How much would you like to deposit?");
                    savings.DepositAmount = double.Parse(Console.ReadLine());
                    Console.WriteLine("You deposited: ${0}", savings.DepositAmount);
                    savings.DepositBalance(savings.DepositAmount);
                    break;

                case "CW":
                    Console.Clear();
                    Console.WriteLine("How much would you like to withdraw?");
                    checking.WithdrawAmount = double.Parse(Console.ReadLine());
                    Console.WriteLine("You withdrew: ${0}", checking.WithdrawAmount);
                    checking.WithdrawBalance(checking.WithdrawAmount);
                    break;

                case "SW":
                    Console.Clear();
                    Console.WriteLine("How much would you like to withdraw?");
                    checking.WithdrawAmount = double.Parse(Console.ReadLine());
                    Console.WriteLine("You withdrew: ${0}", checking.WithdrawAmount);
                    checking.WithdrawBalance(checking.WithdrawAmount);
                    break;

                case "X":
                    Console.Clear();
                    account.WriteSummary(checkingAccountSummary, "Checking");
                    account.WriteSummary(savingsAccountSummary, "Savings");
                    Console.WriteLine("Thanks and come again!");
                    Environment.Exit(0);
                    break;
                }
            } while (userChoice.ToUpper() != "X");
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Instantiate all objects
            Client   greg     = new Client();
            Checking checking = new Checking(1200.00d, 8645);
            Savings  savings  = new Savings(500.00d, 8431);

            //Set up menu options within loop
            int choice;

            Console.WriteLine("Welcome to Cross Roads Bank. Hello " + greg.ClientName);
            Console.WriteLine("What would you like to do?\n");
            Console.WriteLine("1. View Client Information");
            Console.WriteLine("2. View Account Balance");
            Console.WriteLine("3. Deposit Funds");
            Console.WriteLine("4. Withdraw Funds");
            Console.WriteLine("5. Exit");
            Console.WriteLine();
            choice = int.Parse(Console.ReadLine());

            while (choice != 5)
            {
                if (choice == 1)
                {
                    greg.ClientInformation(); //Displays information
                }
                else if (choice == 2)
                {
                    Accounts.AccountType();
                    Console.WriteLine();
                    int accountType = int.Parse(Console.ReadLine());
                    if (accountType == 1)
                    {
                        Console.WriteLine();
                        Console.WriteLine(checking.AccountBalance()); //Checking version of this method
                    }
                    else if (accountType == 2)
                    {
                        Console.WriteLine();
                        Console.WriteLine(savings.AccountBalance()); //Savings version of this method
                    }
                }
                else if (choice == 3)
                {
                    Accounts.AccountType();
                    Console.WriteLine();
                    int accountType = int.Parse(Console.ReadLine());
                    if (accountType == 1)
                    {
                        Console.WriteLine();
                        checking.Deposit();
                        Console.WriteLine();
                    }
                    else if (accountType == 2)
                    {
                        Console.WriteLine();
                        savings.Deposit();
                        Console.WriteLine();
                    }
                }
                else if (choice == 4)
                {
                    Accounts.AccountType();
                    Console.WriteLine();
                    int accountType = int.Parse(Console.ReadLine());
                    if (accountType == 1)
                    {
                        Console.WriteLine();
                        checking.Withdraw();
                        Console.WriteLine();
                    }
                    else if (accountType == 2)
                    {
                        Console.WriteLine();
                        savings.Withdraw(); //Savings version of this method
                        Console.WriteLine();
                    }
                }
                //Reiterate before looping back so user can close
                Console.WriteLine("\nWhat would you like to do?\n");
                Console.WriteLine("1. View Client Information");
                Console.WriteLine("2. View Account Balance");
                Console.WriteLine("3. Deposit Funds");
                Console.WriteLine("4. Withdraw Funds");
                Console.WriteLine("5. Exit");
                Console.WriteLine();
                choice = int.Parse(Console.ReadLine());
            }

            Console.WriteLine("\nThank you for banking with Cross Roads Bank! Have a nice day.");
        }