1 Introduction You will be required to design and implement a game using the C programming language. Your completed program will: • Interact with the user via a Terminal based menu. • Read a series of...

1 Introduction You will be required to design and implement a game using the C programming language. Your completed program will: • Interact with the user via a Terminal based menu. • Read a series of commands from a file. • Play a game of “Simon Says”. • Load the moves from a file This assignment is separated into multiple sections. Make sure to read each section carefully before starting. 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. 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 Task Details Read this section carefully as there is a lot of detail to take in. You may need to read it several times to ensure that you do not miss anything. It is highly recommended that you spend some time coming up with a design template of your code before you start coding.


Page 1 of 6 Curtin College IT Adapted from Curtin University — Computing Discipline UNIX and C Programming (UCP1000) Trimester 3, 2020 Assignment Due: Monday 9AM 18/01/2021 Weight: 35% of the unit mark. 1 Introduction You will be required to design and implement a game using the C programming language. Your completed program will: • Interact with the user via a Terminal based menu. • Read a series of commands from a file. • Play a game of “Simon Says”. • Load the moves from a file This assignment is separated into multiple sections. Make sure to read each section carefully before starting. 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. 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 Task Details Read this section carefully as there is a lot of detail to take in. You may need to read it several times to ensure that you do not miss anything. It is highly recommended that you spend some time coming up with a design template of your code before you start coding. UCP Trimester 3, 2019 Page 2 of 6 Playing the Game Simon is an adorable ASCII stick figure who can be given commands that he must follow. There are three commands that Simon knows how to do: 1. Right hand up 2. Left hand up 3. Hands on head 4. Dance Each command includes: • A text description of the command • Either “Simon says” or “Simon didn’t say” • A function that displays art of Simon performing the specified action Command Queue The program should maintain a queue of commands, implemented using a linked list. These commands should be implemented using structs that contain the information about the command, including the display function, stored as a function pointer. Your Linked List must be a Generic Linked List and therefore be able to store any type of data. 3.1 Input Files Your program should accept one command-line parameter that will be the filename of the commands file. For example: [user@pc]$ ./SimonSays commands.txt If a command filename is not provided, the program should continue without one and the command queue linked list will start empty. If more than one command-line argument is provided, the program should exit and display instructions on how to run the program. If the filename is provided, the file should be loaded and all commands inside it should be loaded into the command queue linked list. ___ / \ | 0 0 | | ^ | \__V__/ | ---|--- | / \ / \ _| |_ Simon UCP Trimester 3, 2019 Page 3 of 6 Commands File The commands file will contain a queue of commands to be given to Simon in order. An example commands file is as follows: Simon says right hand up Simon says left hand up Simon didn’t say right hand up Simon says stand on one foot Simon says hands on head Simon says dance Simon says dance Simon says dance Your code also needs to be able to handle any invalid commands file. This includes but is not limited to: • File not existing. • Any commands having invalid values (eg. missing Simon says/didn’t say). 3.2 User Interface Your program needs to have a menu that the user can interact with. Through this menu the user must be able to: 1: Give Simon commands 2: Load commands from a file 3: Delete commands 4: Play Simon Says 5: Exit the application Your menu should only require an integer input to select a menu and needs to be able to handle errors that may occur. ie, an input that isn’t within range. After each selection, the program should return to the menu until the user selects “exit the application” 3.3 Give Simon Commands When the user chooses to give Simon commands, they should be able to type a command string in a similar format to the command file and it should be added to the end of the queue linked list. 3.4 Load Commands from a file If the user selects the option to load commands from a file, the program should prompt the user to enter a filename. This file should then be opened and each of the commands should be read and appended to the end of the linked list command queue. UCP Trimester 3, 2019 Page 4 of 6 3.5 Delete Command If the player chooses to delete a command, the program should prompt them to enter an integer to specify how many commands they would like to delete. This many commands should then be removed from the front of the queue. 3.6 Play Simon Says If a player selects the “Play Simon Says” option, the program should execute the display functions of each command in the queue, printing ASCII art of Simon performing each command. The text description of the command should also be displayed. Use your creativity to display Simon following the instructions and make up your own text descriptions for these actions. This should be implemented by calling each of the function pointers stored in the queue. If the command is not a “Simon Says” command, then Simon should instead shake his head. If the command is not one that Simon knows how to do, then Simon should instead shrug his shoulders. After Simon follows a command, it should be removed from the front of the queue. 4 Compilation You must provide a single valid makefile for your assignment. When testing your code, the makefile will be used to compile it. Warning: Failure to provide a makefile will result in zero (0) marks being awarded for compilation and it will be assumed that your code does not compile. Condition Compilation There should be two versions of the game that can be compiled using conditional compilation Normal Compilation - The compiled assignment as described above. Everything Mode - When this version is compiled, Simon should do any command whether it is a “Simon Says” command or not. You must use conditional compilation (pre-processor instructions) to achieve the different functionalities. If you achieve this by having multiple .c files for each version, then you will not receive marks for this section. UCP Trimester 3, 2019 Page 5 of 6 5 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. 2 Describe (in 1-2 paragraphs) how you implement the storing and loading/saving of the commands. Talk about any complications that you can into while designing this component. 3 Demonstrate that your program works and how to use it, including: • The command-line used to execute your program • The output of the game as shown on the screen • The input the user uses to interact with the menu • The contents of the input file • The contents of the log file Your report should be professionally presented, with appropriate headings, page numbers and a contents page. You will lose marks for poorly written/badly formatted reports! The report is to be maximum 3 pages long (this does not include cover page, contents page and references). 6 Submission Once complete you are to submit your entire assignment electronically, via Moodle, before the submission deadline. Your submission is to be a single .tar.gz file containing: Your implementation – including all your source code (.c files, .h files, makefile, etc…). Note that all pre-compiled code will be removed before marking. Your report – A single PDF file containing everything mentioned in Section 5 You are responsible for ensuring that your submission is correct and not corrupted. You may make multiple submissions, but only your latest submission will be marked. Standard late submission and extension policies will be applied as per college policy. 7 Demonstration You will be required to demonstrate each of the worksheet submissions during your tutorial session. The final assignment submission will also be demonstrated in the tutorial session following the weeks of the submission date. If you cannot attend your registered tutorial session you must make arrangements with the lecturer as soon as possible. You may be asked several questions about your assignment in this demonstration. UCP Trimester 3, 2019 Page 6 of 6 Failure to demonstrate your work will result in a mark of ZERO (0). During the demonstration you will be required to answer questions about your design. If you cannot answer the questions satisfactorily, you will also receive a mark of ZERO (0). 8 Mark Allocation Marks will be allocated for the following: 20 marks — Implementation None of these marks will be lost if all required implementation is done. 10 marks — Coding practices, coding standard and commenting. You will not lose any of these marks if you have followed the coding standard and good coding practices discussed in the unit, your code is well structured, including being separated into various, appropriate .c and .h files and if you have provided good, meaningful explanations of all the files, functions and structs/typedefs needed for your implementation. 5 marks — Report. You will not lose any of these marks if your report is complete and professionally presented. Implementation and Coding practices
May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here