-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreferredCustomer.java
61 lines (52 loc) · 1.6 KB
/
PreferredCustomer.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
/**
* Program: PreferredCustomer
* Purpose: PreferredCustomer is a subclass of RetailCustomer and calculates the abstact method incentives()
* Date: 22 June 2021
* @author Yug Shah
*/
public class PreferredCustomer extends RetailCustomer {
private int cashbackRate;
/**
*
* @param firstName First Name of Customer
* @param lastName Last Name of Customer
* @param customerLevel The type of Customer
* @param totalPurchases The total amount of purchases by the Customer
* @param cashbackRate The percentage of cashback received by the Customer
*/
public PreferredCustomer(String firstName, String lastName, String customerLevel, double totalPurchases,
int cashbackRate) {
super(firstName, lastName, customerLevel, totalPurchases);
this.cashbackRate = cashbackRate;
}
/**
*
* @return Returns the CashbackRate
*/
public int getCashBackRate() {
return cashbackRate;
}
/**
*
* @param cashBack The percentage of cashback received by the Customer
*/
public void setCashBackRate(int cashBack) {
this.cashbackRate = cashBack;
}
/**
*
* @return Returns the incentives() calculates as per the description
*/
public double incentives() {
return (super.getTotalPurchases() * (double) (super.findDiscountRate() / 100.00)
+ (super.incentives() * (double) (this.cashbackRate / 100.00)));
}
/**
*
* @return Overrides toString() method from RetailCustomer SuperClass
*/
@Override
public String toString() {
return super.toString() + "\n" + "Cashback Rate: " + this.cashbackRate + "%";
}
}//end class