Test and debug a modified battleships game


Introduction:

Your task for this assignment is to design, code (in C89), test and debug a modified battleships game.

In short, your assignment will:

Extract the game settings and values needed from a file.

Interface with the user via a Terminal based menu.

Play an adapted game of battleships (single player).

Be able to do conditional compilation.

Generate new input files.

Code Design:

You must thoroughly document your code using C comments (/* ... */). For each function you define and each datatype you declare (e.g. using struct or typedef), place a comment immediately above it explaining its purpose, how it works, and how it relates to other functions andtypes. Collectively, these comments should explain your design. (They are worth substantial marks - see Section8)

Your code should also be separated logically into multiple c and h files that overall have a single purpose. Marks will be deducted if monolithic functions and/or files are used

Task Details:

1. Input Files

Your program should accept two (2) command-line parameters that will be the filenames of the input files.

Error checking is required on both files and in the case that either of the files is deemed to be invalid the program is to safely exit. Your program should notcontinue in the case of an error being detected but should print out a meaningful error to the user onstderr.

2. Menu

After the 2 input files have been read and appropriately stored in memory it is time to have a menu for the user. This menu is to have the following options initially and is to be controlled via integer input:

1 Play the Game

2 List all missiles

0 Exit

3. Playing the Game

Now that the files have been read its time to play the game. The game will consist of a number of rounds and will finish when there are either no missiles left or all ships have been destroyed. For each turn you must display the following:

The board showing all shots (hits and misses) made. (Similar to above)

The amount of missiles left (Not including the current one)

The name of the currently loaded missile (for example "v-line")

A prompt for the user to input the next coordinate to target

This part has many components and as such as been broken down to make it simplier.

4. Add Some Colour

To make the board look nicer were going to print the tiles in different colours depending on what their status is.

5. Remove Some Colour (Conditional Compilation 1)

Now that we have colour lets create a way to disable it.

Your goal is to add a condition compilation called "MONO" that when compiled with your program no longer prints any colours.

6. Find Your Ships (Conditional Compilation 2)

Lets add another conditional compilation to help us find our ships.

Add another conditional compilation called "DEBUG". With this one defined your board is to now print the '#' in a magenta colour if a ship is there and hasn't been shot yet.

7. Need Help?

So by now you should be able to shoot missiles at the board and the tiles will change character and colour depending on what was there. However what if a player didnt know how to play the game.

The challenge with this part is to allow the user to type in "help" when they are prompted to enter a coordinate to shoot at. When entered you are to print a description of what that missile does. Remember though that you cant do any checks outside of FileIO on which missile it is.

8. Creating Files

Add another 2 options to your Menu

3 Create Board File

4 Create Missile File

The goal of these options is to allow the user to create new input files for the program. As such they must save to the same format as above. These functions should ask the user for all the required information and save them in a file that is named by the user.

Report - You must prepare a report that outlines your design and testing. Specifically:

1. For each file that you have, write a paragraph explaining the overall purpose of it. (Hint: If you can't explain in 1 simple paragraph then its doing to much)

2. Describe (in 1-2 paragraphs) how you implement the storing and using of the ships on the board and the board. Talk about any complications that you can into while designing this component.

3. Demonstrate that your program works and how to use it (only need to show valid input files), including:

The contents of the input files.

The command-line used to execute your program.

The output of the board as shown on the screen.

The input the user uses to interact with the menu.

The input the user used to play the game.

Your report should be professionally presented, with appropriate headings, page numbers and a contents page.

Are you feeling anxious because of the stringent deadline to complete your complex and difficult UNIX and C Programming assignments and homework? Then hire our professional UNIX and C Programming Assignment Help tutors right now for better academic results!

Tags: UNIX and C Programming Assignment Help, UNIX and C Programming Homework Help, UNIX and C Programming Coursework, UNIX and C Programming Solved Assignments 

Attachment:- C Programming.rar

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Test and debug a modified battleships game
Reference No:- TGS03053831

Expected delivery within 24 Hours