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

2014/4/21

Pattern not work Help!

NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
I trying to great a patter but I don't get what the problem it is. any body can help please.
NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
super(400, 400, 1); 
         boolean blue = true;
         for (int x = 0; x < 8; x++)
{
        if (blue)  //alternate colors at the start of each column
                blue = false;
        else 
                blue = true;
                
        for (int y = 0; y < 8; y++)
        {
                if (blue)   // alternate colors
                {
                        ColorPatch blueSquare = new ColorPatch (0, 0, 255);
                        addObject (blueSquare, x*50 + 25, y*50 + 25);
                        blue = false;
                }
                else
                {
                        ColorPatch redSquare = new ColorPatch (255, 0, 0);                           
                        addObject (redSquare, x*50 + 25, y*50 + 25);
                        blue = true;

    }
  }
 }  
}
}
NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
give me the red highlight: constructor color patch in class color patch cannot be applied to given types; required;no arguments; found:int,int,int; reason;actual and format arguments list differ in length. what it this really mean? is any way where I can get a clear explanation what this really mean! :(
danpost danpost

2014/4/21

#
Are you getting any kind of pattern? if so, how is it not what you want? The code above appears to be sufficient; so, maybe a peak at the ColorPatch class might help.
NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
thank! you are right/ this is what I have for my color patch
public ColorPatch(int r, int g, int b) { GreenfootImage img = new GreenfootImage (50, 50); img.setColor (new java.awt.Color(r, g, b)); img.fill(); setImage (img); } }
and give me the highlight Illegal start expression
danpost danpost

2014/4/21

#
If you need help with that, post the class using the 'code' tags and show the entire error message.
NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
wooppss! I was missing a simple }
NINJAGO_KAi NINJAGO_KAi

2014/4/21

#
once again thank you danpost
You need to login to post a reply.