我正在尝试从employee类创建一个新雇员。当我在员工类中添加“ void”时,我可以创建该对象,但它会弄乱子类。我觉得有一些简单的事情要解决。
employee employee1 = new employee();
employee1.employee(name[i][0], monthlySalary[i][0]);
public class employee {
public String name = "";
public int monthlySalary = 0;
public double annualSalary = 0;
public employee(String name, int monthlySalary){
this.name = name;
this.monthlySalary = monthlySalary;
this.annualSalary = annualSalary();
}
}
public class Salesman extends employee {
private int annualSales = 0;
public Salesman(String name, int monthlySalary, int annualSales) {
super(name, monthlySalary);
this.annualSales = annualSales;
}