The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

This is my Gadget class.
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.
It's telling me that the super call must be the first statement but it already is! Please help

Re: BlueJ inheritance Issue. Please Help.

The error code is "call to super must be first statement in constructor". But i believe that it's already the first statement..
There is also another message:constructor Gadget in class Gadget cannot be applied to given types;
required: java.lang.String,double,int,java.lang.String
found: no arguments
reason: actual and formal argument lists differ in length

This is a big hurdle for me and i can't do anything else until i get this fixed..

Re: BlueJ inheritance Issue. Please Help.

I'm sorry but i can't understand. Can you please give me an example? Am i supposed to add something before the super call?
I probably look stupid right now but i really need to understand what my issue is.

Re: BlueJ inheritance Issue. Please Help.

There are several problems in your code but you need to learn to figure them out. The first hint is it doesn't compile which means it must have a compilation error message. What does it say? Paste the whole think in a post. Then we can help you interpret it.

The constructor takes the 4 arguments listed in the message but the code calling the constructor did not have any arguments.
Change the calling code so that it provides the required arguments: java.lang.String,double,int,java.lang.String

Re: BlueJ inheritance Issue. Please Help.

Ok. I am confused about something. You should have also gotten the error.

The constructor gadget() is undefined.

When you invoked super() in the subclass, Phone, the default gadget() constructor was not defined (unless you put it there later and didn't tell us about it). It is normally there by default UNLESS you add an explicit constructor. Then the default constructor goes away.

Re: BlueJ inheritance Issue. Please Help.

Originally Posted by jim829

Ok. I am confused about something. You should have also gotten the error.

The constructor gadget() is undefined.

When you invoked super() in the subclass, Phone, the default gadget() constructor was not defined (unless you put it there later and didn't tell us about it). It is normally there by default UNLESS you add an explicit constructor. Then the default constructor goes away.

Regards,
Jim

I have't added anything extra. This is my entire code for the Phone class