This site is from a past semester! The current version will be here when the new semester starts.
CS2113/T 2020 Aug-Dec
  • Full Timeline
  • Week 1 [Mon, Aug 10th]
  • Week 2 [Fri, Aug 14th]
  • Week 3 [Fri, Aug 21st]
  • Week 4 [Fri, Aug 28th]
  • Week 5 [Fri, Sep 4th]
  • Week 6 [Fri, Sep 11th]
  • Week 7 [Fri, Sep 18th]
  • Week 8 [Fri, Oct 2nd]
  • Week 9 [Fri, Oct 9th]
  • Week 10 [Fri, Oct 16th]
  • Week 11 [Fri, Oct 23rd]
  • Week 12 [Fri, Oct 30th]
  • Week 13 [Fri, Nov 6th]
  • Textbook
  • Admin Info
  • Report Bugs
  • Forum
  • Gitter (Chat)
  • Instructors
  • Announcements
  • Files
  • Tutorial Schedule
  • repl.it link
  • repl.it link (duplicated)
  • Java Coding Standard
  • Git Conventions
  • Forum Activities Dashboard
  • Participation Dashboard

  •  Individual Project (iP):
  • Individual Project Info
  • iP Upstream Repo
  • iP Code Dashboard
  • iP Progress Dashboard

  •  Team Project (tP):
  • Reference AB3
  • Team Project Info
  • Team List
  • tP Code Dashboard
  • tP Progress Dashboard
  • Week 8 [Fri, Oct 2nd] - Tutorial

    1 Exercise: interpret a class diagram

    • Do the following exercise as directed by the tutor.

    Explain the associations, navigabilities, and multiplicities in the class diagram below:

    2 Exercise: draw an object diagram

    [Image source: this article]

    Hand-drawing diagrams on a white-board and on paper is an important practical skill (e.g., for technical interviews, project discussions). It's possible that the diagrams you draw in your first few attempts to look amateurish, messy, and hard to read, and the drawing itself will take a long time. With more practice, you will be able to draw such diagrams quicker (e.g., draw as you explain verbally your design), with less need for corrections, and the diagrams will look more professional too.

    That is why we have structured these tutorials to get everyone to practice this skill so that your first few (not-so-good) diagram drawing experiences happen in the tutorial, not in an interview or during your internship.

    Note the following:

    • Draw on paper or on a whiteboard or use a free-hand drawing software (e.g., Bamboo paper). If latter, do not use UML software or predefined shapes.
    • For the same reason, don't use rulers.
    • When the tutor asks you to, take a screenshot or a photo of the drawing and post in the tutorial workspace document.
    • There are mobile apps (example) that can take a photo of a document and and convert it to a high-quality scan.
    • Do the following exercise while noting the info in the box above.

    Suppose we wrote a program to follow the class structure given in this class diagram:

    Draw object diagrams to represent the object structures after each of these steps below. Assume that we are trying to minimize the number of total objects.

    i.e. apply step 1 → [diagram 1] → apply step 2 on diagram 1 → [diagram 2] and so on.

    1. There are no persons.

    2. Alfred is the Guardian of Bruce.

    3. Bruce's contact number is the same as Alfred's.

    4. Alfred is also the guardian of another person. That person lists Alfred's home address as his home address as well as office address.

    5. Alfred has an office address at the Wayne Industries building which is different from his home address (i.e. Bat Cave).

    After step 2, the diagram should look like this:

    • Discuss answers as guided by the tutor.

    3 Exercise: draw a class diagram

    • Do the following similar to the earlier exercise.

    Draw a class diagram for the code below. Show the attributes, methods, associations, navigabilities, and multiplicities.

    class Box {
    private Item[] parts = new Item[10];
    private Item spareItem;
    private Lid lid; // lid of this box
    private Box outerBox;

    public void open() {
    // ...
    }
    }
    class Item {
    public static int totalItems;
    }
    class Lid {
    Box box; // the box for which this is the lid
    }