コード例 #1
0
ファイル: BankSystem.cs プロジェクト: agpuser/banksystem
        // Collects and sets monthly deposit amount for Type 2 account
        private void SetMonthlyDeposit()
        {
            uint  validID     = 0;
            float validAmount = 0.0f;
            bool  done        = false;

            while (!done)
            {
                validID     = GetValidandExistingID("Enter Account ID: ");
                validAmount = MenuSystem.GetValidAmount("Enter Monthly Deposit: ");
                Console.WriteLine("Press “s” or “S” if you want to submit ");
                Console.Write("Press any other keys if you want to cancel ");
                string input = Console.ReadLine();
                if (input == "s" || input == "S")
                {
                    if (_Accounts[(int)validID - 1].GetType() == typeof(Type2Account)) // must be Type 2 account
                    {
                        Type2Account temp = (Type2Account)_Accounts[(int)validID - 1];
                        temp.MonthlyDeposit         = validAmount;
                        _Accounts[(int)validID - 1] = temp;
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("You must select a Type 2 account to set a monthly deposit. Please re-enter account ID.");
                    }
                }
            }
        }
コード例 #2
0
ファイル: BankSystem.cs プロジェクト: agpuser/banksystem
        // Collects and deposits amount into given account
        private void DepositFunds()
        {
            uint  validID     = 0;
            float validAmount = 0.0f;
            bool  done        = false;

            while (!done)
            {
                validID     = GetValidandExistingID("Enter Account ID: ");
                validAmount = MenuSystem.GetValidAmount();
                Console.WriteLine("Press “s” or “S” if you want to submit ");
                Console.Write("Press any other keys if you want to cancel ");
                string input = Console.ReadLine();
                if (input == "s" || input == "S")
                {
                    if (ValidDeposit((int)validID - 1, validAmount))
                    {
                        Type1Account temp = (Type1Account)_Accounts[(int)validID - 1]; // cast to Type 1 account
                        temp.Deposit(validAmount);
                        _Accounts[(int)validID - 1] = temp;
                        done = true;
                    }
                }
            }
        }
コード例 #3
0
ファイル: BankSystem.cs プロジェクト: agpuser/banksystem
        // Executes main program loop until a non menu value is entered
        public void RunSystem()
        {
            bool   ProgramDone = false;
            string Input       = "";

            _Customers = _FileIO.LoadCustomerData();
            _Accounts  = _FileIO.LoadAccountData(_Customers);
            while (!ProgramDone)
            {
                MenuSystem.DisplayMainMenu();
                Input       = Console.ReadLine();
                ProgramDone = HandleOption(Input);
            }
            _FileIO.SaveCustomerData(_Customers);
            _FileIO.SaveAccountData(_Accounts);
        }
コード例 #4
0
ファイル: BankSystem.cs プロジェクト: agpuser/banksystem
        // Collect and validate account ID and amount to enable a transfer
        private void TransferFunds()
        {
            uint  validSourceID = 0, validDestID = 0;
            float validAmount = 0.0f;
            bool  done        = false;

            while (!done)
            {
                validSourceID = GetValidandExistingID("Enter Source Account ID: ");
                validDestID   = GetValidandExistingID("Enter Destination Account ID: ");
                validAmount   = MenuSystem.GetValidAmount();
                Console.WriteLine("Press “s” or “S” if you want to submit ");
                Console.Write("Press any other keys if you want to cancel ");
                string input = Console.ReadLine();
                if (input == "s" || input == "S")
                {
                    if (ValidTransfer((int)validSourceID - 1, (int)validDestID - 1, validAmount)) // Okay to transfer
                    {
                        _Accounts[(int)validSourceID - 1].Transfer(_Accounts[(int)validDestID - 1], validAmount);
                        done = true;
                    }
                }
            }
        }
コード例 #5
0
ファイル: BankSystem.cs プロジェクト: agpuser/banksystem
        // Collects and validates input to create a new Customer
        private void CreateCustomer()
        {
            string   inFirst = "", inLast = "", inAddress = "", inDoB = "", inContact = "", inEmail = "";
            DateTime DoB = DateTime.Now;
            bool     done = false, DoBValid = false, contactOkay = false;

            while (!done)
            {
                inFirst = MenuSystem.GetCustomerElement("Enter First Name: ", "a first name");
                inLast  = MenuSystem.GetCustomerElement("Enter Last Name: ", "a last name");
                if (FoundCustomer(inFirst, inLast)) // if Customer name (First & Last) already in system
                {
                    Console.WriteLine("Customer name already exists. Please re-enter.");
                    continue;
                }
                inAddress = MenuSystem.GetCustomerElement("Enter Address: ", "an address");
                while (!DoBValid)
                {
                    Console.Write("Enter Date of birth (DOB) eg.\"dd/MM/yyyy\": ");
                    inDoB = Console.ReadLine();
                    try
                    {
                        DoB = DateTime.ParseExact(inDoB, "d/M/yyyy",
                                                  System.Globalization.CultureInfo.InvariantCulture);
                        DoBValid = true;
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid date of birth entered. Please re-enter.");
                    }
                    if (DoBValid)
                    {
                        if (!Customer.DoBValid(DoB.Year)) // Verify that customer is at least 16 years old
                        {
                            Console.WriteLine("Customer cannot be less than 16 years of age. Please re-enter.");
                            DoBValid = false;
                        }
                    }
                }
                while (!contactOkay)
                {
                    Console.Write("Enter Contact (optional - press Enter for blank): ");
                    inContact = Console.ReadLine();
                    if (inContact.Length != 10 && inContact != "") // Validate contact is zero or 10 characters long
                    {
                        Console.WriteLine("Contact must be exactly 10 characters long or blank. Please re-enter.");
                    }
                    else
                    {
                        contactOkay = true;
                    }
                }
                Console.Write("Enter Email (optional - press Enter for blank): ");
                inEmail = Console.ReadLine();
                Console.WriteLine("Press “s” or “S” if you want to submit");
                Console.Write("Press any other keys if you want to cancel: ");
                string menuInput = Console.ReadLine();
                if (menuInput == "S" || menuInput == "s")
                {
                    Customer cust = new Customer(inFirst, inLast, inAddress, DoB, inContact, inEmail);
                    _Customers.Add(cust); // Add new customer to system
                }
                done = true;
            }
        }