CSci 1211 Problem set 9. Due Friday, April 9th at 5pm

Individual work: Problem 1 (12 points)

In this problem you are asked to write an applet that will draw this picture. More specifically: Some hints:

Project Assignment, Part 1 (30 points each person)

For this project you need to implement the Battleship game. Here is the description of the game. Here are the details of the rules:

Programming details for this part of the program

Your task for this part would be to implement two classes: Board and Ship. You are given the compiled versions of these classes (.class files only) and the testing file Game.java.

The class Board will implement one game board (to play a game, you'll need two instances of this class: one for you and one for your opponent). The class will have the following public methods:

The printing methods are for testing purposes.

The Board class should have two 10-by-10 arrays:

While the 2-array implementation is not mandatory, it is highly recommended. If you are considering a different implementation, please discuss it with me ahead of time.

The class Ship contains all the information about the ship (the name, the length, etc.). It may or may not contain the information about whether the ship has been hit or sunk. Since the class Ship is not going to be used directly, so the hit/sunk information can be obtained through the board on which the ship is positioned.

A suggestion: the printing done directly from the classes Board and Ship is for debugging purposes only. You might want to add a variable that indicates whether you are running your program in a test mode. For instance, if this variable is
boolean testmode = true;
and all the print statements are written under an 'if' statement
if(testmode) System.out.println(...);
then switching this variable to false will turn off all the printing. You may further fine-tune this approach by having different kinds of test printing and different kinds of mode variables.

Finally, a few suggestions:

Happy programming!

This page is a part of the course CSci 1211 at UMM.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.