This site is from a past semester! The current version will be here when the new semester starts.
CS2113/T 2020 Jan-Apr
  • Full Timeline
  • Week 1 [from Mon Jan 13]
  • Week 2 [from Wed Jan 15 noon]
  • Week 3 [from Wed Jan 22 noon]
  • Week 4 [from Wed Jan 29 noon]
  • Week 5 [from Wed Feb 5 noon]
  • Week 6 [from Wed Feb 12 noon]
  • Week 7 [from Wed Feb 19 noon]
  • Week 8 [from Wed Mar 4 noon]
  • Week 9 [from Wed Mar 11 noon]
  • Week 10 [from Wed Mar 18 noon]
  • Week 11 [from Wed Mar 25 noon]
  • Week 12 [from Wed Apr 1 noon]
  • Week 13 [from Wed Apr 8 noon]
  • Textbook
  • Admin Info
  • Report Bugs
  • Forum
  • Instructors
  • Announcements
  • File Submissions
  • Tutorial Schedule
  • repl.it link
  • Java Coding Standard
  • Forum Activities Dashboard
  • Participation Dashboard

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

  •  Team Project (tP):
  • Team Project Info
  • Team List
  • tP Code Dashboard
  • tP Progress Dashboard
  • Week 9 [from Wed Mar 11 noon] - Tutorial

    1 Demo v1.0

    • Do an informal demo of the new features during the tutorial. To save time, we recommend that one member demos all new features, using the jar file.

    2 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";
      ...
      }

    3 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 the meaning of various class diagram notations in the following 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 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?

    4 Exercise: draw an intermediate level CD

    Question adapted from past exam paper.

    • Divide into two sub-teams as you did in the previous week.
    • 10 minutes Each sub-team do the part (a) of the following exercise, by drawing the answer on the whiteboard. Use the following layout:

    Consider the code below:

    public interface Billable {
    void bill();
    }
    public abstract class Item
    implements Billable {
    public abstract void print();
    }
    public class StockItem extends Item {
    private Review review;
    private String name;

    public StockItem(
    String name, Rating rating){

    this.name = name;
    this.review = new Review(rating);
    }

    @Override
    public void print() {
    //...
    }

    @Override
    public void bill() {
    //...
    }
    }
    public enum Rating {
    GOOD, OK, POOR
    }
    public class Review {
    private final Rating rating;

    public Review(Rating rating) {
    this.rating = rating;
    }
    }
    import java.util.List;

    public class Inventory {
    private List<Item> items;

    public int getItemCount(){
    return items.size();
    }

    public void generateBill(Billable b){
    // ...
    }

    public void add(Item s) {
    items.add(s);
    }
    }

    (a) Draw a class diagram to represent the code. Show all attributes, methods, associations, navigabilities, visibilities, known multiplicities, and association roles. Show associations as lines.
    (b) Draw an object diagram to represent the situation where the inventory has one item with a name spanner and a review of POOR rating.

    • 10 minutes Compare answers with those from other sub-teams. With the tutor's guidance, self-evaluate the answers.
    • 5+5=10 minutes Do part (b) in the same manner.