Summary: Requirements

  1. The class which contains the main method for playing the game must be called BoneDig.
  2. The grid must be square, and it must have 10 rows and 10 columns. The size of the grid (10) must be assigned to a single variable on one line of your program in such a way that you could change 10 to 15 on that line, recompile, and be able to play the game properly on the grid of size 15, for example.
  3. You must use a two (or higher) dimensional array to represent the grid.
  4. Your program must bury 4 lines of bones of lengths 4,3,3, and 2.
  5. Your program must randomly choose positions for the lines of bones. A line of bones must not 'go off the edge' of the grid: it must fit within the grid.
  6. No grid position can have more than one bone, and no bone can belong to more than one line of bones. Therefore there must be exactly 12 (=4+3+3+2) grid positions that have bones immediately after the lines of bones have been placed on the grid.
  7. You must read the guess from the user so that the user types an integer, presses 'return' and then types another integer and presses 'return'. The row number should be input first and then the column number, but this order is not required.
  8. You may assume that the user will type an integer in each case, but you may not assume that the integer is within the bounds of the grid. Therefore, you must check to see if the row and column are valid integers (within the grid size), and take appropriate action if they are not. Appropriate action means that an 'out of bounds' guess should not impede the playing of the game: you might ask the user to try again, for example, or you might just discard the user's guess which will in effect cause the user to lose that turn.
  9. You must print a version of the grid which indicates the grid positions at which bones have been discovered, the grid positions at which guesses have been made but no bones discovered, and the grid positions at which no guesses have been made. You will indicate these three different possibilities by using a different printed character for each case. This version of the grid will not show any bones that have not yet been discovered, and it will change after every guess made by the user.
  10. You must print a second version of the grid which shows how many bones are hidden at each grid position. This is the map of where the bones are after your program has randomly placed them, but before any guesses have been made, and remains the same throughout the game. It must be printed after the version of the grid described in the previous item. Therefore you will be printing this version of the grid after every guess by the user, as is the case for the first version of the grid. We are requiring this in order to make your program easier to mark; the marker will actually play the game, and we would like the marker to be able to choose grid positions that have bones or don't have bones without having to choose randomly.
  11. All the input and output statements must be in a class that is separate from all other classes. This class will do nothing but input and output.
  12. The game must end when all the bones have been discovered, but not before all bones have been discovered. A bone can be discovered only once. Thus you will have to know or be able to find out whether undiscovered bones remain in the yard in order to determine whether the game should end or not.

Note that there are many correct ways of doing this assignment, and you are free to write the code as you like and use the methods that you like as long as the program conforms to the specified requirements. None of the suggestions in the section For Those Who Are Keen... are required, and extra marks will neither be given nor deducted if you decide to implement any of these suggestions.