Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Computing Discipline
UNIX and C Programming (COMP1000)
Assignment
Weight: To Be Determined
1 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.
2 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
and types. Collectively, these comments should explain your design. (They are worth substantial
marks - see Section 8)
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.
3 Academic Integrity
This is an assessable task, and as such there are strict rules. You must not ask for or accept help
from anyone else on completing the tasks. You must not show your work to another student
enrolled in this unit who might gain unfair advantage from it. These things are considered
plagiarism or collusion.
Staff can provide assistance in helping you understand the unit material in general, but nobody
is allowed to help you solve the specific problems posed in this document. The purpose of
the assignment is for you to solve them on your own. Please see Curtin’s Academic Integrity
website for information on academic misconduct (which includes plagiarism and collusion).
The unit coordinator may require you to provide an oral justification of, or to answer questions
about, any piece of written work submitted in this unit. Your response(s) may be referred to as
evidence in an Academic Misconduct inquiry. In addition, your assignment submission may
be analysed by systems to detect plagiarism and/or collusion.
4 Task Details
4.1 Input Files
Your program should accept two (2) command-line parameters that will be the filenames of
the input files. For example:
[user@pc]$ ./battleships board.txt missiles.txt
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 not continue in the case of an error
being detected but should print out a meaningful error to the user on stderr.
More details on each file are explained below.
4.1.1 Board File
The 1st filename is the name of the settings file for the game board. This file details the size of
the board and the location of the ships. The first line is the size of the board and each proceeding
line is a ship that belongs on the board. The format is as follows:
,
...
Details on each field:
Width + Height :
What is it? : The size of the board in width and height
Restrictions : Has to be a positive Integer between 1 and 12 (inclusive)
Location :
What is it? : This is the location of the front (head) of the ship
Restrictions : Has to be within the board size
Direction :
What is it? : The direction that the ship is facing. All proceeding blocks will be placed
behind it
Restrictions : Can only be the values N,S,E,W and n,s,e,w (case insensitive)
Length :
What is it? : The amount of Blocks (including the head) that the ship takes up.
Restrictions : Has to be a positive number. Has to fit within the board.
Ships Name :
What is it? : The name of the ship.