Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. import java.util.LinkedList;
  2.  
  3. public class Customer {
  4. private String name;
  5.  
  6. private int uID;
  7. private int pIN;
  8. private LinkedList<Account> accounts;
  9. public static int customerCount = 0;
  10.  
  11. public Customer(String name, int pIN) {
  12. this.name = name;
  13. this.uID = customerCount++;
  14. this.pIN = pIN;
  15. this.accounts = new LinkedList<Account>();
  16. }
  17.  
  18. public String getName() {
  19. return name;
  20. }
  21.  
  22. public void setName(String name) {
  23. this.name = name;
  24. }
  25.  
  26. public int getuID() {
  27. return uID;
  28. }
  29.  
  30. public void setuID(int uID) {
  31. this.uID = uID;
  32. }
  33.  
  34. public int getpIN() {
  35. return pIN;
  36. }
  37.  
  38. public void setpIN(int pIN) {
  39. this.pIN = pIN;
  40. }
  41.  
  42. public LinkedList<Account> getAccounts() {
  43. return accounts;
  44. }
  45.  
  46. public void setAccounts(LinkedList<Account> accounts) {
  47. this.accounts = accounts;
  48. }
  49.  
  50. public boolean changePIN(int newPIN, int oldPIN) {
  51. if(oldPIN == this.getpIN()) {
  52. this.setpIN(newPIN);
  53. return true;
  54. } else {
  55. return false;
  56. }
  57. }
  58.  
  59. public void showAccounts() {
  60. for(int i = 0; i < this.accounts.size(); i++) {
  61. System.out.println(accounts.get(i));
  62. }
  63. }
  64.  
  65. public void addAccount(Account x) {
  66. this.accounts.add(x);
  67. }
  68.  
  69. public Account findAccount(String type) {
  70. for(int i = 0; i < this.accounts.size(); i++) {
  71. if(type.equalsIgnoreCase(accounts.get(i).getType())) {
  72. return accounts.get(i);
  73. }
  74. }
  75. return null;
  76. }
  77.  
  78. public int getCustomerCount() {
  79. return customerCount;
  80. }
  81.  
  82. public void setCustomerCount(int customerCount) {
  83. Customer.customerCount = customerCount;
  84. }
  85. }
  86.  
  87. //By Jonathan Baird
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement