Exemple #1
0
        }  //end MakeWithdrawal method

        /// <summary>
        /// Allows the Teller debit a certain account by entering the account number and the amount to be withdrawn.
        /// Requires: The account number is currently in the banks database.
        /// Requires: The amount to be withdrawn is not negative.
        /// Requires: The account is a current account.
        /// Requires: The amount to be withdrawn is greater than the present amount.
        /// Requires: The account balance value is positive.
        /// </summary>
        /// <param name="accountNumber">The account number identifying the account to withdraw from.</param>
        /// <param name="debitAmount">Amount to be withdrawn</param>
        /// <exception cref="InvalidDataException">Thrown when the account number does not exist in the database</exception>
        /// <exception cref="InvalidOperationException">Thrown when the account is not a current account.</exception>
        /// <exception cref="ArgumentException">Thrown when the Amount to be withdrawn is negative,
        /// Thrown when the debit amount is less than the present account balance,
        /// Thrown when the account balance is less than zero.
        /// </exception>
        public virtual void MakeOverdraftWithdrawal(string accountNumber, double debitAmount)
        {
            Contract.Requires <ArgumentException>(GetAccountBalance(accountNumber) > 0, "You already owe the bank");
            Contract.Requires <InvalidDataException>(AccountExists(accountNumber), "Please check input. Account Number does not exist");
            Contract.Requires <InvalidOperationException>(GetAccountType(accountNumber).ToLower().Equals("current"),
                                                          "Transaction valid for current accounts only.");
            Contract.Requires <ArgumentException>(GetAccountBalance(accountNumber) < debitAmount,
                                                  "Can withdraw normally, no need for overdraft");
            Contract.Requires <ArgumentException>(debitAmount > 0, "Cannot withdraw a negative balance");
            Console.WriteLine("");
            Console.WriteLine("ACCOUNT INFO");
            Console.WriteLine("");
            string accountName = GetAccountName(accountNumber);

            Console.WriteLine("Account Name: " + accountName);
            string accountType = GetAccountType(accountNumber);

            Console.WriteLine("Account Type: " + accountType);
            Console.WriteLine("Account Number: " + accountNumber);
            Console.WriteLine("");

            double currentBalance = GetAccountBalance(accountNumber);

            Console.WriteLine("Previous Account Balance: " + getBalance(currentBalance));
            Account <CurrentAccount> currAcc = new Account <CurrentAccount>(accountName, accountNumber, currentBalance);

            CurrentAccount.overdraftWithdraw(currAcc, accountNumber, debitAmount);
            Console.WriteLine("New Account Balance: " + getBalance(GetAccountBalance(accountNumber)));
        }  //end MakeOverdraftWithdrawal method
Exemple #2
0
        } //end CreateAccount method

        /// <summary>
        /// Allows the Teller credit a certain account by entering the account number and the amount to be deposited.
        /// Requires: The account number is currently in the banks database.
        /// Requires: The amount to be deposited is not negative.
        /// </summary>
        /// <param name="accountNumber">The account number identifying the account to be deposited to.</param>
        /// <param name="creditAmount">Amount to be deposited.</param>
        /// <exception cref="InvalidDataException">Thrown when the account number does not exist in the database</exception>
        /// <exception cref="ArgumentException">Thrown when the Amount to be deposited is negative.</exception>
        public virtual void MakeDeposit(string accountNumber, double creditAmount)
        {
            Contract.Requires <InvalidDataException>(AccountExists(accountNumber), "Please check input. Account Number does not exist");
            Contract.Requires <ArgumentException>(creditAmount > 0, "Cannot deposit a negative balance");
            Console.WriteLine("");
            Console.WriteLine("ACCOUNT INFO");
            Console.WriteLine("");
            string accountName = GetAccountName(accountNumber);

            Console.WriteLine("Account Name: " + accountName);
            string accountType = GetAccountType(accountNumber);

            Console.WriteLine("Account Type: " + accountType);
            Console.WriteLine("Account Number: " + accountNumber);

            double currentBalance = GetAccountBalance(accountNumber);

            Console.WriteLine("Previous Account Balance: " + getBalance(currentBalance));
            Console.WriteLine("");
            switch (accountType.ToUpper())
            {
            case "SAVINGS":                   //credits the savings account
                Account savingsAcc = new SavingsAccount(accountName, accountNumber, currentBalance);
                savingsAcc.makeDeposit(accountNumber, creditAmount);
                break;

            case "CURRENT":                  //credits the current account
                Account currentAcc = new CurrentAccount(accountName, accountNumber, currentBalance);
                currentAcc.makeDeposit(accountNumber, creditAmount);
                break;
            }
            Console.WriteLine("New Account Balance: " + getBalance(GetAccountBalance(accountNumber)));
        }  //end MakeDeposit method
Exemple #3
0
        }  //end MakeDeposit method

        /// <summary>
        /// Allows the Teller debit a certain account by entering the account number and the amount to be withdrawn.
        /// Requires: The account number is currently in the banks database.
        /// Requires: The amount to be withdrawn is not negative.
        /// Requires: The amount to be withdrawn is not greater than the present account balance.
        /// </summary>
        /// <param name="accountNumber">The account number identifying the account to withdraw from.</param>
        /// <param name="debitAmount">Amount to be withdrawn.</param>
        /// <exception cref="InvalidDataException">Thrown when the account number does not exist in the database</exception>
        /// <exception cref="ArgumentException">Thrown when the Amount to be withdrawn is negative,
        /// Thrown when the debit amount is greater than the present account balance.
        /// </exception>
        public virtual void MakeWithdrawal(string accountNumber, double debitAmount)
        {
            Contract.Requires <InvalidDataException>(AccountExists(accountNumber), "Please check input. Account Number does not exist");
            Contract.Requires <ArgumentException>(debitAmount > 0, "Cannot withdraw a negative balance");
            Contract.Requires <ArgumentException>(GetAccountBalance(accountNumber) >= debitAmount,
                                                  "Cannot withdraw more than what you have, try using the overdraft");

            Console.WriteLine("");
            Console.WriteLine("ACCOUNT INFO");
            Console.WriteLine("");
            string accountName = GetAccountName(accountNumber);

            Console.WriteLine("Account Name: " + accountName);
            string accountType = GetAccountType(accountNumber);

            Console.WriteLine("Account Type: " + accountType);
            Console.WriteLine("Account Number: " + accountNumber);
            double currentBalance = GetAccountBalance(accountNumber);

            Console.WriteLine("Previous Account Balance: " + getBalance(currentBalance));
            Console.WriteLine("");



            switch (accountType.ToUpper())
            {
            case "SAVINGS":             //debits the savings account
                Account savingsAcc = new SavingsAccount(accountName, accountNumber, currentBalance);
                savingsAcc.makeWithdrawal(accountNumber, debitAmount);
                break;

            case "CURRENT":            //debits the savings account
                Account currentAcc = new CurrentAccount(accountName, accountNumber, currentBalance);
                currentAcc.makeWithdrawal(accountNumber, debitAmount);
                break;
            }
            Console.WriteLine("New Account Balance: " + getBalance(GetAccountBalance(accountNumber)));
        }  //end MakeWithdrawal method