Schedule Planning(From Chris Mayfield Fall 2015 Java CS 149).

After completing a semester of college, you realize it would be helpful to plan ahead and estimate the workload of future years. However now that you've taken CS 149, doing simple calculations by hand (or even using Excel) is not fun anymore. You can't help but think about object-oriented programming solutions for everyday problems!

For this exam, you need to create a class from scratch: Course . The class must match the UML diagram below exactly. You may want to create Unit tests to test your code. At the end of (and during) the exam, you will submit the course.py file via Gradescope. You may submit as many times as you like; only the last submission will be graded.

Course UML

• One example Course is CS 149 (with prefix "CS" and number 149).
• The __init__ automatically converts the prefix to ALL CAPS. If the number is negative or greater than 999, it should be changed to zero.
• The __eq__ method returns true if the courses have the same prefix and number, unless the number is zero, in which case they are not considered equal.
• The __str__ method returns the prefix and number separated by a space and formatted to three digits padded with zeros (e.g., "CS 005").
• The workload for a set of courses is measured in points. Lower division courses (with numbers below 300) get two points, upper division courses (in the 300-499 range) get three points, and graduate courses (500 and above) get four points. CS and MATH courses get an extra point. If the schedule has zero courses or equals None, then workload should return -1.

You do not need to write full documentation, but it would be good to include some comments, particularly if you are struggling to complete the exam. It's strongly recommended you complete the exam in this order:

  1. Write documentation and stubs for all classes and methods. [10 min]
  2. Implement your test cases; they should all fail at this point. [10 min]
  3. Submit to Gradescope to make sure that it compiles and runs. [10 min]
  4. Write and test the first three methods; submit to Gradescope. [15 min]
  5. Write and test the workload method; submit to Gradescope. [15 min]

Back to Top