Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7867383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:42:03+00:00 2026-06-03T00:42:03+00:00

Hey everybody I’m making a memory game where it’s a 4×4 board and you

  • 0

Hey everybody I’m making a memory game where it’s a 4×4 board and you click the tiles to reveal what’s underneath and you have to find the corresponding picture. I’m having trouble with the logic behind the mouse clicking and assigning them to a guess1 and guess2.

the Joption panel is how I’m testing to see if guess 1 and guess 2 register. Every time guess1 works fine, but I don’t know how to make the second guess work
Here is my attempt.

public void displayHit(Graphics g)
{
    //earlier on in the code mouseClicked provides the x and y indexes for the place where you click
    if (mouseClicked)
    {
        //method I coded to assign whereever you clicked on the 400x400 board to match the 4x4 array
        centerClick(x1,y1);
        guess1 = board[row][column];
        board[row][column] = board[x1][y1];
        guess1 = board[x1][y1];
        JOptionPane.showInputDialog(guess1 + "this is guess1");
        guess2 = -1;
        setColor(g);
        centerHit(xMouse, yMouse);
        g.fillOval(xMouse, yMouse, 40, 40);
        mouseClicked = false;

     if ((guess2 == -1) && (mouseClicked))
    {
        centerClick(x1,y1);
        guess2 = board[row][column];
        board[row][column] = board[x1][y1];
        guess2 = board[x1][y1];
        JOptionPane.showInputDialog(guess2 + "this is guess2");
    }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:42:04+00:00Added an answer on June 3, 2026 at 12:42 am

    Try this

     boolean guess2Flag;    
     if (mouseClicked)
    {
    
        if(!guess2Flag) 
        {
        centerClick(x1,y1);
        guess1 = board[row][column];
        board[row][column] = board[x1][y1];
        guess1 = board[x1][y1];
        JOptionPane.showInputDialog(guess1 + "this is guess1");
        guess2Flag = true;
        setColor(g);
        centerHit(xMouse, yMouse);
        g.fillOval(xMouse, yMouse, 40, 40);
        mouseClicked = false;
        }
    
        else if (guess2Flag)
        {
        centerClick(x1,y1);
        guess2 = board[row][column];
        board[row][column] = board[x1][y1];
        guess2 = board[x1][y1];
        JOptionPane.showInputDialog(guess2 + "this is guess2");
        guess2Flag = false;
        mouseClicked = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everybody, this is what I have going on. I have two text files.
Hey i have been looking around and i cant find a way to get
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
*Hey , I have finished developing my app In my iphone apps I have
hey guys having this really simple problem but cant seem to figure out have
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which
hey guys how to make these php html links codes possible. i have tried
Hey I have a menu(with JQuery) in a div on the left, with all
Hey everyone I have a basic search function here that allows me to search
Hey guys I am making a terminal application using Swing and Apache Commons. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.