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 12 of 12

Thread: Minesweeper Game Need Help!

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Minesweeper Game Need Help!

    Below is my psuedo code. I need some serious help putting all of this together. Any critiques would be greatly appreciated!!!!!
    For now, I need this code written in main, and then eventually split into methods.
    public class MineSweeper {
     
    public static void main(String[] args) {
    //declare variables
    System.out.println("Find the empty squares and avoid the mines.");
    		//declare variables
    		int i;
    		int j=0;
           int t2=0;
     
            String[][] gameBoard = new String[9][9];
    * bool error
    */
     
    //load board
    //loadboard(board)
     
    int col, row;
    for (row= 0; row<9; row++)
    {
    for (col =0; col<9; col++)
    {
    board[row][col] = "*";
    }
    }
    //print board
    //int col, row;
    for (col=0; col<9; col++)
    //print " " + col + "|"
    for (row+0; row<9; row++)
    {
    //print row #
    for (col=0; col<9; col++)
    {
    //print " " + board[row][col] + "|"
    }
    //print "\n"
    }
    //end print board
     
    //turn
    while(t2<81){
    do{
    //print "enter column"
    //get column number
    //print "enter row"
    if board[row][col] !="*"
    error = true
    }
    while(error)
    board[row][col]="8";
    //endturn
    //int col, row;
    for(col=0; col<9: col++)
    //print " " + col +"|"
    for( row=0; row<9; row++)
    {
    //print row#
    for (col=0; col<9; col++)
    {
    //print " " + board [row][col] + "|";
    }
    //print "\n"
    }
    //print board
     
    //end print
    t2=turn(board);
    t2++;
    }
    }
     
    void loadboard(string board[][9])
    {
    int col, row:
    for (row=0;row<9;row++)
    {for (col+0; col<9;col++)
    {
    board[row][col]="*";
    }
    }
    } void print board (string board[][9])
    {
    int col, row;
    for (col=0;col<9; col++)
    //print " " + col + "|"
    for (row=0; row<9; row++)
    {
    //print row#
    for (col=0; col<9: col++)
    {
    //print " " + board [row][col]+ "|";
    }
    //print "\n"
    }
    }
     
    int turn ( string board){
    bool error
    do{
    //print "enter column"
    //get column number
    //print "enter row"
    if board[row][col] != "*"
    error = true
    }
    while (error)
    board [row][col]="8";
    }
     
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Minesweeper Game Need Help!

    Do you have any specific questions about the problems you are having?

    BTW The code needs formatting. Too many statements are not indented to show logic nesting. All statements should not start in the first column.

    Also posted at: http://www.java-forums.org/new-java/...need-help.html
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    Program Description:

    Create the first part of your MineSweep Game for Java. You will create the following parts for your game. You will write all your code in main:

    Game Description - this will describe how to play the game.

    Display Board - this will show the "mine field" (mines are hidden from player's view)

    Get Input - this method will read in a player's move

    PSUEDO CODE:

    //main method

    // declare the board array [9][9]
    // initialize the array with a special character using two for loops
    // write the code to Describe the Game - wait for user to hit enter
    // clear the screen
    // write the code to Display the Board - use two for loops
    // write the code to get the row and column from the user - after user enters column clear the screen
    // change the row and column of that element in the array
    // Display the Board Again (copy code used to Display Board from above)

    See sample output.

    At this point your game has no real functionality.
    Program Constraints:

    All code must be written in main. (10 pts)
    You must use a 2D Array and initialize it using two for loops ( one for loop embedded in another). (20 pts)
    When you display the board you must have row and column headings (see sample output).(10 pts)
    The game description will give a description of how the game is to be played (15 pts).
    When you read in the row and column of the players move make sure that you Do Not allow erroneous values. (15 pts)
    Use proper spelling and formatting for game (must look professional) (20 pts).
    Make sure you clear the screen as indicated in the psuedo code. (10pts)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Minesweeper Game Need Help!

    That looks like the assignment/program requirements.
    What specific questions do you have about designing and writing the program?

    Make a list of what needs to be done and start with the first item in the list.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    I don't understand bool error or if I need to declare what it returns

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Minesweeper Game Need Help!

    I've never heard of "bool error"? Is bool short for boolean? Even then boolean error doesn't mean anything to me.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    arrgghh, this class is so difficult
    I sat down with the college tutor and this is the code he came up with. He ran out of time helping me, but I don't understand anything because it's such an advanced code

  8. #8
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    Java Code:
    public class MineSweeper
    {
     public static void main(String[] args) 
     {
      //Game Description (Part 1)
      System.out.println("Find the empty squares and avoid the mines.");
      System.out.println();
     
      //declare variables
      int row=0;
      int col=0;
     
     
            String[][] gameBoard = new String[9][9];
     
            System.out.println("******  MINESWEEPER ******");
            System.out.println("----------------------------");
     
            for ( row=0; row<gameBoard.length-1; row++)
     
       for ( col=0; col< gameBoard[row].length-1; col++)
       {
        gameBoard[row][col] = "*";
       }
     
             System.out.print(gameBoard[row][col] + " ");
     
     
             for (col=0; col<9; col++)
             System.out.println( " " + col + "|");
    			for (row=0; row<9; row++)
    			{
    				System.out.println(" " + row + "|");
    				for (col=0; col<9; col++)
    				{
    			System.out.println( " " + gameBoard[row][col] + "|");
    				}
    				System.out.println("\n");
     
     
     }}}

    I need help actually displaying the game board. I've decided to chunk it and work from the beginning. Any Suggestions would be greatly appreciated!! Thank you!

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Minesweeper Game Need Help!

    This is a waste of effort if you are also working on another forum.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    No it's not, I'm trying to get input from other people too :/ I'm just trying to get my homework done

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Minesweeper Game Need Help!

    It's a waste of my time if there are others writing the same things as I would.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Minesweeper Game Need Help!

    no one is writing....

Similar Threads

  1. [SOLVED] Minesweeper Recursion Method Help
    By beansnbacon in forum What's Wrong With My Code?
    Replies: 12
    Last Post: April 4th, 2013, 07:15 AM
  2. GUI minesweeper help
    By naitomea4664 in forum AWT / Java Swing
    Replies: 1
    Last Post: February 23rd, 2012, 08:33 PM
  3. Can anyone please help me with this java code for minesweeper game!
    By Mahela in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 25th, 2011, 08:10 AM
  4. Minesweeper java problem
    By bluez_exe in forum Paid Java Projects
    Replies: 1
    Last Post: March 3rd, 2010, 08:55 PM
  5. [SOLVED] minesweeper game creation problem
    By kaylors in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 27th, 2009, 04:06 PM

Tags for this Thread