Exemple #1
0
 public savingsAccount(int accNumber, string accName, decimal startingBalance, customer cust)
 {
     this.associatedCustomers = new List <customer>();
     this.associatedCustomers.Add(cust);
     this.accountNumber     = accNumber;
     this.accountName       = accName;
     this.accountBalance    = startingBalance;
     this.fixedInterestRate = 1.5m;
 }
Exemple #2
0
        static void accountMaintenance(ref List <customer> allCustomers, ref List <account> allAccounts)
        {
            string yes            = "Yes";
            bool   stayInFunction = true;
            bool   firstOperation = true;

            while (stayInFunction)
            {
                if (firstOperation)
                {
                    Console.Clear();
                }

                Console.WriteLine("~ Account Maintenance ~\n\nWhat would you like to do?\n\n1 - Add new Account.\n2 - Close Account.\n3 - View Account Details.\n4 - Return to Main Menu.");

                string userInput = Console.ReadLine(); // get user selection
                int    caseCheck;

                Int32.TryParse(userInput, out caseCheck); // parse the selection

                switch (caseCheck)
                {
                case 1:
                {
                    bool     stillAdding = true;
                    string   name        = ""; // a name for the account e.g. "My Checking Account"
                    int      type        = 0;  // 1 for Checking, 2 for Savings
                    int      number      = 0;
                    decimal  startBal    = 0m;
                    customer Cust        = null;

                    while (stillAdding)
                    {
                        Console.Clear();

                        if (name == "")
                        {
                            bool acceptName = false;
                            Console.WriteLine("Please enter a Name for the Account: ");
                            string temp = Console.ReadLine();
                            Console.WriteLine("You entered: " + temp + "\n Accept Name? (Yes to Accept)");
                            string answer = Console.ReadLine();
                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                acceptName = true;
                            }

                            if (acceptName == true)
                            {
                                name = temp;
                            }
                        }

                        if (number == 0)
                        {
                            bool acceptNumber = false;
                            Console.WriteLine("Please enter Account Number: ");
                            string temp = Console.ReadLine();
                            Console.WriteLine("You entered: " + temp + "\n Accept Account Number? (Yes to Accept)");
                            string answer = Console.ReadLine();
                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                acceptNumber = true;
                            }

                            if (acceptNumber == true)
                            {
                                Int32.TryParse(temp, out number);
                            }
                        }

                        if (Cust == null)
                        {
                            Console.WriteLine("Please enter Customer Number: ");
                            string temp = Console.ReadLine();
                            Console.WriteLine("You entered: " + temp + "\n Accept Customer Number? (Yes to Accept)");
                            string answer = Console.ReadLine();
                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                int tnum;
                                Int32.TryParse(temp, out tnum);

                                foreach (customer alpha in allCustomers)
                                {
                                    if (alpha.customerNum == tnum)
                                    {
                                        Cust = alpha;
                                    }
                                }
                            }
                        }

                        if (startBal == 0m)
                        {
                            bool acceptBal = false;
                            Console.WriteLine("Please enter a Starting Balance: ");
                            string temp = Console.ReadLine();
                            Console.WriteLine("You entered: " + temp + "\nCorrect starting balance? (Yes to Accept)");
                            string answer = Console.ReadLine();
                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                acceptBal = true;
                            }

                            if (acceptBal == true)
                            {
                                decimal.TryParse(temp, out startBal);
                            }
                        }

                        if (type == 0)
                        {
                            bool acceptType = false;
                            Console.WriteLine("Please select the type of account (Enter: 1 for checking || 2 for savings): ");
                            string temp = Console.ReadLine();
                            if (temp == "1")
                            {
                                Console.WriteLine("You selected Checking account, is this correct? (Yes to Accept)");
                            }
                            else if (temp == "2")
                            {
                                Console.WriteLine("You selected Savings account, is this correct? (Yes to Accept)");
                            }
                            else
                            {
                                Console.WriteLine("Invalid option selected.");
                                break;
                            }
                            string answer = Console.ReadLine();
                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                acceptType = true;
                            }

                            if (acceptType == true)
                            {
                                Int32.TryParse(temp, out type);
                            }
                        }

                        if (name != "" && number != 0 && Cust != null && type != 0 && startBal != 0m)
                        {
                            addAccount(ref Cust, ref allAccounts, name, number, startBal, type);
                            Console.WriteLine("\n\nNew Account Created!\n\n");
                            stillAdding = false;
                        }
                    }

                    firstOperation = false;

                    break;
                }

                case 2:
                {
                    account         toBeClosed   = null;
                    bool            stillClosing = true;
                    int             number       = 0; //account number not customer number
                    List <customer> cust         = null;

                    while (stillClosing)
                    {
                        bool acceptNumber = false;

                        if (number == 0)
                        {
                            Console.WriteLine("Enter the Account Number for the account you wish to close.");
                            string temp = Console.ReadLine();
                            Console.WriteLine("You entered: " + temp + " accept account number? (Yes to Accept)");
                            string answer = Console.ReadLine();

                            if (string.Equals(answer, yes, StringComparison.OrdinalIgnoreCase))
                            {
                                acceptNumber = true;
                            }

                            if (acceptNumber == true)
                            {
                                Int32.TryParse(temp, out number);
                            }
                        }
                    }

                    foreach (account alpha in allAccounts)
                    {
                        if (alpha.accountNumber == number)
                        {
                            Console.WriteLine("We got here.");      //imhere
                            toBeClosed = alpha;
                            cust       = alpha.associatedCustomers;
                        }
                    }

                    Console.WriteLine("Account Number" + toBeClosed.accountNumber + " belongs to " + toBeClosed.associatedCustomers[0].name + " , Customer Number: " +
                                      toBeClosed.associatedCustomers[0].customerNum + "Proceed to Close? (Yes to Close Account)");
                    string answer2 = Console.ReadLine();
                    if (string.Equals(answer2, yes, StringComparison.OrdinalIgnoreCase))
                    {
                        closeAccount(ref cust, ref allAccounts, ref toBeClosed, ref allCustomers);     //closes the account
                        Console.WriteLine("\n\nAccount Closed Successfully.\n\n");
                        firstOperation = false;
                    }

                    break;
                }

                case 3:
                {
                    break;
                }

                case 4:
                {
                    stayInFunction = false;
                    break;
                }
                }
            }
        }
Exemple #3
0
 public checkingAccount(int accNumber, string accName, decimal startingBalance, customer cust)
 {
     this.associatedCustomers = new List <customer>();
     this.associatedCustomers.Add(cust);
     this.accountNumber  = accNumber;
     this.accountName    = accName;
     this.accountBalance = startingBalance;
 }
Exemple #4
0
 static bool closeAccount(ref customer cust, ref List <account> allAccounts, ref account toBeClosed)
 {
     return(true);
 }