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

2017/1/24

Need Help on Chapter 4 Crab Game

mkirkendall mkirkendall

2017/1/24

#
I am trying to program the crab game, but I came across two errors. The first being that the red underlined "import" says "class, interface, or enum expected" and the red underlines for "private GreenfootImageimage1;" and "private GreenfootImageimage2;" says "<identifier>expected. I would greatly appreciate the help if. import greenfoot.*; // (Actor, World, Greenfoot, and GreenfootImage) // comment ommited public class Crab extends Actor { private GreenfootImageimage1; private GreenfootImageimage2; /** * Create a crab and initialize two images V */ public Crab() { image1=new GreenfootImage("crab.png");image2=new GreenfootImage("crab2.png"); setImage(image1); } //methods omitted }
danpost danpost

2017/1/24

#
You need at least one space between 'GreenfootImage' and the image field names ('image1' and 'image2'). For the 'import' issue, you may have unmatched or out-of-place brackets in the class.
mkirkendall mkirkendall

2017/1/25

#
Thanks. I was able to fix the other problems besides the 'import' problem yesterday. I'll make the corrections and let you know the result.
mkirkendall mkirkendall

2017/1/31

#
So for the problem with 'import', I found that my mistake was that I rewrote 'import greenfoot', which was originally at the top of my code. I put the content in the code I showed you and I placed it under the original 'import greenfoot' and the code worked. Thanks again for your help.
You need to login to post a reply.