I'm just getting into inheritance in my classes, and this is the first error I've had with it. Most of the code is working except for the constructor which throws the title in the errors section.
public class CellDoor extends CellPassage {
// TODO: instance variable(s)!
private String imageOpen,imageClosed;
private boolean locked, occupied;
private Item item;
// Create a new cell in the dungeon with the specified image.
// The CellDoor class represents an door that can be closed (locked) or open.
// NOTE: an open door is allowed to hold an item (e.g. a gem or key).
public CellDoor(String imageOpen, String imageClosed, boolean locked) {
this.imageOpen = imageOpen;
this.imageClosed = imageClosed;
this.locked = locked;
}
The cellPassage constructor is:
public CellPassage(String image) {
this.image = image;
}
Can someone give me some pointers on this?
You propably have a constructor in CellPassage
class that is not the default one. This means that Java cannot create your CellDoor
object by invoking the default super constructor. You have to add a super(...)
in the first row of your constructor body, where ... are the parameters of the constructor in CellPassage
class.
public CellDoor(String imageOpen, String imageClosed, boolean locked)
{
super(imageOpen);
this.imageOpen = imageOpen;
this.imageClosed = imageClosed;
this.locked = locked;
}
If you provide the code from the class CellPassage
, we will easily determine how exactly should you write your CellDoor
constructor