Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- if amount <= (balance + overdraft)
- If (amount <= maxWithdraw) OR (maxWithdraw = 0)
- Subtract amount from balance
- else
- throw PolicyException(“Over Max. Withdrawal”)
- endIf
- else
- throw PolicyException(“Insufficient Funds”)
- EndIf
- return amount*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace atm_program
- {
- class Checking : Account
- {
- //Members
- private double overdraft;
- private double maxWithdrawal;
- //Constructors
- public double Overdraft
- {
- get { return overdraft; }
- set { overdraft = value; }
- }
- public double MaxWithdrawal
- {
- get { return maxWithdrawal; }
- set { maxWithdrawal = value; }
- }
- //Methods
- public Checking(long acctNumber) : base (acctNumber)
- {
- overdraft = 50.00;
- maxWithdrawal = balance;
- }
- public override double Withdrawal(double amount)
- {
- if (amount <= balance + overdraft)
- {
- if ((amount <= maxWithdrawal)||(maxWithdrawal == 0.00))
- {
- balance = balance-amount;
- }
- else
- {
- throw new PolicyException("Over Max Withdrawal.");
- //Console.WriteLine("Balance");
- }
- }
- else
- {
- throw new PolicyException("Insufficient Funds.");
- }
- return amount;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement