コード例 #1
0
ファイル: Bank.cs プロジェクト: Mojo1994/SE_Trainings
        public void Withdraw()
        {
            Console.Write("Enter Account Id: ");
            string accountId = Console.ReadLine();

            if (customerId.Contains(accountId))
            {
                int indexId = Array.IndexOf(customerId, accountId);
                Console.Write("Enter amount of money to withdraw: ");
                int moneyToWithdraw = Convert.ToInt32(Console.ReadLine());
                if (accType[indexId] == "Savings")
                {
                    savings.balance = myBalance[indexId];
                    savings.Withdraw(moneyToWithdraw);
                    myBalance[indexId] = savings.balance;
                }
                else if (accType[indexId] == "Current")
                {
                    current.balance = myBalance[indexId];
                    current.Withdraw(moneyToWithdraw);
                    myBalance[indexId] = current.balance;
                }
            }
            else
            {
                Console.WriteLine("Invalid Account");
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Savings sa1 = new Savings("001", "Faez", 9000);

            sa1.Deposit(1000);
            sa1.Withdraw(200);
            sa1.Deposit(4000);
            Console.WriteLine(sa1.Balance);

            Cheking cha1 = new Cheking("001", "Moshiur", 4000);

            cha1.Deposit(6000);
            cha1.Withdraw(5000);
            Console.WriteLine(cha1.NoOfTransition);

            Savings sa2 = new Savings("004", "Morshed", 6000);

            sa2.Deposit(8000);
            sa2.Withdraw(3000);

            List <Account> anAccounts = new List <Account>();

            anAccounts.Add(sa1);
            anAccounts.Add(cha1);
            anAccounts.Add(sa2);
            GetAllAccount(anAccounts);
            Console.ReadKey();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jsales3/BankAccount
        static void Main(string[] args)
        {
            Client myClient = new Client();

            Checkings myCheckings = new Checkings();

            Savings mySavings = new Savings();

            List <string> userOption = new List <string>();


            string userInput;
            double amount;

            userOption.Add("1. View Client Information");
            userOption.Add("2. View Account Balance");
            userOption.Add("3. Deposit Funds");
            userOption.Add("4. Withdraw Funds");
            userOption.Add("5. Exit");



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

                Console.WriteLine("Enter a number that corressponds to an option: ");
                userInput = Console.ReadLine();

                switch (userInput)
                {
                case "1":
                    myClient.ClientInfo(userInput);
                    break;

                case "2":
                    Console.WriteLine("A. Checkings Account Balance\n");
                    Console.WriteLine("B. Savings Account Balance");
                    userInput = Console.ReadLine().ToLower();
                    if (userInput == "a")
                    {
                        myCheckings.ViewBalance(userInput);
                    }
                    else if (userInput == "b")
                    {
                        mySavings.ViewBalance(userInput);
                    }
                    else
                    {
                        Console.WriteLine("Enter a valid letter that corresponds to an option!");
                    }
                    break;

                case "3":
                    Console.WriteLine("A. To Checkings Account\n");
                    Console.WriteLine("B. To Savings Account");
                    userInput = Console.ReadLine().ToLower();
                    if (userInput == "a")
                    {
                        Console.WriteLine("How much would you like to deposit?");
                        myCheckings.Deposits = double.Parse(Console.ReadLine());
                        myCheckings.Deposit(myCheckings.Deposits);
                    }
                    else if (userInput == "b")
                    {
                        Console.WriteLine("How much would you like to deposit?");
                        amount = double.Parse(Console.ReadLine());
                        mySavings.Deposit(amount);
                    }
                    else
                    {
                        Console.WriteLine("Enter a valid letter that corresponds to an option!");
                    }
                    break;

                case "4":
                    Console.WriteLine("A. From Checkings Account?\n");
                    Console.WriteLine("B. From Savings Account?");
                    userInput = Console.ReadLine().ToLower();
                    if (userInput == "a")
                    {
                        Console.WriteLine("How much would you like to withdraw?");
                        amount = double.Parse(Console.ReadLine());
                        myCheckings.Withdraw(amount);
                    }
                    else if (userInput == "b")
                    {
                        Console.WriteLine("How much would you like to withdraw?");
                        amount = double.Parse(Console.ReadLine());
                        mySavings.Withdraw(amount);
                    }
                    else
                    {
                        Console.WriteLine("Enter a valid letter that corresponds to an option!");
                    }
                    break;
                }
            }while (userInput != "5");
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: abrown29/BankAccount
        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
            }
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
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.");
        }
コード例 #7
0
        static void Main(string[] args)
        {
            //Instantiate!
            Client   potter = new Client();
            Checking check  = new Checking();
            Savings  save   = new Savings();
            Menu     main   = new Menu();

            float input; //store input numbers

            string selection;

            Console.WriteLine("Welcome to Gringott's Bank, sir. How may I be of service?");


            do
            {
                //View Menu
                main.MainMenu();

                selection = Console.ReadLine().Trim(); //store input

                if (selection == "1")                  //client info
                {
                    Console.WriteLine(potter.GetInfo());
                    Console.WriteLine("\nCan I do anything else for you, sir?\n");
                }
                else if (selection == "2") //Acct balance
                {
                    do
                    {
                        main.AccountMenu();
                        selection = Console.ReadLine().Trim();


                        if (selection == "1") //Show checking balance
                        {
                            Console.WriteLine("Your Checking Account balance is : $" + check.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else if (selection == "2") //show savings balance
                        {
                            Console.WriteLine("Your Savings Account balance is: $" + save.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else
                        {
                            main.ValidationMenu();
                        }
                    } while (selection != "1" && selection != "2");
                }
                else if (selection == "3") //Deposit funds
                {
                    do
                    {
                        main.AccountMenu();
                        selection = Console.ReadLine().Trim();
                        if (selection == "1") //Deposit to checking
                        {
                            Console.WriteLine("Please enter the amount you'd like to deposit.");
                            input = float.Parse(Console.ReadLine());
                            check.Deposit(input);
                            Console.WriteLine("Your Checking Account balance is : $" + check.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else if (selection == "2") //Deposit to savings
                        {
                            Console.WriteLine("Please enter the amount you'd like to deposit.");
                            input = float.Parse(Console.ReadLine());
                            save.Deposit(input);
                            Console.WriteLine("Your Savings Account balance is: $" + save.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else
                        {
                            main.ValidationMenu();
                        }
                    } while (selection != "1" && selection != "2");
                }
                else if (selection == "4") //Withdraw funds
                {
                    do
                    {
                        main.AccountMenu();
                        selection = Console.ReadLine().Trim();
                        if (selection == "1") //Withdraw from checking
                        {
                            Console.WriteLine("Please enter the amount you'd like to withdraw.");
                            input = float.Parse(Console.ReadLine());
                            check.Withdraw(input);
                            Console.WriteLine("Your Checking Account balance is : $" + check.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else if (selection == "2") //Withdraw from savings
                        {
                            Console.WriteLine("Please enter the amount you'd like to withdraw.");
                            input = float.Parse(Console.ReadLine());
                            save.Withdraw(input);
                            Console.WriteLine("Your Savings Account balance is: $" + save.acctBalance);
                            Console.WriteLine("\nCan I do anything else for you, sir?\n");
                        }
                        else
                        {
                            main.ValidationMenu();
                        }
                    } while (selection != "1" && selection != "2");
                }
            } while (selection != "5");


            {
                Console.WriteLine("Pleasure doing business with you, Mr. Potter.");
                Environment.Exit(5);
            }
        }
コード例 #8
0
        static void Main(string[] args)
        {
            //Instantiated Client,Checking,Saving
            Client   JerrySeinfeld     = new Client();
            Checking SeinfeldChecking1 = new Checking();
            Savings  SeinfeldSavings1  = new Savings();


            //Accounts
            string choice1;
            string choice2;
            double deposit;
            double withdraw;



            //do
            {
                //Welcome User
                Console.WriteLine("Welocme to Kramerica Bank");
                Console.WriteLine("Please make a selection");

                Console.WriteLine("1. View Client Informtion\n 2. View Account Balance\n 3. Deposit Funds \n 4. Withdraw Funds\n 5. Exit");
                Console.WriteLine("Please Enter a selection");
                choice1 = Console.ReadLine();
                Console.Clear();

                // Display User info

                if (choice1 == "1")
                {
                    JerrySeinfeld.CustomerInfo();

                    Console.Write("Please hit the enter key after selection");
                    Console.ReadLine();
                    Console.Clear();
                }
                //Check Account Balances
                if (choice1 == "2")
                {
                    do
                    {
                        Console.WriteLine("1.Checking Balance\n2. Savings Balance\n3. Back to Menu\n4.Exit ");
                        choice2 = Console.ReadLine();
                        Console.Clear();

                        if (choice2 == "1")

                        {
                            Console.WriteLine("Your Checking balance is  {0}", SeinfeldChecking1.AccountBalance);
                        }


                        if (choice2 == "2")
                        {
                            Console.WriteLine("Your Savings balance is {0}", SeinfeldSavings1.AccountBalance);
                        }

                        if (choice2 == "3")
                        {
                            break;
                        }

                        if (choice2 == "4")
                        {
                            if (choice1 == "5")
                            {
                                break;
                            }
                        }
                    } while (choice2 != "1" || choice2 != "2" || choice2 != "3" || choice2 != "4");
                }



                //Deposit Funds

                if (choice1 == "3")
                {
                    do
                    {
                        Console.WriteLine("Which Account would like to deposit?\n 1.Checking\n 2. Savings \n 3.back\n 4. Exit ");
                        choice1 = Console.ReadLine();
                        Console.Clear();



                        {
                            Console.WriteLine("How much to deposit");
                            deposit = double.Parse(Console.ReadLine());
                            SeinfeldChecking1.AccountBalance = SeinfeldChecking1.Deposit(deposit);

                            Console.WriteLine("Your balance is now {0}", SeinfeldChecking1.AccountBalance);
                            Console.WriteLine("Enter to continue");
                            Console.ReadLine();
                            Console.Clear();



                            {
                                Console.WriteLine("How much to deposit?");
                                deposit = double.Parse(Console.ReadLine());
                                SeinfeldChecking1.AccountBalance = SeinfeldSavings1.Deposit(deposit);
                                Console.WriteLine("Your balance is now {0}", SeinfeldSavings1.AccountBalance);
                                Console.WriteLine("Enter to continue");
                                Console.ReadLine();
                                Console.Clear();
                            }



                            {
                                break;
                            }

                            if (choice2 == "4")
                            {
                                break;
                            }
                        } while (choice2 != "1" || choice2 != "2" || choice2 != "3" || choice2 != "4")
                        {
                            ;
                        }


                        //Allow for Withdrawals
                        if (choice1 == "4")
                        {
                            do
                            {
                                Console.WriteLine("Which account to withdraw?\n 1. Checking\n 2. Savings\n 3. Back\n 4.Exit ");
                                choice2 = Console.ReadLine();
                                Console.Clear();
                                if (choice2 == "1")
                                {
                                    Console.WriteLine("How much to withdraw?");
                                    withdraw = double.Parse(Console.ReadLine());
                                    SeinfeldChecking1.Withdraw(withdraw);

                                    Console.WriteLine("New balalance is {0}", SeinfeldChecking1.AccountBalance);
                                    Console.WriteLine("enter to continue");
                                    Console.ReadLine();
                                    Console.Clear();
                                }
                                if (choice2 == "2")
                                {
                                    Console.WriteLine("How much to withdraw?");
                                    withdraw = double.Parse(Console.ReadLine());
                                    if (withdraw > SeinfeldSavings1.AccountBalance)
                                    {
                                        Console.WriteLine("insufficient funds");
                                        Console.WriteLine("enter");
                                        Console.ReadLine();
                                        Console.Clear();
                                        break;
                                    }


                                    SeinfeldSavings1.AccountBalance = SeinfeldSavings1.Withdraw(withdraw);
                                    Console.WriteLine("new balance is {0}", SeinfeldSavings1.AccountBalance);
                                    Console.ReadLine();
                                    Console.Clear();
                                }


                                if (choice2 == "3")
                                {
                                    break;
                                }

                                if (choice2 == "4")
                                {
                                    break;
                                }

                                {
                                    if (choice1 == "5")
                                    {
                                        ;
                                    }
                                }
                            } while (choice2 != "1" || choice2 != "2" || choice2 != "3" || choice2 != "4");
                        }
                    } while (choice1 != "5");
                }
            }
        }