Assignment 2

Back Up Next

Home
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6

Create a Battle ship game

During class you created  a Battle ship game which consisted of a single item (letter) on an array and that represented your ship.

There will be a couple of executable samples of the program on our briefcase site.

On this assignment you are supposed to expand that program to do the following:

Create a grid (array) 15 x 15
Place 10 ships on this grid. This time, it will be a full ship, for instance a submarine will take 1 element in the array, a tanker 5, in any direction. Follow this pattern:
Aircraft carrier - 4 letters [C]
Marine class 1 - 3 letters [M]
Submarine - 1 letter [S]
Tanker - 5 letters [T]
Distribute these ships on the grid, totaling 10 ships

You Should:

Have a nice and complete introduction on how the game is to be played.
Initialize the array placing Ws (on water) or "." (dots) and also initialize your ships (you can either use two arrays for the game or just one), you can also use classes.
Keep track of the shots fired by placing them on the board with X for water or the letter corresponding to the ship.
Announce to the user if they hit water or part of a ship and a congratulations when they sink a boat.
Redraw the array after every shot with the current situation.
Make sure to have letters and/or numbers on the sides of the grid .
Give the user a way to finish the game (such as use 0 0).
Show statistics at the end on how many shots were fired and what was hit.

Submit in an envelope:

A hard copy of your program.
Your source code on the disk.
The executable file of your program on the disk.

This will be the grading criteria: (click on it)

hw4.ht4.gif (11392 bytes)

Any questions, please let me know.

 

Back to CS162 Homepage
This page was last modified April 02, 2000
wmorales@pcc.edu