Пример #1
0
        // 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
        // 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
        // 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;
                    }
                }
            }
        }