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

2014/4/3

I need help

NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
I new in programming and I have this homework and is killing me. any body can told me what I am doing wrong.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class HomeworkWorld here.
 * 
 * @author (me) 
 * @version (1)
 */
public class HomeworkWorld extends World
{
    /**
     * INSERT CODE BEOLW
     * Add two instance variables that are of type String[]
     *        one will be an array of images
     *        one will be an array of sounds
     *        DO NOT INCLUDE THE FILE SUFFIX - add that through code later
     *        
     *        Note - each image is 55x55
     */
           private String[] image = {"smiley1.png", "smiley2.png","smiley3.png","smiley4.png","smiley5.png"};;
           private String[] soundfile = {"hello.wav","happy.wav","crying.wav","ohno.wav","raspberry.wav"};
    
        
    /**
     * Constructor for objects of class HomeworkWorld.
     * 
     */
    public HomeworkWorld()
    {   
        
        // Create a new world with 400x100 cells with a cell size of 1x1 pixels.
        super(400, 100, 1); 
    }
        
        /**
         * INSERT CODE BELOW
         * Write a "for" loop
         *      It should loop 5 times  (you can either hard code 5 or use code)
         *      It should use the method addObject( Actor object, int x, int y) to add new Emoticons to your world.
         *      Note:  concatinate the ".png" for images  and ".wav" for the sounds
         *      
         *      Determine the x value using a mathematical calculation
         *      The y value can be either hard coded or calculated
         *      
         */ private void makeImages()  
                   {  
                       //make the Emoticon Images  
                       for(int i = 1; i<5; i++)  
                       {  
                            Emoticon emoticon = new Emoticon();  
                            addObject(newEmoticon(images[i]+".png",sound+".wav", 10*(i+60), 50));  
                                   }  
                }  
            }  
NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
press compile to test my codes and if give me the error : cannot find symbol-variable images I don't understand why please any help
erdelf erdelf

2014/4/3

#
you ask in line 51 for
images[i]
but you called the field image, so it should mean
image[i]
NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
thank now I have the problem with sound!
erdelf erdelf

2014/4/3

#
same problem in line 51 replace
sound
with
soundfile[i]
NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
thank for your help but I still having a error
NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
 for(int i = 1; i<5; i++)  
                       {  
                            Emoticon emoticon = new Emoticon();  
                            addObject(newEmoticon(image[i]+".png",soundfile[i]+".wav", 10*(i+60), 50));  
                                   }  
NINJAGO_KAi NINJAGO_KAi

2014/4/3

#
the method new emotion is supposed to be like that?
adam0314 adam0314

2014/4/4

#
I think we're in the same class. I'm struggling too!
danpost danpost

2014/4/4

#
What does your Emoticon class look like?
adam0314 adam0314

2014/4/4

#
@ danpost, I just posted my Emoticon class...it's the same assignment. http://www.greenfoot.org/topics/5919
You need to login to post a reply.