Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. /*
  2. * Program: bankprojectgroup3
  3. * This Account.java
  4. * Date:1/27/2016
  5. * Author: Nicholas Johnston, Tim Ryan, Brice Habets, Thomas Kweram
  6. * Purpose: To hold balances, the names of account holders, and savings checking
  7. and debt
  8. Possess methods for changing these values in response to the Menu.java class
  9. */
  10.  
  11. package bankprojectgroup3;
  12. //==========================================class body: ==========================
  13.  
  14.  
  15. public class Account {
  16. //=====Class member variables=====================================
  17. private double checking;
  18. private double savings;
  19. private double debt;
  20. private String name;
  21.  
  22. //==================Defualt constructor===========================
  23. public Account()
  24. {// This is the default value of the Account object
  25. this.checking = 0;
  26. this.savings =0;
  27. this.debt = 0;
  28. this.name = "If you are reading this, this is invalid";
  29.  
  30. }
  31. //=====================Parameterized contructor================
  32. public Account(double checking, double savings, double debt, String name)
  33. {
  34. this.checking = checking;
  35. this.savings = savings;
  36. this.debt = debt;
  37. this.name = name;
  38.  
  39. }
  40. //====================account methods===============================
  41. // =============allows user to choose which account to deposit in===
  42. public double deposit(int choice,double amount)
  43. { //This method adds money to an account, the value of choice chooses which
  44. //and the value of amount signifies how much
  45.  
  46. switch(choice)
  47. {
  48. case 1:
  49. //checking
  50. this.checking =this.checking + amount;
  51. return this.checking;
  52. case 2:
  53. //savings
  54. this.savings = this.savings + amount;
  55. return this.savings;
  56. case 3:
  57. //debt, the method is inverted and decreases the debt
  58. this.debt = this.debt - amount;
  59.  
  60. return this.debt;
  61. default:
  62. //Validator
  63. System.out.println("Error: There is something"
  64. + " wrong with the menu");
  65. break;
  66.  
  67. }
  68. return 0;
  69. }
  70. //=====allows user to choose which account to withdraw money from=======
  71. public double withdraw(int choice, double amount)
  72. {//removes money in the case of checking and savings
  73. //increases if called on the debt account
  74. switch(choice)
  75. {
  76. case 1:
  77. //checking
  78. this.checking = this.checking - amount;
  79. return this.checking;
  80. case 2:
  81. //savings
  82. this.savings = this.savings - amount;
  83. return this.savings;
  84. case 3:
  85. //debt
  86. this.debt = this.debt + amount;
  87. return this.debt;
  88. default:
  89. //Validator
  90. System.out.println("Error: There is something "
  91. + "wrong with the menu");
  92. break;
  93.  
  94. }
  95. return 0;
  96. }
  97. //============allows user to choose which account to view the balance of===
  98. public double viewAccount(int choice)
  99. {// this returns the value of an account for use by the menu object
  100. switch(choice)
  101. {
  102. case 1:
  103. //checking
  104.  
  105. return this.checking;
  106. case 2:
  107. //savings
  108. return this.savings;
  109. case 3:
  110. //debt
  111. return this.debt;
  112. default:
  113. //Validator
  114. //This should never be called
  115. System.out.println("Error: There is something "
  116. + "wrong with the menu");
  117. break;
  118.  
  119. }
  120. //this should never be returned
  121. return 0;
  122. }
  123. public String getAccountType(int selection)
  124. {//This returns the name of the account, it is used in the menu object to
  125. // tell the user which account the transaction has been aapplied too
  126. switch(selection)
  127. {
  128. case 1:
  129. {//checkings
  130. return "Checking";
  131.  
  132. }
  133. case 2:
  134. {//savings
  135. return "Savings";
  136. }
  137. case 3:
  138. {//Debt
  139. return "Debt";
  140. }
  141. default:
  142. {//This should never be chosen, the validator will ensure this
  143. return "Invalid choice";
  144. }
  145. }
  146.  
  147.  
  148.  
  149. }
  150.  
  151. //======================getter setter block========================
  152. //========================Checking=================================
  153.  
  154. public double getChecking() {
  155. return checking;
  156. }
  157.  
  158. public void setChecking(double checking) {
  159. this.checking = checking;
  160. }
  161. //=========================savings=======================================
  162.  
  163. public double getSavings() {
  164. return savings;
  165. }
  166.  
  167. public void setSavings(double savings) {
  168. this.savings = savings;
  169. }
  170. //======================Debt==============================================
  171.  
  172. public double getDebt() {
  173. return debt;
  174. }
  175.  
  176. public void setDebt(double debt) {
  177. this.debt = debt;
  178. }
  179. //===============Name====================================================
  180.  
  181. public String getName() {
  182. return name;
  183. }
  184.  
  185. public void setName(String name) {
  186. this.name = name;
  187. }
  188.  
  189. //============end of getter setter block====================================
  190.  
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement