CPSC 103 Lecture 8:
CPSC 103 verified notes
8/26View all
Document Summary
Some courses at ubc have a single letter after their number, like biol 448g", although most don"t. Suggest two approaches to changing the course data definition to allow this and explain which one you think is better. Approach 1: change the num field so that it is a string rather than an int in the range of 0-699. Then, we could create course numbers that contain both numbers and letters. Approach 2: add a field to the course data type definition for a course number suffix. Its type should be optional so that it could contain a string or none. Approach 3: design a new data type for s string that contains exactly one uppercase letter, perhaps called uppercaseletter, and then add an optional suffix field to course to contain either an uppercasedletter or none. Uppercaseletter = str # contains exactly one uppercase letter. A string that contains exactly one uppercase letter.