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 7554177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:16:08+00:00 2026-05-30T11:16:08+00:00

My friend is making a minesweeper clone and he asked me to help with

  • 0

My friend is making a minesweeper clone and he asked me to help with the part where when you click on a non-mine/non-number ‘blank’ square it reveals all adjacent blanks. The following is the code I wrote. I can’t figure out why it never resolves.

My base case should be when the for loops completely execute and the if statement never returns true.

Is there something I’m missing?

This is in java, by the way. Also, I told him the whole slew of button state changing should be assigned to a method :p

public void revealAdjacentNulls(int r, int c)
{
    int ir, ic;

    //literal edge cases :P

    int rmax = (r == 15) ? r : r + 1;
    int cmax = (c == 15) ? c : c + 1;

    //check all spaces around button at r,c

    for(ir = (r==0) ? 0 : r-1; ir <= rmax; ir++){

        for (ic = (c==0) ? 0 : c-1; ic <= cmax; ic++){

            //if any are blank and uncovered, reveal them, then check again around the blanks

            if (buttons[ir][ic].value == 0 && buttons[ir][ic].isCovered == false)
            {
                buttons[ir][ic].setEnabled(false);  //number uncovered
                buttons[ir][ic].setBackground(Color.blue);
                buttons[ir][ic].setText(Character.toString(buttons[ir][ic].value));
                buttons[ir][ic].isCovered = false;
                revealAdjacentNulls(ir, ic);
            }
        }
    }

}
  • 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-05-30T11:16:09+00:00Added an answer on May 30, 2026 at 11:16 am

    Well for one thing, it will always keep recursing for revealAdjacentNulls(r, c). Your condition is that isCovered must be false – but then you’re setting isCovered to false as well. Did you mean to write:

    buttons[ir][ic].isCovered = true;
    

    ? Or possibly your check should be:

    if (buttons[ir][ic].value == 0 && buttons[ir][ic].isCovered)
    

    (It depends on what you mean by “is covered”.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A friend of mine was asked, during a job interview, to write a program
A friend asked me for help on building a query that would show how
A friend of mine is making the jump from graphic designer to game developer,
A friend of mine is making a trivia game in C++, and I am
Hi im making a small site to help me and friends learn languages. Typical
A friend of mine has inherited an old Joomla 1.0.x site, that amongst other
My friend is making a website. Some of the pages display gif image files
I'm making a website for a designer friend, he can design stuff quite well
A friend of mine and I are looking to start a project looking into
A friend has asked me this, and I couldn't answer. He asked: I am

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.