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

2013/11/7

PLEASE HELP WITH CODE

cbufis cbufis

2013/11/7

#
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); } } }
danpost danpost

2013/11/7

#
I do not see where you create new Emoticon objects.
davmac davmac

2013/11/7

#
Since this is clearly homework, you are supposed to do it yourself. Just follow the instructions in the comments - they are pretty straightforward. If you don't understand something, you can ask specific questions here - at least make sure you say what error you are getting and on which line!
cbufis cbufis

2013/11/8

#
got it
You need to login to post a reply.