Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. public class BankAccount {
  2.  
  3. // Params
  4. private String accountNumber;
  5. private double balance;
  6. private String customerName;
  7. private String emailAddress;
  8. private String phoneNumber;
  9.  
  10. // Constructors
  11. public BankAccount(){
  12. this("Default Account Number",0.0,"Default Name",
  13. "Default Email","Default Phone");
  14. }
  15. public BankAccount(String accountNumber,double balance,String customerName, String emailAddress, String phoneNumber){
  16. this.accountNumber = accountNumber;
  17. this.balance = balance;
  18. this.customerName = customerName;
  19. this.emailAddress = emailAddress;
  20. this.phoneNumber = phoneNumber;
  21. }
  22. public BankAccount(String customerName, String emailAddress, String phoneNumber) {
  23. this("Default Account Number",0.0,customerName,emailAddress,phoneNumber);
  24. this.customerName = customerName;
  25. this.emailAddress = emailAddress;
  26. this.phoneNumber = phoneNumber;
  27. }
  28.  
  29. // Getters
  30. public String getAccountNumber(){
  31. return accountNumber;
  32. }
  33. public double getBalance(){
  34. return balance;
  35. }
  36. public String getCustomerName(){
  37. return customerName;
  38. }
  39. public String getEmailAddress(){
  40. return emailAddress;
  41. }
  42. public String getPhoneNumber(){
  43. return phoneNumber;
  44. }
  45.  
  46. // Setters
  47. public void setAccountNumber(String accountNumber){
  48. this.accountNumber=accountNumber;
  49. }
  50. public void setBalance(double balance) {
  51. this.balance = balance;
  52. }
  53. public void setCustomerName(String customerName) {
  54. this.customerName = customerName;
  55. }
  56. public void setEmailAddress(String emailAddress) {
  57. this.emailAddress = emailAddress;
  58. }
  59. public void setPhoneNumber(String phoneNumber) {
  60. this.phoneNumber = phoneNumber;
  61. }
  62.  
  63. // Methods
  64. public void depositFunds(double deposit){
  65. if (deposit <0){
  66. System.out.println("Deposit must be greater than 0!");
  67. } else {
  68. this.balance+=deposit;
  69. System.out.println("New Balance is "+this.balance);
  70. }
  71. }
  72. public void withdrawFunds(double withdraw){
  73. if (withdraw>this.balance){
  74. System.out.println("Insufficient Funds, "+this.balance+" available but "+withdraw+" was requested!");
  75. } else {
  76. this.balance-=withdraw;
  77. System.out.println("New Balance is "+this.balance);
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement