-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoyaltyCard.java
205 lines (188 loc) · 5.07 KB
/
LoyaltyCard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Represents a loyalty card for a fictional university
* bookshop.
*
*
*
* Amended to include address functionality for the card.
*
* @author Mateus Goncalves De Ouro
* @ 25/10/2018
*/
public class LoyaltyCard
{
private String title, firstName, lastName;
private LoyaltyCardAddress address;
private String cardNumber;
private int points;
/**
* Constructor for objects of class LoyaltyCard where they obtain
* a card without purchasing any book(s) at that point.
*
* The number of points / spend should be set to 0.
*
* @param theTitle The customer's title
* @param theFirstName The customer's first name
* @param theLastName The customer's last name
* @param theCardNumber The number for this card
* @param street The street
* @param town The town
* @param postcode The postcode
*/
public LoyaltyCard(String theTitle, String theFirstName,
String theLastName, String street,
String town, String postcode,
String theCardNumber)
{
title = theTitle;
firstName = theFirstName;
lastName = theLastName;
address = new LoyaltyCardAddress(street, town, postcode);
cardNumber = theCardNumber;
points = 0;
}
/**
* Constructor for objects of class Customer where they purchase
* a book(s) at the same time as they obtain their card.
*
* @param theTitle The customer's title
* @param theFirstName The customer's first name
* @param theLastName The customer's last name
* @param theCardNumber The number for this card
* @param street The street
* @param town The town
* @param postcode The postcode
* @param thePoints The number of points earned - could be zero.
*/
public LoyaltyCard(String theTitle, String theFirstName,
String theLastName, String street,
String town, String postcode,
String theCardNumber, int thePoints)
{
title = theTitle;
firstName = theFirstName;
lastName = theLastName;
address = new LoyaltyCardAddress(street, town, postcode);
cardNumber = theCardNumber;
points = thePoints;
}
// accessors
/**
* Get the Customer's title
* @return gives the customer's title
*/
public String getTitle()
{
return title;
}
/**
* Get the Customer's first name
*
* @return the Customer's first name
*/
public String getFirstName()
{
return firstName;
}
/**
* Get the Customer's last name
*
* @return the Customer's last name
*/
public String getLastName()
{
return lastName;
}
/**
* Return the Customer's address
*
* @return the Customer's address
*/
public String getAddress()
{
return address.getFullAddress();
}
/**
* Get the Customer's card Number
*
* @return the Customer's card number
*/
public String getCardNumber()
{
return cardNumber;
}
/**
* Get the number of points earned
*
* @param thePoints The number of points collected.
* @return the number of points available.
*/
public double getPoints()
{
return points;
}
/**
* Record a new title
*
* @param title the revised title
*/
public void setTitle(String newTitle)
{
title = newTitle;
}
/**
* Record a new firstName
*
* @param newFirstName the revised first name
*/
public void setFirstName(String newFirstName)
{
firstName = newFirstName;
}
/**
* Record a new last name
*
* @param newLastName the revised last name
*/
public void setLastName(String newLastName)
{
lastName = newLastName;
}
/**
* Record a new spend and add it to the current amount.
*
* @param theSpend the amount spent
*/
public void setRevisedPoints(int thePoints)
{
points = points + thePoints;
}
/**
* Change the Customer's address
*
* @param street the street
* @param town the town
* @param postcode the postcode
*/
public void setAddress(String street, String town, String postcode)
{
address.setFullAddress(street, town, postcode);
}
/**
* Print out Customer's address
*/
public void printAddress()
{
address.printAddress();
}
/**
* Output the Customer's details
*/
public void printCustomerDetails()
{
System.out.println(title + " " + firstName + " "
+ lastName + "\n" +getAddress()
+ "\n Card Number: " + cardNumber
+ "\n Points available: " + points);
}
} // end LoyaltyCard class