This site requires JavaScript, please enable it in your browser!
Greenfoot back
steelparagon
steelparagon wrote ...

2014/5/8

I'm getting an error with my constructors

steelparagon steelparagon

2014/5/8

#
When I try to compile the Primary Class I get an error stating "constructor Enemy in Class Enemy cannot be applied to given types; required: boolean; found: no arguments; reason: actual and formal argument lists differ in length" Super Class
import greenfoot.*;


public class Enemy extends Character
{
int myHealth;
boolean facingLeft;
    
    public Enemy(boolean isLeft){
        facingLeft=isLeft;
    }
    public void act() 
    {
        // Add your action code here.
    }    
    public void move(){
        
    }
    public void flip(){
        
    }
    public int getHealth(){
        return myHealth;
    }
}
Subclass
import greenfoot.*; 


public class Primary extends Enemy
{
int myHealth;
boolean facingLeft;
int color;
    
    public Primary(boolean isLeft){
        Super(false);
    }
    public void act() 
    {
        // Add your action code here.
    }    
}
bourne bourne

2014/5/8

#
"Super" needs to be lowercased (line 11 of Primary)
super(false);
And you probably meant this:
super(isLeft);
You need to login to post a reply.