Battleship - Homework 1 - Object Oriented Programming in C++ | CIS 554, Assignments of Computer Science

Material Type: Assignment; Professor: Waclawski; Class: Object Oriented Programming in C++; Subject: Computer & Info Science; University: Syracuse University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-wp7
koofers-user-wp7 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 554 Homework 1b
Homework Objective: Provide students with an opportunity to do some C++ programming to get started.
Provide a programming assignment that tests the student’s knowledge of the fundamentals. Provide
students with the opportunity to get the Visual C++ environment up and running.
Due Date: See class website
Description: Battleship. (Worth 120 Points)
The aim of this project is to develop an interactive program, simulating a game of battleships between the user and
the computer. Gives students a chance to work with C++ concepts like double scripted arrays, random number
generation, and basic language constructs.
Overview
1. The principle layout will be as follows. When the program is run, a grid is displayed, similar to that shown in
the example below:
2.
Declare two 8X8 grids. Each is implemented via an 8x8 array in the program. For EXTRA CREDIT, make the grid
size adaptable when the program is run. Note that if the grids are too large, they will not fit on the screen nicely,
so you may want an upper bound on the grid size.
3. The computer (your program) chooses its random positions of ships, up to five. For EXTRA CREDIT, make the
number of ships adaptable when the program is run. Note, the computer’s ship positions are obviously NOT
shown to the user as an S on the Computer’s grid.
4. Now the user enters their positions of the ships.
5. After the computer and user enter ship positions, an empty grid with dots is displayed for the Computer’s Navy,
and the User’s Navy grid shows the ship’s positions with an S, and dots everywhere else.
6. The user now drops a bomb somewhere on the computer’s grid. This is done by selecting one of the Computer’s
grid locations. E.g. 4B or 4b. Based on a hit or a miss, an appropriate message is displayed, and the grids are
subsequently refreshed.
7. Now the computer chooses a user’s grid cell at random, and bombs it. The grids are refreshed again, based upon
whether or not the computer hit one of the user’s ships.
8. Note that a ship occupies only one grid location, and not several as in the real game.
9. The game continues until the Navy on one side is completely destroyed.
10. You must properly input Doxygen tags to comment your code, per the Doxygen standard provided on the
webpage.
User’s Navy User’s Hits
1 . . S . . . . S 1 . H . . . . . .
2 . . . . . . . . 2 . . . M . . . .
3 . . . S . . . . 3 . . . . . . . .
4 . . . . . . . . 4 . . . . . . . .
5 . . * . . . . . 5 . . . . . . . .
6 . . . . . . . . 6 . . . . . . . .
7 . . . . S . . . 7 . M . . . . H .
8 . . . . . . . . 8 . . . . . . . .
A B C D E F G H A B C D E F G H
H : Hit
M : Miss
S : Ship
* : Sunk Ship
pf3

Partial preview of the text

Download Battleship - Homework 1 - Object Oriented Programming in C++ | CIS 554 and more Assignments Computer Science in PDF only on Docsity!

CIS 554 Homework 1b

Homework Objective : Provide students with an opportunity to do some C++ programming to get started.

Provide a programming assignment that tests the student’s knowledge of the fundamentals. Provide

students with the opportunity to get the Visual C++ environment up and running.

Due Date: See class website

Description: Battleship. (Worth 120 Points)

The aim of this project is to develop an interactive program, simulating a game of battleships between the user and the computer. Gives students a chance to work with C++ concepts like double scripted arrays, random number generation, and basic language constructs. Overview

1. The principle layout will be as follows. When the program is run, a grid is displayed, similar to that shown in the example below: 2. Declare two 8X8 grids. Each is implemented via an 8x8 array in the program. For EXTRA CREDIT, make the grid size adaptable when the program is run. Note that if the grids are too large, they will not fit on the screen nicely, so you may want an upper bound on the grid size. 3. The computer (your program) chooses its random positions of ships, up to five. For EXTRA CREDIT, make the number of ships adaptable when the program is run. Note, the computer’s ship positions are obviously NOT shown to the user as an S on the Computer’s grid. 4. Now the user enters their positions of the ships. 5. After the computer and user enter ship positions, an empty grid with dots is displayed for the Computer’s Navy, and the User’s Navy grid shows the ship’s positions with an S, and dots everywhere else. 6. The user now drops a bomb somewhere on the computer’s grid. This is done by selecting one of the Computer’s grid locations. E.g. 4B or 4b. Based on a hit or a miss, an appropriate message is displayed, and the grids are subsequently refreshed. 7. Now the computer chooses a user’s grid cell at random, and bombs it. The grids are refreshed again, based upon whether or not the computer hit one of the user’s ships. 8. Note that a ship occupies only one grid location, and not several as in the real game. 9. The game continues until the Navy on one side is completely destroyed. 10. You must properly input Doxygen tags to comment your code, per the Doxygen standard provided on the webpage. User’s Navy User’s Hits 1.. S.... S 1. H...... 2........ 2... M.... 3... S.... 3........ 4........ 4........ 5.. *..... 5........ 6........ 6........ 7.... S... 7. M.... H. 8........ 8........ A B C D E F G H A B C D E F G H **H : Hit M : Miss S : Ship

  • : Sunk Ship**

Format: Provide the information as follows:

1. Upload the program via the web on the Homework page. If you don’t have an ECS account, you will

have to email me your program.

2. Please include your full name as part of the header in each source file.

3. A zip file including source and executable should be uploaded. Please append _HW1b to the .zip file

name (e.g. waclawski_HW1b.zip).