Exercise 10.49 Add a display that shows the current volume.
for exercise 10.49, you need to display the volume either in a vertical bar or a horizontal bar. This volume bar is for display volume only, and nothing should happen if you click on the bar, because it is not supposed to respond to user clicking on the bar. The lowest value is 0, and the highest value is 100. According to class GreenfootSound , its method getVolume() indicates that the volume is between 0 and 100. Alone with the bar, you also need to display the current volume level in numeric value, such as number 97 in the picture below. An example volume bar looks like this horizontal bar (you should ignore the dark background in these two pictures when you implement the volume bart in your homework.): , or this vertical bar:
I have a code made so far are following:
Please guys help me on this, ThaNK YOU..
If you guys need more code linked with it with other class and I have one. please respond it and help would be really appreciate..
Thank You Guys...
public class CurrentVolume extends Actor
{
private String message;
private int currentVolume;
public CurrentVolume()
{
this(0);
}
public CurrentVolume(int currentVolume)
{
message = "VOLUME: ";
//GreenfootImage image = new GreenfootImage("currentvol.png");
setImage(new GreenfootImage(message.length() * 20, 30));
//image.scale(200, 200);
GreenfootImage image = getImage();
this.currentVolume = currentVolume;
}
public void act()
{
updateImage();
}
public void setCurrentVolume(int newCurrentVolume){
this.currentVolume = newCurrentVolume;
updateImage();
}
private void updateImage(){
GreenfootImage image = getImage();
image.clear();
image.setFont(image.getFont().deriveFont(20f));
image.drawString(message + currentVolume,14,20);
}
}
