Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Minesweeper Game

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 2219
47
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please, read articles behind those links.
NotACodeMill
ShowSomeEffort
UseCodeTags
HowToAskQuestionsOnJavaRanch
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the articles
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this code do now, and what should it do instead? Where are you stuck making progress?
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the teacher's requirements. I am in an intro to Java class and this should be in an advanced class.
I just don't understand how to actually get my program running :( To make matters worse, I'm learning this online. Any directions or suggestions are greatly appreciated!

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)
 
Paweł Baczyński
Bartender
Posts: 2219
47
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, we have the requirements. Not very smart. I wouldn't advise to cramp all code in main, but... clients' demands right ;) ?
So, what do you have problem with? Remember that we will be very glad to help you make this assignment but nobody will write the code for you (or even if somebody does, it will be moderated).
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just need to start at the beginning of the code and work my way down until this assignment is completed.
I'm starting with declaring the variables and the game description.
I'll edit the code as I go.
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand bool error or if I need to declare what it returns
 
Paweł Baczyński
Bartender
Posts: 2219
47
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Punkymedic Heather wrote:I don't understand bool error or if I need to declare what it returns


What error?
ItDoesntWorkIsUseless <- click
TellTheDetails

This is the most important for you to read:
StopCoding

Don't write a single line of code until you figure out what you want to do and you are able to tell 5-years-old the instructions.
Don't try to code random thing in hope it will somehow work.
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paweł Baczyński
Bartender
Posts: 2219
47
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing advanced in this code, but I can understand that for a beginner everything is difficult ;).
So, somebody wrote some code for you and you don't understand the code?
My advice is, throw it away and begin from scratch on your own. That way you'll actually learn something and understand what is going on.
 
Punkymedic Heather
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Code:

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!
 
Marshal
Posts: 64998
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you indenting that code? Correct indentation (example here makes it a lot easier to read and will probably pick you up a mark or two.

Why have you declared row and col before you get to the loops? Why didn't you declare them as loop variables? Why are you using .length in one loop and 9 in the other? Why are you using - 1? Why have you got a print for an element in the board outside your loop?
Remember the usual way to iterate an array with a for loop, which you should always use:- for (int i = 0; i < myArray.length; i++)...
 
Campbell Ritchie
Marshal
Posts: 64998
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ctrl‑a ctrl‑i. Works wonders on Eclipse. Does all your indenting, even if you forgot it completely, in 1 second

No, - 1 and < are not equivalent to each other.
I showed you how to declare a loop variable in my last post. Only I gave it the conventional name of i.
You should always use xxx.length. How do you know you will have a 9‑element array?
 
Saloon Keeper
Posts: 3406
149
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:(...) Why have you declared row and col before you get to the loops? Why didn't you declare them as loop variables?
Why are you using .length in one loop and 9 in the other? Why are you using - 1? Why have you got a print for an element in the board outside your loop? (...)


Maybe because Punkymedic (love those parents who give their children such original names!) is an absolute beginner?
 
Campbell Ritchie
Marshal
Posts: 64998
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly. But combining - 1 and < looks like guessing to me.
If she had explained it, that would have helped her see what is going wrong.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!