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

CPSC 231: Assignment 8 (Worth 8%)

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 the assignment

  1. File input and output
  2. Arrays of records
  3. Common list management functions

 

Writing a list management program:

For this assignment you are to write a Pascal program that allows a person to manage a list of rooms.  In the full version of the assignment your program will read the initial information a file into an array of records. The user can perform common list management functions, such as adding or removing entries.  When the person has finished with the program, he or she can then save the updated information back to the data file and to reload the updated information later. 

Each room will be described by three fields with each field residing on a separate line in the following order:

  1. The room code

  2. Maximum capacity

  3. The building

Description of the fields

1. The room code

The room code is unique to each room and consists of a string of 6 characters. The first three characters are an abbreviation of the building in which the room resides (e.g., ICT) followed by three numbers that specify the room number (e.g., 114).

2. Capacity

.This field specifies the maximum number of people that can safely reside in the room at one time.

3. Building

This is a text field that lists the full name of the building in which the room resides (e.g., "Information and Communication Technology").

Features to be implemented
 
  1. Correctly declares a new type 'Room' that tracks all the pertinent information for a room: 1 mark
 
  1. Correctly declares a new type 'RoomList' that is an array of type 'Room' with 100 elements: 1 mark
 
  1. Declares an instance of the array, type 'RoomList': 1 mark
 
  1. Displays instructions on how to use the program each time that it is run: 1 mark
 
  1. Display a signoff message to indicate to the user that he or she has quit the program: 1 mark
 
  1. Some form of debug mode has been implemented: 1 mark
 
  1. Displays a menu showing the list management functions: 1 mark
 
  1. (Q)uit: The user can quit the program: 1 mark
 
  1. (D)isplay: Displays the list in a neat and presentable form (try running the sample executable for an example). Only the occupied array elements will be displayed. If the array is empty then some sort of status message should be provided (e.g., "List is empty: nothing to display"). Each room should be separated by a line of stars. When the list is long, to prevent the output from scrolling off the screen your program should 'pause' the display every often (say after displaying a half a doze list elements) while it waits for a response from the user to tell it to continue (e.g., "Hit enter to continue").  In order to receive credit for this feature you must have already implemented some way of adding elements to the list either by reading from file or by allowing the user to type in the information for a new element: 2 marks
 
  1. (L)oad: The user will be prompted for the name of the input file and the program loads the information for the list from that file. The file that you can use for simple testing is 'mini.txt'. Before handing in your assignment you should make sure that it also works with the full sized input file 'rooms.txt'.  You can implement this feature in one of two possible ways: 4 marks maximum for this feature
   
  1. As the information for each room is read in from file it's added to the end of the list: 2 marks
   
  1. As the information for each room is read in from file it's inserted in correct alphabetical order according to the room code: 4 marks
 
  1. Program can detect and properly handle the case of an empty file (e.g., 'empty.txt') by displaying some sort of status message (e.g., "File is empty: nothing to read"): 1 mark
 
  1. (S)ave: The user can save the list to a file. In order to receive credit for this feature your program must be able to write to the original input file and be able to successfully re-read the updated information again (that means that you must write the information in a format that is identical to how the information was originally stored) : 3 marks
 
  1. (F)ind: Program can find details about a particular room. The user enters the room code and if a match was found all the information for that room will be displayed onscreen. Otherwise a suitable error message should be displayed. The program should not allow the user to search an empty list (a suitable error message should be displayed): 3 marks
 
  1. (P)resent: Program will all the rooms with a given capacity. If no rooms of that capacity could be found then the program should display a suitable message.  Also the program should not allow the user to search an empty list (a suitable error message should be displayed): 3 marks
 
  1. (A)dd: New rooms can be added to the list if the list is not yet full (a suitable error message should be displayed if it is). When this option is selected the user will be prompted to enter the information for the room to be added. You can implement this feature in one of two possible ways: 4 marks maximum for this feature
   
  1. New rooms will be added to the end of the list: 2 marks
   
  1. New rooms will be inserted in it's correct alphabetical order according to the room code: 4 marks
 
  1. (R)emove: When this feature is invoked the user will be prompted to end the room code. If the match was found then the room is removed otherwise some sort of error message should be displayed (e.g., "Room 'ICT114' could not be found in the list"). Also the program should not prompt the user to enter the room information if the list is empty (another error message should be displayed) : 4 marks

 

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 'rooms' can be found in UNIX under the directory: /home/231/assignments/assignment8. Sample input files that you can use include 'empty.txt', 'mini.txt' and 'rooms.txt'.