Assignment Objectives

The purpose of this assignment is to test the following:

  • Use of Java API classes (Scanner, String, Math, etc.)
  • Use of control structures (selection and repetition, nested and unested) to create non-trivial logic
  • Design of object oriented solutions to simple problems using multiple user-defined classes
  • Testing of programming solutions
  • Use of arrays (Part 2)

Assignment Overview

For this assignment you will be creating a grid-based game in which a hunter attempts to shoot a snark. The snark is a vicious beast that lives in the dismal swamp beyond the limits of the city. As a game begins the snark hides at a random grid point. At each step of the hunt the hunter takes a shot by indicating a grid point expressed as an x and y coordinate. The origin (0, 0) is in the bottom left hand corner of the grid. For a grid of size 10 the top right hand corner is (9, 9). If the grid point of the hunter’s shot is the same as the snark’s hiding place the snark is dead and the game is over and the hunter wins. The hunter has 5 shots to kill the snark. If the hunter fails to shoot the snark in 5 shots or gives up before all 5 shots have been used the game ends and the snark wins. After each unsuccessful shot the hunter is told where the snark is relative to the shot using compass directions as follows: Compass direction.


There is a console dump of a short but typical run of the application in the file called dump.txt files attached. In this dump two games are played. In the first game the snark is shot dead which is a score for the hunter. In the second game the hunter gives up before 5 tries which is a score for the snark. In the dump the position of the snark is indicated by an “S”. This is just for testing and to make the dump clear. Obviously the final version of the application would suppress this indicator of the snark’s position. The position of the shot is indicated with an “*” and a successful shot (i.e. a hit) by an “X” (see first game). Although your application is not required to reproduce the dump format exactly it should produce all the features of the dump. The following points give more details:

  • At the start of the application (before the first game) the application’s title is displayed followed by some brief instructions on how to play a game.
  • At the start of each game an empty grid is displayed before the coordinates of the first shot of the game are prompted for.
  • The Snark is randomly located somewhere within the swamp at the start of each game.
  • In each game the hunter has five shots. The number of shots remaining at any time is displayed.
  • A successful hit should produce an appropriate message and end the current game and increment the hunter’s score.
  • An unsuccessful shot should produce hints as to the relative compass position of the shot and the snark.
  • An unsuccessful fifth shot should end the current game and increment the snark’s score.
  • A user response of -1 before or at the fifth shot should end the current game and increment the snark’s score.
  • If the player chooses to play another game at any stage all relevant game variables should be reset and a new game played. To see sample output please review the 2 dump files attached.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.