Hello,
I'm working on my coursework and the task is to create inheritance using "super"
Screenshot_2.png
This is the structure.
This is my Gadget class.public class Gadget { public String model; public double price; public int weight; public String size; public Gadget(String themodel, double theprice, int theweight, String thesize) { price = theprice; model = themodel; weight = theweight; size = thesize; } //Return The price of a gadget. public double getPrice() { return this.price; } //Return The model of a gadget. public String getModel() { return this.model; } //Return The weight of a gadget. public int getWeight() { return this.weight; } //Return The size of a gadget. public String getSize() { return this.size; } }
For my Phone class i have this task:
The Mobile class is a subclass of the Gadget class and has just one attribute, which corresponds to the (whole) number of minutes of calling credit remaining. The attribute is initialized in the constructor by being assigned the value of one of the constructor's five parameters and it has a corresponding accessor method. The other parameters of the constructor represent the model the price, the weight and the size of the mobile phone and these four values are passed to the constructor of the Gadget class.
This is my Phone class and the same error i keep getting. I've checked my code 1000 times and it look 100% correct. I just can not understand why the "super" function doesn't want to work for me. I reinstalled BlueJ but it's still the same. Please i need your help because i can't even begin the task with the most basic function.public class Phone extends Gadget { private int credits; private int balance; public void Gadget(String themodel, double theprice, int theweight, String thesize) { super(); credits = theCredits; } }
It's telling me that the super call must be the first statement but it already is! Please help