Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: A 8*8 matrix and there is a weird game to be created...

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default A 8*8 matrix and there is a weird game to be created...

    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();


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: A 8*8 matrix and there is a weird game to be created...

    Continue developing the code. When you get errors that you are having problems with, post the code and your questions.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 7
    Last Post: November 18th, 2011, 02:47 PM
  2. VERY WEIRD OUTPUT... HELP PLEASE?
    By Medo Almasry in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 23rd, 2011, 10:02 AM
  3. Created simple game applet but wanting it to access a DSN on the server
    By hirsty in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 21st, 2011, 03:11 AM
  4. [SOLVED] Weird calendar.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 3rd, 2011, 08:19 PM
  5. Jsp weird problem
    By johniem in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 5th, 2010, 06:46 AM