Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 5 (Worth 3%)

Grading Scales

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

 

New concepts to be applied for this assignment

 

The Rock-Paper-Scissors game

All the features of this assignment are identical to the previous assignment except that you must break these features down into the following modules (functions and procedures).
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:

 

Submission requirements

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

  1. Include a README file in your submission:  For this assignment your README file must include your contact information: your name, university identification number and UNIX login name so that your marker knows whose assignment that he or she is marking.   For this assignment you should also list the features of the game that you actually implemented.

  2. Assignments (source code/'dot-p' file and the README file) must be electronically submitted.  In addition a paper print out of the source code and README must be handed into the assignment drop box (located on the second floor of the Math Sciences building) for the tutorial that you are registered in.  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and flip through your source code.  Unless you are told otherwise you are to email your source code and readme file to your TA and to me.  Make sure that include the following information in the subject line: "CPSC 231 Assignment X" where 'X' stands for the assignment number that you are submitting e.g., "CPSC 231 Assignment 3".

  3. As a reminder, you are not allowed to work in groups for this class.   Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following link.

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.