Please help me with this simple code. The instructions are in the /** areas
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import java.lang.Object;
/**
* Write a description of class HomeworkWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
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 smileImages = { "smiley1", "smiley2", "smiley3", "smiley4", "smiley5" };
private String smileSounds = { "crying", "happy", "hello", "ohno", "raspberry" };
/**
* 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);
makeImages();
}
/**
* 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 white keys
for(int i = 0; i < smileImages.length; i++) {
Image image = new Image(smileImages, smileSounds+".wav", "IMAGE.png", "IMAGE-down.png");
addObject(image, 54 + (i*63), 140);
}
}
}
