Lecture notes for the Introduction to Computer Science I by James Tam | Return to the course web page |
Grade out of 24 | Letter |
53 - 54 | A+ |
51 - 52 | A |
48 - 50 | A- |
44 - 47 | B+ |
40 - 43 | B |
36 - 39 | B- |
32 - 35 | C+ |
28 - 31 | C |
24 - 27 | C- |
18 - 23 | D+ |
12 - 17 | D |
6 - 11 | D- |
0 - 5 | F |
Module | Type | Input / parameters | Function return value | Description | Marks for implementing the module |
main | procedure | NA | NA | The starting point of execution for the program | NA - it will be given to you to help you start your program. |
initialize | procedure | playerOneChoice (char), playerTwoChoice (char), rerunAnswer (char), noPlayers (integer) | NA | Set variables to default starting values. If you have additional variables declared that need to be initialized then you can also pass them to this procedure. | NA - you need to implement this module as part of good programming practice. |
introduction | procedure | none | NA | Describe how the program works. The procedure runs once as the program first runs. | 1 mark |
conclusion | procedure | none | NA | Display a signoff message so that the player knows that the game has ended. | 1 mark |
displayMenu | procedure | none | NA | Show the player a list of allowable gestures. | 1 mark |
getPlayerChoice | function | none | char | Works in conjunction with the previous module. Display menu shows the list of allowable gestures to the player, this module reads in the gesture selected by the human player (the 'player's choice' of gesture) and returns it back to the main procedure. It checks if the choice is valid by calling 'isChoiceValid'. If the choice is invalid it will declare a foul and award a forced rock. Also it converts the gesture to lower case by calling 'convertToLower'. | 1 mark |
isChoiceValid | function | playerChoice (char) | boolean | This function takes the player's choice of gesture as input and returns true if it's true that the gesture was valid, false otherwise. The boolean value will be returned back to getPlayerChoice. | 4 marks |
convertToLower | function | playerChoice (char) | char | This function takes the player's choice of gesture as input, converts upper case input to a lower case equivalent and returns the lower case character. | 4 marks |
getRunrunAnswer | function | none | char | Determines whether if the player wants to play another round and returns the answer back to the main procedure. | 4 marks |
getComputerChoice | function | none | char | Randomly generates a gesture for the computer player as a character (r, p or s) and returns this value back to the main procedure. | 2 marks |
getNoPlayers | function | none | integer | Prompts the player for the number of (human) players and returns this value back to the main procedure. | 2 marks |
compare | procedure | playerOneChoice (char), playerTwoChoice (char) | NA | Takes as input the choice of gesture selected by each player (either human or computer) and determines who wins, who loses or if there is a tie. An appropriate status message should be displayed for each case. | 12 marks |
To help you visualize the structure of your program I've included a diagram that shows the hierarchy of calls for the modules:
To help make sure that you haven't missed anything here is a checklist of items to be used in marking. A sample executable 'rps' can be found in UNIX under the directory: /home/231/tamj/assignments/assignment5. Also there will be a skeleton program called 'rps.p' that you need to use as the starting point for your own program.