Programming Project 3
As you know, through the course of this semester, we are building the board game Battleship (see the rules here https://www.thesprucecrafts.com/the-basic-rules-of-battleship-411069).
For this assignment, we will be completing the one-sided game.
In the previous assignment, you detected a hit. Now you must update the board with a hit. We will create a log file to track all of the moves. You must also detect when the game is over and set the terminate flag to end the game loop.
Copy your Programming Project 2 and make the changes described below.
Create a structure to track each move. The structure should be a linked list that keeps the coordinates fired at and the result: missed or ship type hit.
When the input is accepted, create a new instance of the structure. Add it to the linked list. Pass the structure from accept input to update state and then to display state.
When updating the state, change the board to indicate that the shot hit or missed.
In display state, check to see if the game is over (there are a number of ways to do that). If so, set the end game flag (to end the game loop).
In teardown, create a log file by walking the linked list. Each line should follow this format:
Fired at A1. Hit – Carrier.
Fired at C2. Miss.
In teardown, free the nodes of the linked list.
Note: we use the names of your program functionalities according to the recommendations given in the first programming assignment. In your program, you are free to choose another name for the program module corresponded to the functionality, but please keep it close, so the corresponding is clear. For example, we use teardown and termination interchangeable.
Please review your work carefully before submitting it. Read “Programming Assignments Requirements and Recommendations.” Check the grading rubric before you submit to make sure you are meeting all of the requirements.
Submission should include:
- C language source code as a file named c.
- A screenshot with your program dialog and outputs.
To submit your files, click the assignment title, then in the submission window, click the “Browse My Computer” button to add files to the submission.
You may add any comments in the comments area.
Click the “Submit” button.
You have three submission attempts; only the last one will be considered and graded.
You may not retract your submission or resubmit for re-grading after the due date.
Late submissions will not be accepted.
If you have trouble with the submission, please contact your TA for assistance.