this code is supposed to be a simple game. the computer picks a random circle in the 100 by 100 square of circles called the secret spot and when you hit a circle it says either go up go down go left or go right until you hit the secret spot. the game is supposed to pick a new secret spot every time after you win. i thought i had it or something near it and it compiles fine it just doesnt work when you actually try to use it.
if anyone knows what i'm doing wrong please help me out i'm getting ready to pull my hair out.

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class projectThree extends Applet implements MouseListener
{

    int clickedNum = 0;
    int x, y;
    int secret = (int)(Math.random() * 1000);
    public projectThree()
    {
        addMouseListener(this);
    }

    public void paint(Graphics g)
    {
        g.drawString("Find The Spot", 100,50);

        if (x - 25 <= secret && x + 25 >= secret && y - 25 <= secret && y +25 >= secret )
        {
            g.drawString("you win", 100,100);
        }
        else if ( x < 200 && x > 700 && y < 50 && y > 550)
        {
            g.drawString("click a circle", 100,100);
        }
        else if (y <= secret)
        {
            g.drawString("go down", 100,100);
        }

        else if (y >= secret)
        {
            g.drawString("go up", 100,100);
        }
        else if (x >= secret)
        {
            g.drawString("go right", 100,100);
        }
        else if (x <= secret)
        {
            g.drawString("go left", 100,100);
        }


        final int max=40;
        int num=0;
        while (num <= 10)
        {

            int col = 1;
            while ( col <=10)
            {
                g.setColor(Color.red);
                g.fillOval(200+num*50,col*50, max, max);


                col += 1;
                }

            num++;
        }


    }
    public void mouseEntered(MouseEvent me)
    {
    }
    public void mouseExited(MouseEvent me)
    {
    }
    public void mousePressed(MouseEvent me)
    {
    }
    public void mouseReleased(MouseEvent me)
    {
    }
    public void mouseClicked(MouseEvent me)
    {
        x = me.getX();
        y = me.getY();
        repaint();
    }
}

Please use code tags around posted code to make it more readable.
Since your class projectThree extends Applet an method public void init(){...} would be defined instead of a constructor. Hence the code line: public projectThree() should be replaced by public void init()
I have a question for your reference:
What is a spot? I think it is a point which should be defined by the coordinate: x and y. If the spot is a point defined by coordinate x and y, then the sensible judgement is the distance between the secret spot(point) and the point clicked by the mouse.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.