同じ抽象クラスを実装している具体的なクラスのうち、デフォルトのコンストラクタしか使用できないというエラーが出ています。"抽象クラスで使用可能なデフォルトのコンストラクタがありません"
`
public abstract class Employee implements Payable
private String firstName;
private String lastName;
private String socialSecurityNumber;
private date birthdate;
// constructor
public Employee(String firstName, String lastName,
String social, date dob)
{
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = social;
//this.birthdate = getBirthdate();
// Birthdate(year, month, day);
birthdate = dob;
}
public class pieceWorker extends Employee // no default constructor available
{
private double wage; ``
private int pieces;
public void pieceWorker(String firstName, String lastName, String social,date dob, double wage, int pieces) // use some getters ?
{
super(firstName,lastName,social, dob);
setWage(wage);
setPieces(pieces);
this.wage = wage;
this.pieces = pieces;
}
あなたは、引数なしのコンストラクタを持たないクラスを拡張しているので、あなたが持つスーパーコンストラクタを呼び出す必要があります:あなたはあなたのコードを動作させるために次の操作を行うことができ
正しい引数( 'super(...);') – Rogue
pieceWorkerの前の 'void'を削除する必要があります。 –
@CarlMastrangeloは正しいですあなたの構文です!コンストラクタは戻り値の型を必要としません。彼らは常に独自のインスタンスを返します。 – Sagar