Actually I am a new learner of greenfoot and I have a trouble for my assignment
I have to make a Jungle board game
Here is the given codes
I have to create some chess and place them on the right place of the board for initialization.
So I tried to create the subclass, and create an animal lets say is a Rat
and I type the following codes in the GWorld
however, I cannot compile my program since this problem
How should I fix it? Many thanks!
Frankly speaking, I am a very new learner of greenfoot and I am not familar with the environment yet ........
public class Chess extends Actor
{
private int color;
private int rank;
private int real_rank;
public static final int COLOR_RED = 0;
public static final int COLOR_GREEN = 1;
public static final int RANK_RAT = 1;
public static final int RANK_CAT = 2;
public static final int RANK_DOG = 3;
public static final int RANK_WOLF = 4;
public static final int RANK_LEOPARD = 5;
public static final int RANK_TIGER = 6;
public static final int RANK_LION = 7;
public static final int REAL_RANK_LION = 6; //Lion and Tiger are equally strong.
public static final int RANK_ELEPHANT = 8;
public Chess(int c, int r)
{
color = c ;
rank = r;
updateImage();
}/**
* It simply loads the image based on the given rank and color, No need to modify.
*/
private void updateImage()
{
String prefix = "";
String postfix = "" ;
if ( color == COLOR_RED )
{
prefix = "red_";
}
else
{
prefix = "green_";
}
switch (rank)
{
case RANK_RAT: postfix = "rat"; break;
case RANK_CAT: postfix = "cat"; break;
case RANK_DOG: postfix = "dog"; break;
case RANK_WOLF: postfix = "wolf"; break;
case RANK_LEOPARD: postfix = "leopard"; break;
case RANK_TIGER: postfix = "tiger"; break;
case RANK_LION: postfix = "lion"; break;
default:
case RANK_ELEPHANT: postfix = "elephant"; break;
}
setImage( prefix + postfix + ".png" );
} private void initializeChess()
{
Rat greenrat = new greenRat;
GWorld.addOneObject(greenrat,0,0);
}
How should I fix it? Many thanks!
Frankly speaking, I am a very new learner of greenfoot and I am not familar with the environment yet ........
