I have the following code:
public class Cockpit extends Seat {
private Seat seat;
public Cockpit(String location) {
super("Cockpit");
}
. . .
public class Seat {
private String location;
public Seat(String location) {
this.location = location;
}
public String getLocation() {
return location;
}
public String toString() {
return location;
}
. . .
You're not showing the code causing the error, but I suspect it looks something like this:
Cockpit cockpit = new Cockpit();
The problem that your Cockpit
constructor is expecting a String
argument, but you're not passing one in. Since the location
argument of Seat
is hardcoded in the Cockpit
constructor, you probably want to remove the parameter altogether:
public Cockpit() {
super("Cockpit");
}
Alternatively, you can pass the location
parameter into super()
and specify its value when you call the constructor:
public Cockpit(String location) {
super(location);
}
// ...
Cockpit cockpit = new Cockpit("Cockpit");