Design, Take 1

So it is time to write Minesweeper. I have read the handout too many times and I am ready to begin.

I need to go through the spec and determine what the objects are since most of those will be my classes.

In addition, I went thru the spec and found all of the actions that I need to incorportate into my design.

As I was going through this, I noticed that there are things that I do not quite understand. It is probably important to understand _everything_ before I even try to design. Here are the current problems/questions I have that are prohibiting me from going farther:

For the moment, I am going to stop and come back to these issues later.


I continued to review the spec and am starting to answer some of my questions. Checking is actually kind of cool. Basically, when you choose a square that has already been overturned, it sees how many neighbors are flagged. If the number on the square (the number of neighboring mines) equals the number of neighbor "mines" flagged, it uncovers all of the non-flagged neighbors (expecting all to be non-mines). That is kind of cool!

In order to deal with randomness, I found a java function called java.util.Random (Note to the reader: in order to not use GP, I am not using the GP randomizer. I am doing this so that other schools/cs17 could use this code since a GP one is already existing. This is easy since I am not using graphics.) Since I had never used this before, I decided to write a mini-program to show how it is used. The code is here and sample output is:

iteration number 0 = 58
iteration number 1 = 29
iteration number 2 = 89
iteration number 3 = 81
iteration number 4 = 89
iteration number 5 = 47
iteration number 6 = 84
iteration number 7 = 78
iteration number 8 = 46
iteration number 9 = 82

The other technical issue that I had was dealing with text input and output. I figued out that I can survive on System.out.print and System.out.println. Reading things is a whole other issue. [Note: Jon created a wrapper class after I tried 8 different wrappers. The wrapper does no checking for errors so we have to assume that the input is correct.] Since I did not understand how to use read, I decided to write a tester class. The code is available here. That really solidified what I need to do in order to start the major design portion of Minesweeper.

I also figured out how to tell that something is a mine. I just need to give it a flag so that I can say, "Are you a mine?" and it will tell me.