Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Assignment 3

Due at 4 PM. For assignment due dates see the main schedule on the course webpage.

New Concepts to be applied for the assignment

Description:

Implement the functionality for the previous assignment using functions. One way of decomposing your program is to implement the process of instructions for a room as a function or functions. Because there are six rooms that will mean that your program will consist of at least 7 functions (1 per room plus a starting function). You may be able to subdivide your program using an alternate approach to writing 1 function per room but your program must follow good design principles for using functions.

This program includes everything needed for the program to perform the actions specified in the previous assignment (e.g. display menus, get user input, verify user input etc.) but adds three additional rooms. While the player can still play the first part of this program (the A2 code can still be interacted with) your solution must set the two locks in a state such that the inner door is unlocked (silver lock = right, gold lock = left). This will speed up your testing and the TA marking.

All instructions must be enclosed within the body of a function. The exceptions could include: import statements (not really needed for this assignment), the creation of global constants and the call to the initial start or main function. You will be penalized heavily if functions are not used or improperly used. A solution for the previous assignment will be posted in one of the [display cases] on the 7th floor of ICT (right in front the three elevators) after the A2 due date if you didn't fully complete the assignment. It's recommended that you don't take the entire solution and just include it in your program. Instead you should just use the solution to help you understand how to produce your own solution. You can find sample outputs of my solution to this assignment under: /home/231/assignments/assignment3/outputs

Part I:

Your first part of this program is identical to the previous assignment except your solution will be implemented into separate functions. Once the player passes through the locked door into Part II there is no way to return the original three rooms in Part I

Part II:

Living room contents: a pot of soil, stairs going up, a dark entranceway, a ball of a string

Attic contents: a tiny hole in the floor, an unlimited supply of cheese, stairs going down.

Bedroom contents: a tomcat which is intently watching a mouse hole (default), mouse (after the cat leaves).

As was the case with the previous assignment each room will provide a description of the contents, display a menu of options (which varies depending upon the actions of the player), get and error check the player's selection as long as the player remains in the room. (In the case of the bedroom the menu may stop displaying after the player has won the game).

In addition to grading on whether the above functionality was correctly implemented TAs will also look at style and documentation.

Documentation (synopsis from the intro to programming notes)

Style  (synopsis from the intro to programming notes)

Principles of good design for functions (most of it is a synopsis from the decomposition notes)

D2L configuration:

Marking

Points to keep in mind:

  1. Due time: All assignments are due at 4 PM on the due dates listed on the course web page.  Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. Alternate submission mechanisms (non exhaustive list of examples: email, uploads to cloud-based systems such as Google drive, time-stamps, TA memories) cannot be used as alternatives if you have forgotten to submit work or otherwise have not properly submitted into D2L. Only files submitted into D2L by the due date is what will be marked, everything else will be awarded no credit.
  2. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a doctor's note). Typical examples of reasonable cases for an extension include: illness or a death in the family. Example cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. Tutorial instructors (TA's) will not be able to provide extension on their own and must receive permission from the course instructor first.
  3. Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that you submit your assignment with enough time before it comes due for you to do a check).
  4. Identifying information: All assignments should include contact information (full name, student ID number and tutorial section) at the very top of your program in the class where the 'main()' method resides (starting execution point). (Note other documentation is also required for most assignments). Not necessary graded for mini-assignments but still a good idea to do this.
  5. Collaboration: Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others.  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
  6. Execution: programs must run on the computer science network running Python 3.x. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH then you should be okay (assuming you don't login to a non-Linux computer). If you choose to install Python on your own computer then it is your responsibility to ensure that your program will run properly here. If it's not running in the lab computers using Python 3.x then it won't be awarded credit. It's not recommended that you use an IDE for writing your programs but if you use one then make sure that you submit your program in the form of text ".py" file or files.
  7. Use of pre-created Python libraries: unless otherwise told you are to write the code yourself and not use any pre-created functions. For this assignment the usual acceptable functions include: print(), input() and the 'conversion' functions such as int(), float(), str(). Look at the particular assignment description for a list of other classes that you are allowed to use and still get credit in an assignment submission.