forked from Santoshrt999/Java-Abstract-Class-and-Interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalesAssociate.java
More file actions
102 lines (93 loc) · 3.22 KB
/
SalesAssociate.java
File metadata and controls
102 lines (93 loc) · 3.22 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package store;
/**
* This is the SalesAssociate class file extends AbstractStoreEmployee class
* file.
*
* @author Goteti Santosh Ravi Teja
*/
public class SalesAssociate extends AbstractStoreEmployee {
private final double salesRate;
/**
* This is a argument constructor which Initializes variable salesRate and
* need to call its super class to initialize other variables
*
* @param salesRate - The parameter Percentage of sales done by a
* SalesAssociate is passed.
* @param numberOfHoursWorked - The parameter Number of hours worked is
* passed.
* @param hourlyRate - The parameter Hourly Rate is passed.
* @param storeDetails - The parameter Details of the Store is passed.
* @param associateName - The parameter Name of the Sales Associate is
* passed.
* @param basePay - The parameter Base pay is passed.
*/
public SalesAssociate(double salesRate, double numberOfHoursWorked, double hourlyRate,
String storeDetails, String associateName, double basePay) {
super(numberOfHoursWorked, hourlyRate, storeDetails, basePay, associateName);
this.salesRate = salesRate;
}
/**
* Returns the total commission of the Sales Associate in dollars.
*
* @return - This method returns the commission in dollars.
*/
@Override
public double calculateCommission() {
if (getSalesRate() > 30) {
return super.getBasePay() * COMMISSION_RATE;
} else {
return 0.0;
}
}
/**
* Returns calculated Pay of the Sales Associate. The calculated pay is the
* sum of basePay, commission and the product of number of hours worked and
* hourly rate.
*
* @return - This method returns Payment of the Sales Associate.
*/
@Override
public double calculatePay() {
return super.getBasePay() + calculateCommission() +
(super.getNumberOfHoursWorked() * super.getHourlyRate());
}
/**
* Checks if the employee should be awarded with a promotion.
*
* @return - This method returns boolean the eligibility status for
* promotion for an employee.
*/
@Override
public boolean checkPromotionEligibility() {
if (calculatePay() > 25000.0) {
return true;
} else {
return false;
}
}
/**
* Percentage of sales done by a SalesAssociate.
*
* @return- This method returns double Percentage of sales done by a
* SalesAssociate.
*/
public double getSalesRate() {
return salesRate * 100;
}
/**
* Returns the String representation of Sales. Append Super Class toString()
* along with the Sales Rate.
*
* @return - This method returns a String representation of Sales and
* Employee details.
*/
@Override
public String toString() {
return super.toString() + "Sales Rate: " + getSalesRate() + "%";
}
}