Example #1
0
        public void NewClient()
        {
            SecurityCode  = _random.Next(100, 999);
            DebitCard     = LongRandom(1000000000000000, 9999999999999999, _random);
            AccountNumber = LongRandom(100000000000, 999999999999, _random);
            Chequing      = new ChequingAccount(Balance);
            Saving        = new SavingAccount(Balance);

            //301,060,170,623
            //999999999999
        }
        private void btnChequingAccount_Click(object sender, EventArgs e)
        {
            //// create account with vaild values
            //ChequingAccount b1 = new ChequingAccount(123, 100, "Chequing Account", 5);
            ChequingAccount b1 = new ChequingAccount(123, 100M, "Chequing Account", 5M);

            //// test get accessors

            string Display = "Testing Get Accessors for Savings Account: \nClient Name: "
                             + b1.ClientName + "\nAccount Number: "
                             + b1.AccountNumber + "\nDate Open: " + b1.DateOpen + "\nBalance: "
                             + b1.Balance + "\nFee: " + b1.Fee;

            //// test set accessors - valid data

            b1.ClientName = "J Doe";
            b1.Fee        = 15M;

            Display += "\n\nTest Set Accessors: Name = J Doe, Fee = $15\nNew Name: "
                       + b1.ClientName + "\nNew Fee: " + b1.Fee;

            //// test set accessors - invalid data
            b1.ClientName = "";
            b1.Fee        = 5M;

            Display += "\n\nTest Set Accessors: Name = null, Fee = $5\nNew Name: " + b1.ClientName
                       + "\nNew Fee: " + b1.Fee;
            //// test ToString() method
            Display += "\n\nTostring():\n" + b1.ToString();

            //// test Deposit method
            decimal deposit = b1.Deposit(20m);

            Display += "\n\nDeposite $20, Deposit:" + deposit;
            deposit  = b1.Deposit(-30m);
            Display += "\nDepost -$30, Deposit: " + deposit +
                       "\nBalance: " + b1.Balance;

            //// test Withdraw method
            decimal withdraw = b1.Withdraw(20m);

            Display += "\n\nWithdraw $20,Withdraw: " + withdraw;
            withdraw = b1.Withdraw(-30m);
            Display += "\nWithdraw -$30, Withdraw: " + withdraw + "\nBalance: " + b1.Balance;

            //// test ApplyMonthlyFee method
            Display += "\n\nBalance Before Monthly Fee:" + b1.Balance;
            decimal monthlyFee = b1.ApplyMonthlyFee();

            Display += "\nFee Charged: " + monthlyFee +
                       "\nNew Balance: " + b1.Balance;
            MessageBox.Show(Display, BankAccount.BankName);
        }
Example #3
0
        static void Main(string[] args)
        {
            Account A1 = new SavingsAccount(5.00, .02);
            Account A2 = new ChequingAccount(5.00, .02);
            GlobalSavingsAccount A3 = new GlobalSavingsAccount(5.00, .02);

            string option;

            Console.WriteLine("You booted up the Personal Bank App!");
            do
            {
                Console.WriteLine("You accessed the General page:");

                Console.WriteLine(String.Format("A. Savings\nB. Checking\nC. Global Savings\nQ. Exit"));
                option = Console.ReadLine().ToUpper();

                switch (option)
                {
                case "A":
                    MenuS(A1);
                    break;

                case "B":
                    MenuC(A2);
                    break;

                case "C":
                    MenuGS(A3);
                    break;

                case "Q":
                    Environment.Exit(0);
                    break;

                default:
                    throw new InvalidOperationException("That's not what I'm looking for...");
                }
            }while(option != "Q");
        }
Example #4
0
 public Client()
 {
     Chequing = new ChequingAccount();
     Saving   = new SavingAccount();
 }
Example #5
0
        public static void ChequingMenu()
        {
            bool errmenu = true;

            do
            {
                try
                {
                    ChequingAccount chequing = new ChequingAccount(5, 1.00);
                    StringBuilder   sb       = new StringBuilder();
                    sb.Append("Chequing Menu\n");
                    sb.Append("A. Deposit\n");
                    sb.Append("B. Withdrawal\n");
                    sb.Append("C. Close + Report\n");
                    sb.Append("R. Return to Bank Menu\n");
                    Console.WriteLine(sb.ToString());
                    string sinput = Console.ReadLine().ToUpper();
                    switch (sinput)
                    {
                    case "A":
                        bool depositerror = true;
                        do
                        {
                            try
                            {
                                Console.WriteLine("Please enter the deposit amount:");
                                string deposit      = Console.ReadLine();
                                bool   validdeposit = Double.TryParse(deposit, out double depositvalue);

                                if (validdeposit)
                                {
                                    chequing.MakeDeposit(depositvalue);
                                }
                                else
                                {
                                    throw new NumberValueException("\"" + deposit + "\" is not a numeric value.");
                                }
                                depositerror = false;
                            }
                            catch (NumberValueException nex)
                            {
                                Console.WriteLine(nex.Message);
                                depositerror = true;
                            }
                        } while (depositerror);
                        break;

                    case "B":
                        bool withdrawalerror = true;
                        do
                        {
                            try
                            {
                                Console.WriteLine("Please enter the withdrawal amount:");
                                string withdrawal      = Console.ReadLine();
                                bool   validwithdrawal = Double.TryParse(withdrawal, out double withdrawalvalue);

                                if (validwithdrawal)
                                {
                                    chequing.MakeDeposit(withdrawalvalue);
                                }
                                else
                                {
                                    throw new NumberValueException("\"" + withdrawal + "\" is not a numeric value.");
                                }
                                withdrawalerror = false;
                            }
                            catch (NumberValueException nex)
                            {
                                Console.WriteLine(nex.Message);
                                withdrawalerror = true;
                            }
                        } while (withdrawalerror);
                        break;

                    case "C":
                        chequing.CloseAndReport();
                        break;

                    case "R":
                        MainMenu();
                        break;

                    default:
                        throw new IllegalSavingsMenuOptionException("Unkown option \"" + sinput + "\"");
                    }
                    errmenu = false;
                }
                catch (IllegalSavingsMenuOptionException ex)
                {
                    Console.WriteLine(ex.Message);
                    errmenu = true;
                }
            } while (errmenu);
        }