Ted pottel
Ted pottel

Reputation: 6983

Trying to make a parent class

I have 2 classes, cPuzzlePieces and cShapes. cPuzzlePieces extends cShapes.

Right now I get 2 errors on cPuzzlePeaces.

The first error is on the first line of the def and says:

implacet super constructor cShapes is undefined for default constructor.

The second error on the first line of the construter says

constructor call must be the first staemnt

and it is on the first staement.

Here is my code:

public class cPuzzlePieces extends cShapes{ // first error message is here

    int mAmountOfShapes;
    Context InContext;

    void cPuzzlePieces(Context MyContext) throws IOException 
    {
        super( MyContext);  // SECOND ERROR MESSAGE IS HERE
        InContext=MyContext;
    }
}




public class cShapes 
{
    cShape[] MyShapes;
public int mAmountOfShapes=0;
boolean AnimationRunning=false;

cShapes(Context InContext) throws IOException
{

}

...
...
}

Upvotes: 0

Views: 46

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279990

This

void cPuzzlePieces(Context MyContext) throws IOException 

is a method, not a constructor.

Remove the void keyword. Add an appropriate access modifier (if need be). Also check for the IOException. Currently, nothing is throwing it.

Related


Java naming conventions state that class names should start with an uppercase alphanumeric character. Please follow that.

Upvotes: 3

Related Questions