我正在創建一個項目,我有3個不同的類創建對象CommissionEmployee,SalariedEmployee和HourlyEmployee。我需要將這些添加到主類中的數組列表中,但不確定哪裏出錯。從一個不同的類添加對象到Arraylist的問題 - java
公共類公司{
public String companyName;
public SalariedEmployee owner;
public ArrayList<SalariedEmployee> salariedEmployee;
public ArrayList<HourlyEmployee> hourlyEmployee;
public ArrayList<CommissionEmployee> commissionEmployee;
public Company (String companyName, SalariedEmployee owner){
this.companyName = companyName;
this.owner = owner;
}
public void addSalariedEmployee (SalariedEmployee SalariedEmployee){
salariedEmployee.add(SalariedEmployee); **
}
public void addHourlyEmployee (HourlyEmployee HourlyEmployee){
//HourlyEmployee = new HourlyEmployee (name, position, ratePerHour);
hourlyEmployee.add(HourlyEmployee);
}
public void addCommissionEmployee (CommissionEmployee CommissionEmployee){
//CommissionEmployee = new CommissionEmployee (,, ratePerItem);
commissionEmployee.add(CommissionEmployee);
}
** =這是在我的編輯告訴我,我會錯行了。 歡呼聲,任何幫助將不勝感激
對於您的方法中的每個形式參數名稱,請將第一個字母改爲小寫。 –