-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
60 lines (47 loc) · 1.51 KB
/
Employee.java
File metadata and controls
60 lines (47 loc) · 1.51 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
/*
* Employee.java
*/
/**
*
* @author Andy Kilgore
*/
public class Employee {
// Name your member variables as follows: firstName, lastName and monthlySalary
private String firstName;
private String lastName;
private double monthlySalary;
// Implement a three-parameter constructor that takes, in order: the first name, last name and monthly salary
public Employee(String firstName, String lastName, double monthlySalary) {
this.firstName = firstName;
this.lastName = lastName;
if (monthlySalary > 0) {
this.monthlySalary = monthlySalary;
}
}
// Your accessor methods should be named following the pattern getVariableName. e.g.: getFirstName
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public double getMonthlySalary() {
return monthlySalary;
}
// Your mutator methods should be named following the pattern setVariableName. e.g.: setFirstName
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setMonthlySalary(double monthlySalary) {
if (monthlySalary > 0 ) {
this.monthlySalary = monthlySalary;
}
}
}
// may not be needed
// if (this.monthlySalary < 0){
// monthlySalary = 0;
// }