Advertisement
wis3_guy

Checking Class

Mar 7th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /*
  2. if amount <= (balance + overdraft)
  3. If (amount <= maxWithdraw) OR (maxWithdraw = 0)
  4. Subtract amount from balance
  5. else
  6. throw PolicyException(“Over Max. Withdrawal”)
  7. endIf
  8. else
  9. throw PolicyException(“Insufficient Funds”)
  10. EndIf
  11. return amount*/
  12.  
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17.  
  18. namespace atm_program
  19. {
  20. class Checking : Account
  21. {
  22. //Members
  23.  
  24. private double overdraft;
  25. private double maxWithdrawal;
  26.  
  27.  
  28. //Constructors
  29. public double Overdraft
  30. {
  31. get { return overdraft; }
  32. set { overdraft = value; }
  33. }
  34. public double MaxWithdrawal
  35. {
  36. get { return maxWithdrawal; }
  37. set { maxWithdrawal = value; }
  38. }
  39.  
  40. //Methods
  41.  
  42. public Checking(long acctNumber) : base (acctNumber)
  43. {
  44. overdraft = 50.00;
  45. maxWithdrawal = balance;
  46. }
  47.  
  48. public override double Withdrawal(double amount)
  49. {
  50. if (amount <= balance + overdraft)
  51. {
  52. if ((amount <= maxWithdrawal)||(maxWithdrawal == 0.00))
  53. {
  54. balance = balance-amount;
  55. }
  56. else
  57. {
  58. throw new PolicyException("Over Max Withdrawal.");
  59. //Console.WriteLine("Balance");
  60. }
  61. }
  62. else
  63. {
  64. throw new PolicyException("Insufficient Funds.");
  65. }
  66. return amount;
  67. }
  68.  
  69. }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement