示例#1
0
        static void Main(string[] args)
        {
            int      balance;
            string   accountName;
            Checking checking = null;
            Savings  savings  = null;

            while (true)
            {
                Console.WriteLine("1. Exit program");
                Console.WriteLine("2. Create Checking Account");
                Console.WriteLine("3. Create Savings Account");
                Console.WriteLine("4. Get Checking Balance");
                Console.WriteLine("5. Get Savings Balance");
                Console.WriteLine("6. Make a Deposit to Checking");
                Console.WriteLine("7. Make a Deposit to Savings");
                int menuOption = Utils.GetNumber("Enter a menu option: ");
                if (menuOption == 1)
                {
                    break;
                }
                if (menuOption == 2)
                {
                    float fIntrestRate = 0.02F;
                    accountName = Utils.GetInput("What would you like to name your account: ");
                    balance     = Utils.GetNumber("What is the initial balance of the account: ");
                    checking    = new Checking(accountName, balance, fIntrestRate);
                }
                if (menuOption == 3)
                {
                    float fIntrestRate = 0.03F;
                    accountName = Utils.GetInput("What would you like to name your account: ");
                    balance     = Utils.GetNumber("What is the initial balance of the account: ");
                    savings     = new Savings(accountName, balance, fIntrestRate);
                }
                if (menuOption == 4)
                {
                    Console.WriteLine(checking);
                }
                if (menuOption == 5)
                {
                    Console.WriteLine(savings);
                }
                if (menuOption == 6)
                {
                    int depositAmount = Utils.GetNumber("How much would you like to deposit: ");
                    checking.Deposit(depositAmount);
                }
                if (menuOption == 7)
                {
                    int depositAmount = Utils.GetNumber("How much would you like to deposit: ");
                    savings.Deposit(depositAmount);
                }
            }
        }
示例#2
0
        private void btn_deposit_Click(object sender, EventArgs e)
        {
            int     sNum  = SQLHelper.getsavenumber(Convert.ToInt32(customernumber.Text));
            Savings check = new Savings();
            bool    ver   = check.verify(txt_amount.Text);

            if (ver == false)
            {
                MessageBox.Show("Please enter a number");
                txt_amount.Clear();
            }
            else
            {
                decimal amount = Convert.ToDecimal(txt_amount.Text);
                SQLHelper.Deposit(sNum, amount);
                txt_amount.Clear();
                UpdateBox();
            }
        }
示例#3
0
文件: ATM.cs 项目: mjlacy/CSharpATM
        void PopulateAcct()
        {
            int index = -99;

            for (int i = 0; i < myAccounts.Length; i++)
            {
                if (myAccounts[i] == null)
                {
                    index = i;
                    break;
                }
            }
            if (index != -99)
            {
                Console.WriteLine("\nPlease enter a name to be associated with the type of account you want");
                String name = Console.ReadLine();
                for (int i = 0; i < myAccounts.Length; i++)
                {
                    if (myAccounts[i] != null && name.ToLowerInvariant() == myAccounts[i].Name.ToLowerInvariant())
                    {
                        Console.WriteLine("\nThat name has already been used\n");
                        Greeting();
                        return;
                    }

                    if (name == "")
                    {
                        Console.WriteLine("You must enter a name\n");
                        Greeting();
                        return;
                    }
                }
                Console.WriteLine("\nPlease enter a PIN to use with this account");
                String PIN = Console.ReadLine();

                if (PIN == "")
                {
                    Console.WriteLine("You must enter a PIN\n");
                    Greeting();
                    return;
                }

                Console.WriteLine("\nWhat type of account would you like to open, checking or savings?");
                String type = Console.ReadLine();

                if (type.Equals("checking", StringComparison.InvariantCultureIgnoreCase))
                {
                    myAccounts[index] = new Checking(100, index, name, PIN);
                    Console.WriteLine("\nBalances start at $100, and the annual interest rate is 5%");
                }
                else if (type.Equals("savings", StringComparison.InvariantCultureIgnoreCase))
                {
                    myAccounts[index] = new Savings(100, index, name, PIN);
                    Console.WriteLine("\nBalances start at $100, and the annual interest rate is 10%");
                }
                else
                {
                    Console.WriteLine("\nInvalid account type");
                    PopulateAcct();
                }
            }
            else
            {
                Console.WriteLine("\nSorry, all available accounts are full\n");
                Greeting();
            }
        }