This site is from a past semester! The current version will be here when the new semester starts.

Week 9 [Fri, Oct 7th] - Tutorial

1 Demo an assertion failure

  • Temporarily edit the tP code to cause an assertion failure. Demo the assertion failure by running the app.
    For example, you can add the following assertion at the start of the main method and then run gradlew run.
    your main class
    ...
    public static void main(String[] args){
        assert false : "dummy assertion set to fail";
        ...
    }
    
  • Post a screenshot of the assertion failure in the tutorial workspace document.

2 Exercise: interpret an intermediate level CD

  • 10 minutes With the tutor's guidance, interpret the following class diagram, focusing on the new CD notations that you learned this week.

Explain notations in the class diagram


  • Some questions you can try to answer:
    1. What does this mean?
    2. What does this mean?
    3. Of the above two, why the lines in one are dashed?
    4. What does this mean?
    5. What's the difference (w.r. t. what it means) between the above and a normal association?
    6. What does this mean?
    7. What's the difference if the diamond is empty?
    8. Can a PR object exist without any Commit objects attached to it?
    9. Can a Commit object exist without a corresponding PR object?
    10. A Student can belong to how many teams?
    11. A Team can have how many Student objects?

3 Exercise: draw an intermediate level CD

Question adapted from past exam paper.

  1. before the tutorial Do the following exercise, by hand-drawing the answer.
    Use the following layout:

Draw a Class Diagram for the code (StockItem, Inventory, Review, etc.)


  1. during the tutorial
    • Paste the diagram (take a photo if you drew on paper) in the tutorial workspace document.
    • Discuss answers as guided by the tutor.