[SOLVED] 代写 C data structure Scheme game math theory COMP 1041

30 $

File Name: 代写_C_data_structure_Scheme_game_math_theory_COMP_1041.zip
File Size: 536.94 KB

SKU: 0388646161 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


COMP 1041
Programming for Engineers
Programming Assignment
School of Information Technology and Mathematical Sciences The University of South Australia
May 2019

Contents
Introduction
Graduate Qualities Specifications and Requirements Submission Details
Extensions and Late Submissions Academic Misconduct
Marking Criteria
Sample Output
-2-

Introduction
This document describes the programming assignment for Programming for Engineers.
The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course by applying your knowledge and skills to implement a program that allows players to play the game of Rock-Paper-Scissors against the computer and maintains information on players (using an array of structures). You are to write a program (using multiple C source files) that will keep a record of the players. Player information will be stored in a text file that will be read in when the program commences. Once the application has read the initial player data, it should allow the user to interactively query and manipulate the player information as well as play the game against the computer.
This assignment is an individual task that will require an individual submission. Both internal and external students will be required to submit your work via learnonline before Tuesday 18 June 2019, 11am (swot-vac week).
Internal students will also be required to present your work to your supervisor during your allocated session held in the swot-vac week of the study period. Important: You must attend your allocated session (schedule to be announced on week 11) in order to have your assignment marked. External students are not required to demonstrate in person.
This document is a kind of specification of the required end product that will be generated by implementing the assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts. Please make sure you seek clarification if you are not clear on any aspect of this assignment.
-3-

Graduate Qualities
By undertaking this assessment, you will progress in developing the qualities of a University of South Australia graduate. The Graduate qualities being assessed by this assignment are:
• The ability to demonstrate and apply a body of knowledge (GQ1) gained from the lectures and text book readings. This is demonstrated in your ability to apply programming theory to a practical situation.
• The development of skills required for lifelong learning (GQ2), by searching for information and learning to use and understand the resources provided (supplied assignment files, C standard library, lecture notes, text book, practical exercises, etc.), in order to complete a programming exercise.
• The ability to effectively problem solve (GQ3) using the C programming language to complete the programming problem. Effective problem solving is demonstrated by the ability to understand what is required, utilise the relevant information from lectures, the text book and practical work, write C code, and evaluate the effectiveness of the code by testing it.
• The ability to work autonomously (GQ4) in order to complete the task.
• The ability to behave ethically (GQ5) by ensuring that you abide by the University’s policies and procedures relating to academic integrity as they apply to assessment.
Your solutions must be your own work.
• The use of communication skills (GQ6) by producing source code that has been
properly formatted; and by writing adequate, concise and clear comments.
• The application of international standards (GQ7) by making sure your solution
conforms to the standards presented in the programming practices lecture slides (available on the course website).
-4-

Specifications and Requirements
Your solution MUST adhere to the specifications and requirements described in this document.
It is recommended that you develop this assignment in stages and make back-ups of your code regularly not only for development purpose, but also as an evidence of original work.
Your program must be developed using multiple C source and header files, with the number and names of all the files strictly adhering to the specifications below.
Your program must be developed with five files (three C source files and two header files). These files must be:
• assign.c – This file contains the main() function and contains code to implement the command mode, which uses the functions contained in player.h file. It allows the user to interactively query and manipulate the player information and play the game.
• player.h – This file contains definition of data structure to store player information and function prototypes for functions to load, query, and manipulate the player information (stored in the array of structures). It also uses the functions declared in game.h to allow the player to play the game against the computer.
• player.c – This file contains the implementations of the function prototypes listed in player.h file. It will also call functions declared in game.h which will allow the player to play the game against the computer.
• game.h – This file contains function prototypes for playing one game of Rock-Paper- Scissors against the computer.
• game.c – This file contains the implementations of the function prototypes listed in game.h file.
All five files will be provided on the course website along with this document. To solve this assignment, you should modify the three files assign.c, player.h, player.c provided, but the other two files (game.h and game.c) must be used as is, without any modification. Regarding the player.h file, only the part defining member variables of the structure Player should be modified while the rest of the file should be used as is, without modification.
Player Information
When your program starts, it will load in player information from a file called players.txt (provided on the course website) by calling the load() function (declared in player.h) and using the Player structure defined in player.h file. To shore the player information, an array of pointers that point to structures of the player information (i.e. Player *players[]) must be defined and used within the main() function in file assign.c as a local variable. Number of players must be also defined as a local variable in main() function, and must not exceed MAX_PLAYERS defined as a symbolic constant in
-5-

the assign.c file. The table below details the information stored for each player which you have to implement by modifying the Player structure defined in player.h file.
Field name
Description
name
A string, up to 30 characters (+ 1 null character)
played
An integer, number of games played
won
An integer, number of games won
lost
An integer, number of games lost
tie
An integer, number of games tied
points
An integer, current points
In the players.txt file, the name of the player (which may include white spaces) is stored on a separate line. The very next line contains the number of games played, games won, games lost, games tied, and the points, all stored on one line and separated by the space character. Below is a sample content of the players.txt file:
John Doe
5 4 0 1 70
Lisa Smith
16 13 2 1 105
Andrew Whittaker
7 0 7 0 55
Use the input file players.txt provided on the course website (you are not supposed to create it yourself or edit the provided input file). You may assume that all data in this file is in the correct format. Note there could be empty lines at the end of the file which should be ignored when your program reads in those lines.
After the program has loaded the data into an array of struct pointers, it should display:
Players info successfully loaded.
Or if the program fails to load the players info, it should display:
ERROR: Cannot load players info.
The program will then enter the command mode as described in the following section.
Command Mode
Your program should enter command mode after the player information has been loaded in from the file. In the command mode, the program reads user input for a command with the following prompt shown on the screen:
Please enter a command [list, winner, add, remove, play, quit]:
The program will allow the user to enter commands and process these commands until the ‘quit’ command is entered.
-6-

The following commands must be supported:
Command
Description
list
Displays a list of all players with their details by calling the show_list() function.
winner
Displays the winner by calling the show_winner() function.
add
If there are MAX_PLAYERS number of players already, shows a message of “Cannot add more. Maximum number of users.”
Otherwise, prompts for and reads in a name for a new player to add, and calls the add() function to add the player. Depending on the return value, the following messages are displayed on the screen with the player’s NAME :
– returned 0: “Successfully added player NAME. ” – returned 1: “Player NAME already exists. ”
– otherwise: “Failed to add a new player.”
remove
Prompts for and reads in the player’s name to remove then calls the remove() function with it. Depending on the return value, the following messages are displayed on the screen with the player’s NAME :
– returned 0: “Successfully removed player NAME. ”
– returned 1: “No such player found.”
play
Prompts for and reads in the player’s name who will the game, then searches for the player in the array of players. If the player is not found in the array of players, an error message “No such player found.” is displayed to the screen.
If the player is found, calls the play_games() function.
quit
Causes the program to quit, displaying a message “Thank you for playing!”. Upon quitting, the program will also save the player information to a file named output.txt which should have the same format as the input players.txt file. This is done by calling the save() function.
Upon successfully saving the information, it shows a message, “Players info successfully saved.”
If it fails saving the information, it shows a message, “ERROR: Cannot save players info.”
Once the information is save, all of the dynamically allocated memories should be freed calling the free() standard library function.
-7-

Command input should be validated and the program should perform the input command as described above. The program should also display an appropriate message if there is any error, such as invalid command or a player is not found matching input name. Appropriate messages should also be displayed to indicate whether a command has been successfully completed. After performing each command, the program returns to command mode, prompting the user to input next command.
A loop for processing command mode should be implemented in the main() function in the assign.c file. The implementation of command mode should use and call the functions declared in the player.h file.
Specifications for Functions
Below are detailed specifications of the functions declared in player.h that you need to implement in the player.c file.
int load(Player *players[], int max_players, int *player_count)
This function reads from the players.txt file, and stores the player information read to the players structure pointer array, which can store up to max_players. You must use malloc() standard library function to dynamically allocate memory space for storing individual player information using the Player structure defined in player.h file. Details on this data structure and the file format of the players.txt are described in the ‘Player Information’ section above. On successful loading, the *player_count is updated to the number of players successfully read in. This function returns an error code of 0 for success, 1 for failing to open players.txt file, and 2 for any other errors (e.g. failure to allocate memory space). This function should not display anything onto the screen (i.e. the code calling this function is responsible for displaying relevant messages onto the screen, if needed).
int save(Player *players[], int player_count)
This function writes the current player information (provided in players structure pointer array for player_count number of players) to the output.txt file. The format of the output.txt file must be identical to the players.txt file, so that it could be read in by the load() function with simply changing the file name. It returns an error code of 0 for success, 1 for failing to open output.txt file, and 2 for any other errors. This function should not display anything onto the screen (i.e. the code calling this function is responsible for displaying relevant messages onto the screen, if needed).
void show_list(Player *players[], int player_count)
This function displays the list of players and their information (provided in players structure pointer array for player_count number of players) following the specified format. Please see the ‘Screen Format’ section for details.
void show_winner(Player *players[], int player_count)
This function finds and displays the details of the winning player who has the highest points among the player_count number of players with their information provided in the players structure pointer array. Where two players have the same points, the older
-8-

player (i.e. who comes first in the array) wins. This command should not alter the original array of players in any way. Please see the ‘Screen Format’ section for details.
int find(const char *name, Player *players[], int player_count)
This function finds a player with the given name from the player_count number of players with their information provided in the player structure pointer array. If a player is found, it returns the index of the found player in the player structure pointer array. If not found, it returns -1. This function should not display anything onto the screen (i.e. the code calling this function is responsible for displaying relevant messages onto the screen, if needed).
int add(Player *players[], int *player_count, const char *name)
This function adds a new player with the given name at the end of the players structure pointer array, which initially has *player_count number of players. If successfully added, the player information is initialised (given 100 points, and the number of games played, won, lost, tied are initialised to zero) and the *player_count is incremented by one. It returns an error code of 0 if succeeded, 1 if the player with the given name already exists, and 2 for any other errors (such as, insufficient memory space). This function should not display anything onto the screen (i.e. the code calling this function is responsible for displaying relevant messages onto the screen, if needed).
You must use malloc() standard library function to dynamically allocate memory for a structure for the new player. The new player information must be added after the last player entry stored in the array. This function does not check the array boundary, so the code calling this function is responsible for checking this before calling this function.
int remove(Player *players[], int *player_count, const char *name) This function removes the player with the given name from the players structure pointer array, which initially has *player_count number of players. If successful, the *player_count is decremented by one. It returns an error code of 0 if succeeded, 1 if the player with the given name is not found. This function should not display anything onto the screen (i.e. the code calling this function is responsible for displaying relevant messages onto the screen, if needed).
You will need to free up the memory allocated to the player being removed using free() standard library function. Watch out for memory leaks and undefined/dangling pointers! The player must be removed maintaining the order of the player array. (Hint: shift all elements one position up the array).
void play_games(Player *player)
This function runs the game with the given *player, letting him/her play until he/she runs out of point or answers no when asked to play again. If the player has zero points, then an error message is displayed saying “You have not enough points to play.” and returns to the command mode immediately, otherwise continues the game as described below.
First, it shows the amount of points the user has and asks how many points to bid. The player can choose how many points to bid between 1 and the amount of points he/she has. If there is only 1 point left, it should ask if the player still wants to play, bidding his/her last point, instead of asking how many points to bid.
-9-

After bidding, the player plays the game of Rock-Paper-Scissors against the computer. The game logic is explained in the section ‘Game of Rock-Paper-Scissors’ section below.
After playing a game, the results are shown and the player’s records are updated (i.e. number of games played, points, etc…). The amount of points bid are awarded if the player wins (i.e. the points increase by the amount of points bid). If the player loses, the amount of points bid are deducted from the points. No change to the points is made if the player ties with the computer. Depending on these results, one of the following message is displayed for reporting on the number of points left:
– When the game is a tie:
– When no more points are left: – When only one point left:
– In any other cases:
No changes to your points.
Oh no! You ran out of points!
You now have only 1 point left.
You now have 123 points.
After reporting the result, if the player ran out of points, show a message of “You have not enough points to play.” and return to the command mode.
Otherwise, ask the player to play again prompting “Play again (y|n)?”.
Please refer to the sample output to ensure that your program is behaving correctly and that you have the correct output messages (refer to the ‘Sample Output’ section at the end of this document).
Screen Format
Student Information
When the program is executed, the following information MUST be displayed on the screen at the very beginning:
COMP 1041 – Assignment – SP2 2019
Author : Steve Jobs
Stud ID : 12345678
Email ID : jobst007
This is my own work as defined by the University’s Academic
Misconduct Policy.
List
Giving the ‘list’ command in command mode (which will eventually call the show_list() function) should display the list of players and their details in a table format as shown below: |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
| John Doe
| Lisa Smith
| Andrew Whittaker
|———————————————————–|
– 10 –
5401 80.0% 70 |
16 1321 81.3%105 |
70700.0% 55 |

• The player name field is displayed under the “Player Name” heading, and should be 30 characters wide, left justified.
• The number of games played is displayed under the “P” heading, and should be 2 characters wide, right justified.
• The number of games won is displayed under the “W” heading, and should be 2 characters wide, right justified.
• The number of games lost is displayed under the “L” heading, and should be 2 characters wide, right justified.
• The number of games tied is displayed under the “T” heading, and should be 2 characters wide, right justified.
• The winning rate is displayed under the “W-Rate” heading, and should be 6 characters wide, right justified, showing 1 digit under decimal point with a percent sign (%) at the end (Hint: 100.0% has 6 characters). Note that the winning rate is not part of the information stored in the Player structure, but should be calculated based on number of games played and number of games won. If the number of games played is zero, the winning rate is treated as zero percent.
• The points is displayed under the “Points” heading, and should be 6 characters wide, right justified.
• Each of the field should be separated by a single empty space character.
When there is no player (i.e. all players removed), it should show a “No player to display.” message as below: |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
| No player to display. |
|———————————————————–|
Winner
Giving the ‘winner’ command (which will eventually call the show_winner() function) should display the name of the winning player with his/her points and number of times played, as below:
The winner is:
Lisa Smith who has 105 points and played 16 times.
If there is no player (i.e. all players removed, it should show the following message:
No players to decide the winner.
– 11 –

Other Outputs
Please refer to the sample output to ensure that your program is behaving correctly and that you have the correct output messages (refer to the ‘Sample Output’ section at the end of this document).
Game of Rock-Paper-Scissors
A single game of Rock-Paper-Scissors is provided implemented in game.c file (i.e. you don’t have to implement or modify) as the play_rock_paper_scissors()function. Calling this function will start a game showing a prompt on the screen and asking for the player’s choice. Once the player chooses between rock, paper, and scissors, the game result is displayed on the screen. The function returns 1 If the player wins, -1 if the player loses, or return 0 if it is a tie. See below for a sample screen output of a single game of Rock-Paper- Scissors:
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose rock, you chose paper.
You win!
General and Structural Requirements
Your solution must adhere to the following requirements:
• Your solution must be based on the provided multifile C program provided on the
course website together with this document.
• Supplied file game.h, game.c, and players.txt must not be modified.
• Only the Player structure definition part of the supplied file player.h should
be modified, and the function prototypes must not be altered.
• Appropriate and well-constructed while or for loops. (Marks will be lost if you use
break, continue, exit, return or similar statements in order to control or exit
from within loops.)
• Appropriate and well-constructed if, else if, else statements (as necessary).
(Marks will be lost if you unnecessarily embed if statements in another if statement. Rather use logical operators (&&, ||, !) or else if statements for combing multiple conditions.)
• User inputs should be validated and asked again if invalid (out of range number, not among the provided options) with messages displayed as shown in sample outputs.
• Appropriate definition and use of functions. All of the functions outlined in the specification must be implemented and used. If more functions are added, they should be fully implemented and used in your solution.
• Output must strictly adhere to the assignment specifications. If you are not sure about these details, you should check with the ‘Sample Output’ section at the end of this document or post a message to the discussion forum.
• No global variables.
• An array of pointers to structure Player (i.e. Player *player[]) will store
player information (defined inside the main() function as local variable). – 12 –

• Use of #define for symbolic constants instead of using specific numbers repetitively.
• Consistent commenting and indentation. You are to provide comments to describe:
your details, program description, all variable definitions, all function prototypes and
all function definitions and every significant section of code.
• Meaningful variable names (no single letter identifier names, except for index
variable accessing array elements).
• Consistent code indentation and layout.
• Your code must compile and run on Microsoft Visual Studio 2017 (Community
version), as this assignment will be assessed using this development platform.
– 13 –

Submission Details
You are required to do the following in order to submit your work and have it marked. This assignment is an individual task that will require an individual submission.
BOTH Internal and External students are required to submit an electronic copy of your program source code via learnonline before Tuesday 18 June 2019, 11am (swot-vac week). No further changes can be made to your assignment once submitted.
Internal students will also be required to demonstrate your work to your supervisor during your allocated session held in the swot-vac week of the study period. You must attend your allocated session (schedule to be announced on week 11) in order to have your assignment marked. Assignments submitted to learnonline, but not demonstrated during your allocated session, will NOT be marked. Likewise, assignments that have been demonstrated during the allocated session, but have not been submitted via learnonline, will NOT be marked. Assignments will be demonstrated in a way that the submitted files are downloaded from learnonline onto a dedicated Windows machine, then copied onto a Microsoft Visual Studio 2017 (Community version) project to build and run. Submitted files are also checked for plagiarism.
External students are not required to demonstrate in person. You just need to submit your assignment to learn online by the deadline mentioned above.
The submission to learn online must include, and only include the following five files: assign.c, player.h, player.c, game.h, game.c
Note the two files game.c and game.h should not be modified (i.e. submitted back as it was provided). The three files you modified (i.e. assign.c, player.c, and player.h)
must include the following comments at the very beginning of each file:
/*
File : filename.x
Author : Steve Jobs
Stud ID : 12345678
Email ID : jobst007
This is my own work as defined by the University’s Academic Misconduct Policy.
*/
Assignments that do not contain these details may not be marked.
It is expected that students will make copies and back-ups of all assignments in various stages and be able to provide these if required.
– 14 –

Extensions and Late Submissions
There will be no extensions/late submissions for this course without one of the following exceptions:
1. A medical certificate is provided that has the timing and duration of the illness and an opinion on how much the student’s ability to perform has been compromised by the illness. Please note if this information is not provided the medical certificate WILL NOT BE ACCEPTED. Late assessment items will not be accepted unless a medical certificate is presented to the Course Coordinator. The certificate must be produced as soon as possible and must cover the dates during which the assessment was to be attempted. In the case where you have a valid medical certificate, the due date will be extended by the number of days stated on the certificate up to five working days.
2. A Learning and Teaching Unit councillor contacts the Course Coordinator on your behalf requesting an extension. Normally you would use this if you have events outside your control adversely affecting your course work.
3. Unexpected work commitments. In this case, you will need to attach a letter from your work supervisor with your application stating the impact on your ability to complete your assessment.
4. Military obligations with proof.
Applications for extensions must be lodged with the Course Coordinator before the due date of the assignment.
Note: Equipment failure, loss of data, ‘Heavy work commitments’ or late starting of the course are not sufficient grounds for an extension.
Academic Misconduct
Students are reminded that they should be aware of the academic misconduct guidelines available from the University of South Australia website.
Deliberate academic misconduct such as plagiarism is subject to penalties. Information about Academic integrity can be found in Section 9 of the Assessment policies and procedures manual at:
http://www.unisa.edu.au/policies/manual/
– 15 –

Marking Criteria
This assignment is worth 25% of your grade.
Assessment of this assignment will include the following criteria:
– Producing correct results (correct behaviour and output): 15%
– Adheres to specifications and requirements: 5%
– Appropriate coding style (e.g., indentation, comments, etc.): 5%
Detailed marking scheme:
Category
Max Mark
Mark
Comment
Produces Correct Results
COMP 1041 – Assignment – SP2 2019 Author : Steve Jobs
Stud ID : 12345678
Email ID : jobst007
This is my own work as defined by the University’s Academic Misconduct Policy.
Players info successfully loaded.
Please enter a command [list, winner, add, remove, play, quit]: list |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
|JohnDoe
|LisaSmith
| Andrew Whittaker |———————————————————–|
Please enter a quit]: winner The winner is: Lisa Smith who
command [list, winner, add, remove, has 105 points and played 16 times.
add, remove,
add, remove,
add, remove,
add, remove,
Please enter a command [list, winner, quit]: add
Cannot add more. Maximum number of users.
play,
play,
play,
play,
play,
play,
Please enter a
quit]: add user
Invalid command: add user
command [list, winner,
Please enter a command [list, winner, quit]: add
Player’s name to add: Lisa Smith Player Lisa Smith already exists.
Please enter a command [list, winner, quit]: add
Player’s name to add: Bill Gates Successfully added player Bill Gates.
Please enter a command [list, winner, quit]: add
Player’s name to add: Alan Kay Successfully added player Alan Kay.
Please enter a command [list, winner, add, remove,
quit]: list |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
|JohnDoe
|LisaSmith
| Andrew Whittaker
|BillGates
|AlanKay |———————————————————–|
Please enter a command [list, winner, add, remove, play, quit]: play
Player name: John
No such player found.
Please enter a command [list, winner, add, remove, play, quit]: play
Player name: John Doe
5401 80.0% 70| 1613 2 1 81.3% 105| 7 0 7 0 0.0% 55 |
add, remove,
6411 66.7% 0| 1613 2 1 81.3% 105| 7 0 7 0 0.0% 55 | 0 0 0 0 0.0% 100| 0 0 0 0 0.0% 100|
play,
15
-1 mark per crash (up to -3 marks). -0.5 mark for each item.
(If a feature is not working at all, all relevant items will be deducted.)
[ ] no or incorrect student details
[ ] no or incorrect load fail message [ ] no or incorrect loaded message
[ ] no or incorrect command prompt [ ] list command not working
[ ] incorrect player list format
[ ] winner command not working [ ]incorrectwinnerformat
[ ] validation of command name
[ ] add command not working [ ] validation of existing name
[ ] no or incorrect successfully added message
[ ] validation of maximum number of users
[ ] play command not working [ ] validation of player name
– 16 –

You have 70 points.
How many points to bid (1-70)? 0 How many points to bid (1-70)? 90 How many points to bid (1-70)? 20
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose rock, you chose paper. You win!
You now have 90 points.
Play again (y|n)? a
Play again (y|n)? y
You have 90 points.
How many points to bid (1-90)? 20
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? r
Computer chose rock, you chose rock. Tie!
No changes to your points.
Play again (y|n)? y
You have 90 points.
How many points to bid (1-90)? 30
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? r
Computer chose paper, you chose rock. You lose!
You now have 60 points.
Play again (y|n)? y
You have 60 points.
How many points to bid (1-60)? 59
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose rock, you chose scissors. You lose!
You now have only 1 point left.
Play again (y|n)? y
You have only 1 point left.
Do you still want to play bidding your last point (y|n)? y
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose scissors, you chose paper. You lose!
Oh no! You ran out of points!
You have not enough points to play.
Please enter a command [list, winner, add, remove, play, quit]: list |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
|JohnDoe
|LisaSmith
| Andrew Whittaker
|BillGates
|AlanKay |———————————————————–|
12624 50.0% 0| 1613 2 1 81.3% 105| 7 0 7 0 0.0% 55 | 0 0 0 0 0.0% 100| 0 0 0 0 0.0% 100|
winner,
play. winner,
add, remove, play,
add, remove, play,
add, remove, play,
add, remove, play,
Please enter a command [list, quit]: play
Player name: John Doe
You have not enough points to
Please enter a command [list, quit]: remove
Player’s name to remove: John No such player found.
Please enter a command [list,
quit]: remove
Player’s name to remove: John Successfully removed player John Doe.
Please enter a command [list, winner, quit]: remove
Player’s name to remove: Alan Kay Successfully removed player Alan Kay.
Please enter a command [list, winner,
quit]: list |———————————————————–|
winner, Doe
add, remove, play,
[ ] no or incorrect bidding prompt [ ] validation of bidding amount
[ ] no or incorrect points update
[ ] no or incorrect play again prompt [ ] validation of y|n
[ ] points update special case for tie games
[ ] points update special case when only 1 point left
[ ] confirm to bid when only 1 pt left
[ ] points update special case when ran out of points
[ ] stop playing if not enough points
[ ] incorrect update of user info
[ ] validation of not enough points
[ ] remove command not working [ ] validation of player name
[ ] no or incorrect successfully removed message
– 17 –

| Player Name P W L T W-Rate Points | |———————————————————–|
|LisaSmith
| Andrew Whittaker
|BillGates |———————————————————–|
Please enter a command [list, winner, add, remove, play, quit]: play
Player name: Bill Gates
You have 100 points.
How many points to bid (1-100)? 50
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose rock, you chose paper. You win!
You now have 150 points.
Play again (y|n)? n
Please enter a command [list, winner, add, remove, play, quit]: list |———————————————————–| | Player Name P W L T W-Rate Points | |———————————————————–|
|LisaSmith
| Andrew Whittaker
|BillGates |———————————————————–|
Please enter a quit]: winner The winner is: Bill Gates who
Please enter a
quit]: quit
Thank you for playing!
command
has 150
[list, winner, add, remove, play,
points and played 2 times.
[list, winner, add, remove, play,
command
Players info successfully saved.
1613 2 1 81.3% 7 0 7 0 0.0% 0 0 0 0 0.0%
105| 55 | 100|
1613 2 1 81.3% 7 0 7 0 0.0% 2 1 0 1 50.0%
105| 55 | 150|
[ ] incorrect winner update
[ ] quit command not working
[ ] no or incorrect thank you msg. [ ] no or incorrect saved message
Adheres to specifications
Proper use of provided files (without modifying game.c, game.h, and function prototypes in player.h)
Information loaded from the provided file without modification Information saved into correct file and format
Proper use of dynamic memory allocation (without leak, dangling pointer, or crash)
Well-constructed loops
Well-constructed if, else if, else statements Functions fully implemented and used in player.c No global variables
Use of #define for defining symbolic constants
5
-0.5 mark for each item
[ ] multi-file configuration not following the specifications
[ ] not loading from players.txt or incorrect parsing
[ ] not saving to output.txt or incorrect format
[ ] not using malloc() properly [ ] not calling free() properly
[ ] use of break, continue, return to stop loops
[ ] unnecessary deep layered if/else [ ] missing function def. or not using [ ] use of global variable
[ ] not using symbolic constant
Style
Comments: student details
Comments: all variables and functions, and sections/blocks of code.
Consistent code layout and indentation.
Meaningful variable names (no single letter variable names).
5
-1 mark for each item
[ ] no student details at the top
[ ] no comment on vars or functions [ ] insufficient comment on code blocks/sections
[ ] inconsistent indentation [ ] non-descriptive name
Total
25
– 18 –

Sample Output
Sample Output 1 – Player information:
COMP 1041 – Assignment – SP2 2019
Author : Steve Jobs
Stud ID : 12345678
Email ID : jobst007
This is my own work as defined by the University’s Academic
Misconduct Policy.
Players info successfully loaded.
Please enter a command [list, winner, add, remove, play,
quit]: list
|———————————————————–|
| Player Name PWLTW-Rate Points |
|———————————————————–|
| John Doe
| Lisa Smith
| Andrew Whittaker
|———————————————————–|
Please enter a command [list, winner, add, remove, play,
quit]: abc
Invalid command: abc
Please enter a command [list, winner, add, remove, play,
quit]: winner
The winner is:
Lisa Smith who has 105 points and played 16 times.
Please enter a command [list, winner, add, remove, play,
quit]: add
Player’s name to add: Matthew Harper
Successfully added player Matthew Harper.
Please enter a command [list, winner, add, remove, play,
quit]: list
|———————————————————–|
| Player Name PWLTW-Rate Points |
|———————————————————–|
| John Doe
| Lisa Smith
| Andrew Whittaker
| Matthew Harper
|———————————————————–|
Please enter a command [list, winner, add, remove, play,
quit]: remove
– 19 –
5401 80.0% 70 |
16 1321 81.3%105 |
70700.0% 55 |
5401 80.0% 70 |
16 1321 81.3%105 |
70700.0% 55 |
00000.0%100 |

Player’s name to remove: Lisa
No such player found.
Please enter a command [list, winner, add, remove, play,
quit]: remove
Player’s name to remove: Lisa Smith
Successfully removed player Lisa Smith.
Please enter a command [list, winner, add, remove, play,
quit]: list
|———————————————————–|
| Player Name PWLTW-Rate Points |
|———————————————————–|
| John Doe
| Andrew Whittaker
| Matthew Harper
|———————————————————–|
Please enter a command [list, winner, add, remove, play,
quit]: add
Player’s name to add: John Doe
Player John Doe already exists.
Please enter a command [list, winner, add, remove, play,
quit]: add
Player’s name to add: Player One
Successfully added player Player One.
Please enter a command [list, winner, add, remove, play,
quit]: add
Player’s name to add: Player Two
Successfully added player Player Two.
Please enter a command [list, winner, add, remove, play,
quit]: add
Cannot add more. Maximum number of users.
Please enter a command [list, winner, add, remove, play,
quit]: quit
Thank you for playing!
Players info successfully saved.
– 20 –
5401 80.0%
70700.0%
00000.0%
70 |
55 | 100 |

Sample Output 2 – Game play:
COMP 1041 – Assignment – SP2 2019
Author : Steve Jobs
Stud ID : 12345678
Email ID : jobst007
This is my own work as defined by the University’s Academic
Misconduct Policy.
Players info successfully loaded.
Please enter a command [list, winner, add, remove, play,
quit]: play
Player name: John
No such player found.
Please enter a command [list, winner, add, remove, play,
quit]: list
|———————————————————–|
| Player Name PWLTW-Rate Points |
|———————————————————–|
| John Doe
| Lisa Smith
| Andrew Whittaker
|———————————————————–|
Please enter a command [list, winner, add, remove, play,
quit]: play
Player name: John Doe
You have 70 points.
How many points to bid (1-70)? 20
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose paper, you chose scissors.
You win!
You now have 90 points.
Play again (y|n)? a
Play again (y|n)? y
You have 90 points.
How many points to bid (1-90)? 120
How many points to bid (1-90)? 0
How many points to bid (1-90)? 89
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose scissors, you chose scissors.
Tie!
– 21 –
5401 80.0% 70 |
16 1321 81.3%105 |
70700.0% 55 |

No changes to your points.
Play again (y|n)? y
You have 90 points.
How many points to bid (1-90)? 89
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose paper, you chose scissors.
You win!
You now have 179 points.
Play again (y|n)? y
You have 179 points.
How many points to bid (1-179)? 178
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose rock, you chose paper.
You win!
You now have 357 points.
Play again (y|n)? y
You have 357 points.
How many points to bid (1-357)? 356
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? p
Computer chose scissors, you chose paper.
You lose!
You now have only 1 point left.
Play again (y|n)? y
You have only 1 point left.
Do you still want to play bidding your last point (y|n)? y
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose paper, you chose scissors.
You win!
You now have 2 points.
Play again (y|n)? y
You have 2 points.
How many points to bid (1-2)? 2
Let’s play Rock-Paper-Scissors!
– 22 –

What is your choice (r: rock / p: paper / s: scissors)? s
Computer chose scissors, you chose scissors.
Tie!
No changes to your points.
Play again (y|n)? y
You have 2 points.
How many points to bid (1-2)? 2
Let’s play Rock-Paper-Scissors!
What is your choice (r: rock / p: paper / s: scissors)? r
Computer chose paper, you chose rock.
You lose!
Oh no! You ran out of points!
You have not enough points to play.
Please enter a command [list, winner, add, remove, play,
quit]: list
|———————————————————–|
| Player Name PWLTW-Rate Points |
|———————————————————–|
| John Doe
| Lisa Smith
| Andrew Whittaker
|———————————————————–|
Please enter a command [list, winner, add, remove, play,
quit]: quit
Thank you for playing!
Players info successfully saved.
– The end –
– 23 –
13823 61.5%
16 1321 81.3%
70700.0%
0 | 105 | 55 |

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C data structure Scheme game math theory COMP 1041
30 $