import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Emoticon here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Emoticon extends Actor
{
/**
*INSERT CODE BELOW
* Create two instance varaibles of type String
* one named sound
* one named image
*/
private String sound;
private String image;
private String[] images ={"smiley1","smiley2","smiley3","smiley4","smiley5"};
private String[] sounds = {"hello","happy","crying","ohno","raspberry"};
/**
* INSERT CODE BELOW
* Write a construtor method
* The method should have two parameters
* type: String name: newImage
* type: String name: newSound
*
* The method should
* 1. set the instance variable image to the value passed by the corresponding parameter
* 2. set the instance variable sound to the value passed by the corresponding parameter
*
* 3. Use the method setImage( java.lang.String filename ) to set the image.
*
*/
public Emoticon(String newImage, String newSound)
{
image=newImage;
sound=newSound;
setImage(image);
}
/**
* play a sound when the mouse is clicked in the emotion image
*/
public void act()
{
// When the mouse is click on this object, play the sound.
if(Greenfoot.mouseClicked(this))
{
/**
* INSERT CODE BELOW
* Use the method Greenfoot.playSound( java.lang.String filename ) to play the sound
*
*/
Greenfoot.playSound(sound);
}
}
}

