先上示例代码:
(1)抽象类Person
public abstract class Person {
private String name;
public Person(String name) {
this.name = name;
}
public abstract String getDescription();
public String getName() {
return this.name;
}
}
(2)子类Employee
import java.time.*;
public class Employee extends Person{
private double salary;
private LocalDate hireDay;
public Employee(String name, double salary, int year, int month, int day) {
super(name);
this.salary = salary;
hireDay = LocalDate.of(year, month, day);
}
public double getSalary() {
return this.salary;
}
public LocalDate getHireDay() {
return this.hireDay;
}
public String getDescription() {
return String.format("an employee with salary of $%.2f", this.salary);
}
public void raiseSalary(double byPercent) {
double raise = t