Hi guys! I am in need of some help with a school project for my Information CS class. I am working on a duck typing lab and can not seem to figure out how to do some of the starting features of the program. Below is my code. I need to know how to add the "livesleft" variable to the screen at the coordinate (250, 50). I was thinking about using "getWorld().addObject" or a print Statement, but can not seem to work around either of those ideas. Additionally, I need to ask the program if the person playing the game his the correct key (myKey), but I looked through my notes and can not find how to do so. There will probably be more questions to come(; . Thank you all in advance!!!
PS - I am working in Greenfoot using Java Compiler!
import greenfoot.*;
public class Duck extends SmoothMover
{
private int score = 0;
private int livesleft = 10;
double velocity = 0.0;
//Leave this myKey alone. Read it to see if you can understand
//how it generates a letter randomly, it is similar to an
//(int)(Math.random() * __ ) + ___ but this time I wanted a char.
private String myKey = "" + (char)(Math.random() * 26 + 'A');
public Duck()
{
//This is called a Constructor.
//The constructor is called the moment a Duck is built.
//Leave this section alone, it draws the Duck's letter/key on the Duck
GreenfootImage img = getImage();
img.setFont(new Font("VERDANA", true, false, 20));
img.drawString(myKey, 50, 80 );
}
public void act()
{
setLocation(getExactX(), getExactY()+velocity);
velocity+=0.1;
if(isTouching(Gator.class))
{
livesleft--;
System.out.print(livesleft); ??????HELP???????
Greenfoot.playSound("quack.mp3");
getWorld().removeObject(this);
if(livesleft==0)
{
Greenfoot.stop();
}
else if(myKey==????HELP????)
{
}
}
}
}

