Here is a Good question that i need to get solved as soon as possible.
I have just started events and the first thing is under MOUSE events. So here is the question, I have to create a 8*8 matrix, then i have to click at a random position and generate a word say "Q".
Alright then wherever that Q is located i have to make the associated row,columns,diagonals filled with red color.
After that i have to insert 7 more such "Q" and if i am succesfull in inserting 8 such Q i have to print game completed, if not game failed. I am told that there are 8 special locations by which we can achieve all this .
Can someone help? A complete code would be appreciated, I had started like this..
import java.awt.*;
import java.awt.event.*;
class A extends Frame implements MouseListener
{
int i,j,x,y;
int a[][]=new int[8][8];
Graphics g;
public void paint (Graphics g)
{
g.drawRect(300,300,300,300);
g.drawLine(400,300,400,600);
g.drawLine(500,300,500,600);
g.drawLine(300,400,600,400);
g.drawLine(300,500,600,500);
}
A()
{
addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
{
g=getGraphics();
x=me.getX();
y=me.getY();