r/javahelp • u/Saivy__4 • Feb 07 '20
Need Help with Abstract Classes!
abstract class Employee {
private int id;
private String firstName;
private String lastName;
public Employee(int id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
abstract double calculatePay();
}
Employee class – This class has the following characteristics a. Must be abstract b. Three data fields i. id: int (greater than 0)
ii. firstName: String
iii. lastName: String
c. Only one constructor, namely a 3-arg constructor setting the above
d. Getters and Setters for the above
e. An abstract calculatePay method with no parameters that returns a double
f. Overrides the toString() method of Object making it abstract
Im not able to understand (F) part or last part. Any hints will be greatly appreciated.
Thank You
17
Upvotes
-1
u/desrtfx Out of Coffee error - System halted Feb 07 '20
Have you investigated about
.toString()?Check out
Object.toString()and method overriding- then you understand F.