Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. package edu.gmu.mut;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Calendar;
  5.  
  6. /**
  7. * Class Account represents an immutable customer account.
  8. */
  9. public class Account {
  10.  
  11. /** The date of last visit. */
  12. private Calendar dateOfLastVisit;
  13.  
  14. /** The name. */
  15. private String name;
  16.  
  17. /** The email. */
  18. private String email;
  19.  
  20. /** The date registered. */
  21. private Calendar dateRegistered;
  22.  
  23. /** The purchase history. */
  24. private ArrayList purchaseHistory;
  25.  
  26. /**
  27. * Gets the name.
  28. *
  29. * @return the name
  30. */
  31. public String getName() {
  32. return name;
  33. }
  34.  
  35. /**
  36. * Gets the email.
  37. *
  38. * @return the email
  39. */
  40. public String getEmail() {
  41. return email;
  42. }
  43.  
  44. /**
  45. * Gets the date registered.
  46. *
  47. * @return the date registered
  48. */
  49. public Calendar getDateRegistered() {
  50. return dateRegistered;
  51. }
  52.  
  53. /**
  54. * Gets the last visit date.
  55. *
  56. * @return the last visit date
  57. */
  58. public Calendar getLastVisitDate() {
  59. return dateOfLastVisit;
  60. }
  61.  
  62. /**
  63. * Gets the purchase history.
  64. *
  65. * @return the purchase history
  66. */
  67. public ArrayList getPurchaseHistory() {
  68. return purchaseHistory;
  69. }
  70.  
  71.  
  72. /**
  73. * Instantiates a new account.
  74. */
  75. private Account(){}
  76.  
  77. /**
  78. * Static factory method for creating new instances of Account objects
  79. *
  80. * @param name the name
  81. * @param email the email
  82. * @param dateRegistered the date registered
  83. * @param lastVisitDate the last visit date
  84. * @param purchases the purchases
  85. * @return the account
  86. */
  87. public static Account newInstance(String name, String email, Calendar dateRegistered, Calendar lastVisitDate, ArrayList<Purchase> purchases) {
  88. Account accnt = new Account();
  89. accnt.name = name;
  90. accnt.email = email;
  91. accnt.dateRegistered = dateRegistered;
  92. accnt.dateOfLastVisit = lastVisitDate;
  93. accnt.purchaseHistory = purchases;
  94. return accnt;
  95. }
  96.  
  97.  
  98. public String toString(){
  99. return this.name + ", " + this.email + ", " + this.getPurchaseHistory().toString();
  100.  
  101. }
  102.  
  103. }
Add Comment
Please, Sign In to add comment