Results 1 to 19 of 19
  1. #1
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    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.
    Java Code:
    public class MineSweeper {
    
    	public static void main(String[] args) {
    System.out.println("Find the empty squares and avoid the mines.");
    //declare variables
    int i;
    int j;
    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";
    	}		
    					
    			}
    Last edited by Punkymedic; 11-13-2013 at 04:46 PM.

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,605
    Rep Power
    5

    Default Re: Minesweeper Game Need Help!

    So you dump unformatted "pseudo-code" here without any specific details or information or a particular question and you want help. Have you programmed in Java before? If not, this is a rather advanced program (assuming I know what you want to accomplish). First, read the FAQ and the guide for new members. Then learn Java syntax and place your Java code between code tags. And I happened to notice your turn method will never end.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    I am completely new at programming, this is supposed to be an intro to java class... The teacher doesn't even grade her own work, it's someone else at the college. I'm teaching myself and it's the most agonizing class ever. I'll edit the code tags. I'm new with forums too :/

  4. #4
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    This is the teacher's requirements
    I can make a simple calculator, but this should be for an advanced class :(

    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)

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,010
    Rep Power
    6

    Default Re: Minesweeper Game Need Help!

    Okay, but a forum is not a replacement for a tutor; the best you can get here is directions to articles and recommendations for books and help with SPECIFIC problems, not "how to build this program". You need to find tutoring help somewhere else if your teacher won't provide it. In my case it were my classmates.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,605
    Rep Power
    5

    Default Re: Minesweeper Game Need Help!

    Well, I'm sorry to hear about the troubles. Is this a required project? If you're new at Java has everything else been relatively easy until now? IMHO, you need to spend time learning the fundamentals piece meal and see how they work before you tackle a minesweeper game. For example, your signature is wrong in the turn method. The argument board is an array but you pass it as a String. There are other problems too. You need to at least eilminate the syntax errors before posting by trying to compile the program. And quite frankly, I would find it challenging and I'm pretty familiar with the language.

    For additional help on learning Java, check out the Oracle tutorials in my signature.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    I'll take directions and recommendations. This is a required program for the into to java class. We went from making a simple calculator to a whole program. I've been reading and watching youtube, tutorials suggested by the teacher. I'm not sure where to find a tutor in my town. I'm also taking this class online :(

  8. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: Minesweeper Game Need Help!

    "All code must be written in main."
    I mean, come on...why on earth would anyone want to put this down as a requirement?

    I can see the things we sometimes get here, where things have to involve arrays and not Collections, since they teach you potentially useful algorithms that sit underneath all this other stuff. But this?
    How on earth is this a useful thing?

    I despair sometimes.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,407
    Rep Power
    25

    Default Re: Minesweeper Game Need Help!

    Also posted at: Minesweeper Game Need Help!
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    I'm using eclipse and in the tutorials it told us to select String for the argument board. :/ I cannot wait until this semester is over. As long as I get 50% or higher on the assignments, I'll pass with a C.

  11. #11
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,010
    Rep Power
    6

    Default Re: Minesweeper Game Need Help!

    Quote Originally Posted by Tolls View Post
    "All code must be written in main."
    I mean, come on...why on earth would anyone want to put this down as a requirement?
    Its like the requirement itself is there to keep people from properly learning Java :/
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  12. #12
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    System.out.println("Find the empty squares and avoid the mines.");
    //declare variables
    int i;
    int j;
    int t2=0;

    String[][] gameBoard = new String[9][9];

    under this is a bool error. I don't fully understand boolean or if I need to set a value for it. Do I just need to set it to true?

  13. #13
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,605
    Rep Power
    5

    Default Re: Minesweeper Game Need Help!

    Quote Originally Posted by Punkymedic View Post
    under this is a bool error. I don't fully understand boolean or if I need to set a value for it.
    A boolean is a variable type which can either be true or false. All conditional expressions (e.g. a > 24) evaluate to boolean values.

    So
    Java Code:
    if (a > 24) {
    // do something
    }
    is equivalent to
    Java Code:
    boolean result = a > 24;
    if (result) {
    // do something
    }
    Do I just need to set it to true?
    I have no idea. It depends on how it is used in your program. If you don't understand it, how did you happen to choose to use it?

    You really need to talk to your teacher or classmates or read the tutorials I and others have suggested.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  14. #14
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    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

  15. #15
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    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

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,407
    Rep Power
    25

    Default Re: Minesweeper Game Need Help!

    Post the program's output and add some comments saying what is wrong with it and show what it should look like.
    If you don't understand my response, don't ignore it, ask a question.

  17. #17
    Punkymedic is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Minesweeper Game Need Help!

    This is what it is outputting:

    Find the empty squares and avoid the mines.

    ****** MINESWEEPER ******
    ----------------------------
    * 0|
    1|
    2|
    3|
    4|
    5|
    6|
    7|
    8|
    0|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    1|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    2|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    3|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    4|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    5|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    6|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    7|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|


    8|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    *|
    This is what it's supposed to look like
    MINESWEEPER
    0 | 1| 2| 3| 4| 5| 6| 7| 8
    0 * * * * * * * * *
    1 * * * * * * * * *
    2 * * * * * * * * *
    3 * * * * * * * * *
    4 * * * * * * * * *
    5 * * * * * * * * *
    6 * * * * * * * * *
    7 * * * * * * * * *
    8 * * * * * * * * *

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,407
    Rep Power
    25

    Default Re: Minesweeper Game Need Help!

    It looks like you are using println() too much. That method will end the current line and move to the next line.
    If you want to print on the same line use the print() method. When you want the next printed output on the next line use the println() method.
    If you don't understand my response, don't ignore it, ask a question.

  19. #19
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: Minesweeper Game Need Help!

    To add to what Norm has said, println already adds a new line (that's the 'ln' part of the name), so this:
    Java Code:
    System.out.println("\n");
    is actually printing two blank lines. You probably don't want to be doing that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. I badly need help on this minesweeper game
    By Shin in forum New To Java
    Replies: 5
    Last Post: 10-14-2012, 08:42 PM
  2. [suggestions] minesweeper
    By temyong in forum New To Java
    Replies: 7
    Last Post: 12-30-2010, 03:10 AM
  3. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  4. MineSweeper!
    By CrushOverwrite in forum New To Java
    Replies: 17
    Last Post: 02-24-2010, 02:34 PM
  5. Minesweeper problem! need help!
    By jeffrey in forum New To Java
    Replies: 1
    Last Post: 10-02-2009, 04:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •