Hi, I'm new with the java world..
I have a homework assignment for my java class due soon and I'm quite stuck in the middle of it.
I'm supposed to make an eight ball using GOval in the acm library and whenever I click on the black ball in the applet, the words (fortunes) need to be changed everytime. But another click after showing the fortune, it must come back and show me 8 again and another click will lead to another fortune and another will come back to 8.
public class EightBall extends GraphicsProgram
public static final int BALL_RADIUS = 100;
public static GObject obj;
private GLabel fortunes = new GLabel("");
public String fortune;
RandomGenerator rgen = new RandomGenerator();
public void run()
public void mouseClicked(MouseEvent e)
boolean startAtEight = false;
// obj = getElementAt(getX(), getY());
// while(obj != null)
public void createBall()
GOval ball = new GOval(BALL_RADIUS*2,BALL_RADIUS*2);
public void getFortune()
fortunes.setFont(new Font("Ariel", Font.BOLD, 15));
String  fortune = new String;
fortune = "8";
fortune = "Yes";
fortune = "No";
fortune = "Most Likely";
fortune = "Maybe";
fortune = "Make it work";
fortune = "Not going to happen";
This is what I got so far and I'm stuck in the middle of it..
This is the requirements:
Pick from a set of 6 fortunes choosing one randomly
In addition to the run method, you will make at least 3 other methods:
- One to create the eight ball
- One to pick a random fortune
- And a mouseClicked method that will change the fortune
The part that I'm stuck at right now is how to make the applet start at 8 in the beginning and it have to show fortune after a click then if i click another it will be back to 8, then another a fortune and so on.
If you could help me get this through, I would be very appreciate it because I have no idea how to get going from here.. I will be waiting for any reply from now on.
Thank you so much