This site is from a past semester! The current version is here.
CS2113/T Aug '19
  • Week 1 [Aug 12]
  • Week 2 [Aug 19]
  • Week 3 [Aug 26]
  • Week 4 [Sep 2]
  • Week 5 [Sep 9]
  • Week 6 [Sep 16]
  • Week 7 [Sep 30]
  • Week 8 [Oct 7]
  • Week 9 [Oct 14]
  • Week 10 [Oct 21]
  • Week 11 [Oct 28]
  • Week 12 [Nov 4]
  • Week 13 [Nov 11]
  • Textbook
  • Admin Info
  • Report Bugs
  • Slack
  • Forum
  • Project Info
  • Instructors
  • Announcements
  • File Submissions
  • Tutorial Schedule
  • Duke
  • Project Phase1 Dashboard
  • Java Coding Standard
  • samplerepo-things
  • Projects List
  • config.json templates for Reposense
  • PersonalAssistant-Duke
  • Project Phase2 Dashboard
  • Reference project - Addressbook
  • Repl.it classroom
  • Project Duke

    Duke, the Java Mascot
    [credit: Wikipedia]

    Project Duke is a educational software project designed to take you through the steps of building a small software incrementally, while applying as many Java and SE techniques as possible along the way.

    The project aims to build a product named Duke, a Personal Assistant Chatbot that helps a person to keep track of various things. The name Duke was chosen as a placeholder name, in honor of Duke, the Java Mascot. You may give it any other name or personality you wish.

    Here is a sample interaction with Duke:

        ____________________________________________________________
          ____        _        
         |  _ \ _   _| | _____ 
         | | | | | | | |/ / _ \
         | |_| | |_| |   <  __/
         |____/ \__,_|_|\_\___|
    
         Hello! I'm Duke
         What can I do for you?
        ____________________________________________________________
    
    list
        ____________________________________________________________
         Here are the tasks in your list:
         1.[T][✓] read book
         2.[D][✗] return book (by: June 6th)
         3.[E][✗] project meeting (at: Aug 6th 2-4pm)
         4.[T][✓] join sports club
        ____________________________________________________________
    
    todo borrow book
        ____________________________________________________________
         Got it. I've added this task: 
           [T][✗] borrow book
         Now you have 5 tasks in the list.
        ____________________________________________________________
    
    
    deadline return book /by Sunday
        ____________________________________________________________
         Got it. I've added this task: 
           [D][✗] return book (by: Sunday)
         Now you have 6 tasks in the list.
        ____________________________________________________________
    
    done 2
        ____________________________________________________________
         Nice! I've marked this task as done: 
           [D][✓] return book (by: June 6th)
        ____________________________________________________________
    
    blah
        ____________________________________________________________
         ☹ OOPS!!! I'm sorry, but I don't know what that means :-(
        ____________________________________________________________
    
    bye
        ____________________________________________________________
         Bye. Hope to see you again soon!
        ____________________________________________________________
    
    

    The project consists of the following increments:

    • Levels: A series of features, meant to be added to Duke in the given order, although some can be skipped. These have been named Level 1 to Level 10 to indicate how the features make the product progressively "level up".
    • Extensions:
      • Category A These are internal/feature enhancements meant to help you practice a specific Java or an SE technique.
      • Category B These are enhancements related to task tracking.
      • Category C These are enhancements, not specifically related to task tracking.
      • Category D Each of these adds the ability to track another type of entities.

    Levels

    Level 1. Greet, Echo, Exit

    In this initial skeletal version of Duke, it starts by greeting the user, simply echos commands entered by the user, and exits when the user types bye.
    Example:

        ____________________________________________________________
         Hello! I'm Duke
         What can I do for you?
        ____________________________________________________________
    
    list
        ____________________________________________________________
         list
        ____________________________________________________________
    
    blah
        ____________________________________________________________
         blah
        ____________________________________________________________
    
    bye
        ____________________________________________________________
         Bye. Hope to see you again soon!
        ____________________________________________________________
    
    
    • The indentation and horizontal lines are optional.

    Level 2. Add, List

    Add the ability to store whatever text entered by the user and display them back to the user when requested.

    Example:

        ____________________________________________________________
         Hello! I'm Duke
         What can I do for you?
        ____________________________________________________________
    
    read book
        ____________________________________________________________
         added: read book
        ____________________________________________________________
    
    return book
        ____________________________________________________________
         added: return book
        ____________________________________________________________
    
    list
        ____________________________________________________________
         1. read book
         2. return book
        ____________________________________________________________
    bye
        ____________________________________________________________
         Bye. Hope to see you again soon!
        ____________________________________________________________
    
    
    • There is no need to save the data to the hard disk.
    • Assume there will be no more than 100 tasks. If you wish, you may use a fixed size array (e.g., String[100]) to store the items.

    Level 3. Mark as Done

    Add the ability to mark tasks as done.

    list
        ____________________________________________________________
         Here are the tasks in your list:
         1.[✓] read book
         2.[✗] return book
         3.[✗] buy bread
        ____________________________________________________________
    
    done 2
        ____________________________________________________________
         Nice! I've marked this task as done: 
           [✓] return book
        ____________________________________________________________
    

    When implementing this feature, you are also recommended to implement the following extension:

    A-Classes

         Use a class to represent tasks

    While it is possible to represent a task list as a multi-dimensional array containing primitive values, the more natural approach is to use a Task class to represent tasks.

    public class Task {
        protected String description;
        protected boolean isDone;
    
        public Task(String description) {
            this.description = description;
            this.isDone = false;
        }
    
        public String getStatusIcon() {
            return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
        }
    
        //...
    }
    
    Task t = new Taks("read book");
    t.markAsDone()
    

    Level 4. ToDos, Events, Deadlines

    Add support for tracking three types of tasks:

    1. ToDos: tasks without any date/time attached to it e.g., visit new theme park
    2. Deadlines: tasks that need to be done before a specific date/time e.g., submit report by 11/10/2019 5pm
    3. Events: tasks that start at a specific time and ends at a specific time e.g., team project meeting on 2/10/2019 2-4pm

    Example:

    todo borrow book
        ____________________________________________________________
         Got it. I've added this task: 
           [T][✗] borrow book
         Now you have 5 tasks in the list.
        ____________________________________________________________
    
    list
        ____________________________________________________________
         Here are the tasks in your list:
         1.[T][✓] read book
         2.[D][✗] return book (by: June 6th)
         3.[E][✗] project meeting (at: Aug 6th 2-4pm)
         4.[T][✓] join sports club
         5.[T][✗] borrow book
        ____________________________________________________________
    
    deadline return book /by Sunday
        ____________________________________________________________
         Got it. I've added this task: 
           [D][✗] return book (by: Sunday)
         Now you have 6 tasks in the list.
        ____________________________________________________________
    
    event project meeting /at Mon 2-4pm
        ____________________________________________________________
         Got it. I've added this task: 
           [E][✗] project meeting (at: Mon 2-4pm)
         Now you have 7 tasks in the list.
        ____________________________________________________________
    

    At this point, dates/times can be treated as strings; there is no need to convert them to actual dates/times.

    Example:

    
    deadline do homework /by no idea :-p
        ____________________________________________________________
         Got it. I've added this task: 
           [D][✗] do homework (by: no idea :-p)
         Now you have 6 tasks in the list.
        ____________________________________________________________
    

    When implementing this feature, you are also recommended to implement the following extension:

    A-Inheritance

         Use Inheritance to support multiple task types

    As there are multiple types of tasks that have some similarity between them, you can implement classes Todo, Deadline and Event classes to inherit from a Task class.

    Furthermore, use polymorphism to store all tasks in a data structure containing Task objects e.g., Task[100].

    public class Deadline extends Task {
    
        protected String by;
    
        public Deadline(String description, String by) {
            super(description);
            this.by = by;
        }
    
        @Override
        public String toString() {
            return "[D]" + super.toString() + " (by: " + by + ")";
        }
    }
    
    Task[] tasks = new Task[100];
    task[0] = new Deadline("return book", "Monday");
    

    Level 5. Handle Errors

    Teach Duke to deal with errors such as incorrect inputs entered by the user.

    Example:

    todo
        ____________________________________________________________
         ☹ OOPS!!! The description of a todo cannot be empty.
        ____________________________________________________________
    
    blah
        ____________________________________________________________
         ☹ OOPS!!! I'm sorry, but I don't know what that means :-(
        ____________________________________________________________
    

    When implementing this feature, you are also recommended to implement the following extension:

    A-Exceptions

         Use Exceptions to handle errors

    Use exceptions to handle errors. For example, define a class DukeException to represent exceptions specific to Duke.

    • Minimal: handle at least the two types of errors shown in the example above.
    • Stretch goal: handle all possible errors in the current version. As you evolve Duke, continue to handle errors related to the new features added.

    Level 6. Delete

    Add support for deleting tasks from the list.

    Example:

    list
        ____________________________________________________________
         Here are the tasks in your list:
         1.[T][✓] read book
         2.[D][✓] return book (by: June 6th)
         3.[E][✗] project meeting (at: Aug 6th 2-4pm)
         4.[T][✓] join sports club
         5.[T][✗] borrow book
        ____________________________________________________________
    
    delete 3
        ____________________________________________________________
         Noted. I've removed this task: 
           [E][✗] project meeting (at: Aug 6th 2-4pm)
         Now you have 4 tasks in the list.
        ____________________________________________________________
    

    When implementing this feature, you are also recommended to implement the following extension:

    A-Collections

         Use Java Collections classes

    Use Java Collections classes for storing data. For example, you can use an ArrayList<Task> to store the tasks.


    Level 7. Save

    Save the tasks in the hard disk automatically whenever the task list changes. Load the data from the hard disk whe Duke starts up. You may hard-code the file name and location e.g., [project_root]/data/duke.txt

    The format of the file is up to you. Example:

    T | 1 | read book
    D | 0 | return book | June 6th
    E | 0 | project meeting | Aug 6th 2-4pm
    T | 1 | join sports club
    

    Level 8. Dates and Times

    Teach Duke to understand dates and times. For example, if the command is deadline return book /by 2/12/2019 1800, Duke understands 2/12/2019 1800 as 2nd of December 2019, 6pm, instead of storing it simply as a String.


    Level 9. Find

    Give users a way to find a task by searching for a keyword.

    Example:

    find book
        ____________________________________________________________
         Here are the matching tasks in your list:
         1.[T][✓] read book
         2.[D][✓] return book (by: June 6th)
        ____________________________________________________________
    

    Level 10. GUI

    Add a GUI to Duke.

    When implementing this feature, you are also recommended to implement the following extension:

    A-JavaFx

         use JavaFX

    Use JavaFX to create a GUI. Refer to the JavaFX tutorials at the Duke repo (i.e., the repo you forked from) to learn how to get started.

    Extensions: Category A

    A-Classes

         Use a class to represent tasks

    While it is possible to represent a task list as a multi-dimensional array containing primitive values, the more natural approach is to use a Task class to represent tasks.

    public class Task {
        protected String description;
        protected boolean isDone;
    
        public Task(String description) {
            this.description = description;
            this.isDone = false;
        }
    
        public String getStatusIcon() {
            return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
        }
    
        //...
    }
    
    Task t = new Taks("read book");
    t.markAsDone()
    

    A-Inheritance

         Use Inheritance to support multiple task types

    As there are multiple types of tasks that have some similarity between them, you can implement classes Todo, Deadline and Event classes to inherit from a Task class.

    Furthermore, use polymorphism to store all tasks in a data structure containing Task objects e.g., Task[100].

    public class Deadline extends Task {
    
        protected String by;
    
        public Deadline(String description, String by) {
            super(description);
            this.by = by;
        }
    
        @Override
        public String toString() {
            return "[D]" + super.toString() + " (by: " + by + ")";
        }
    }
    
    Task[] tasks = new Task[100];
    task[0] = new Deadline("return book", "Monday");
    

    A-Exceptions

         Use Exceptions to handle errors

    Use exceptions to handle errors. For example, define a class DukeException to represent exceptions specific to Duke.


    A-TextUiTesting

         Test using the I/O redirection technique

    Use the input/output redirection technique to semi-automate testing of Duke.

    A tutorial is provided in the duke repository.


    A-Collections

         Use Java Collections classes

    Use Java Collections classes for storing data. For example, you can use an ArrayList<Task> to store the tasks.


    A-MoreOOP

         Make the code more OOP

    Refactor the code to extract out closely related code as classes.

    • Minimal: Extract the following classes:
      • Ui: deals with interactions with the user
      • Storage: deals with loading tasks from the file and saving tasks in the file
      • Parser: deals with making sense of the user command
      • TaskList: contains the task list e.g., it has operations to add/delete tasks in the list

    For example, the code of the main class could look like this:

    public class Duke {
    
        private Storage storage;
        private TaskList tasks;
        private Ui ui;
    
        public Duke(String filePath) {
            ui = new Ui();
            storage = new Storage(filePath);
            try {
                tasks = new TaskList(storage.load());
            } catch (DukeException e) {
                ui.showLoadingError();
                tasks = new TaskList();
            }
        }
    
        public void run() {
            //...
        }
    
        public static void main(String[] args) {
            new Duke("data/tasks.txt").run();
        }
    }
    
    • Stretch Goal: Consider extracting more classes. e.g., *Command classes (i.e., AddCommand, DeleteCommand, ExitCommand etc.) that inherits from an abstract Command class, so that you can write the main logic of the App as follows:
      public void run() {
          ui.showWelcome();
          boolean isExit = false;
          while (!isExit) {
              try {
                  String fullCommand = ui.readCommand();
                  ui.showLine();
                  Command c = Parser.parse(fullCommand);
                  c.execute(tasks, ui, storage);
                  isExit = c.isExit();
              } catch (DukeException e) {
                  ui.showError(e.getMessage());
              } finally {
                  ui.showLine();
              }
          }
      }
      

    A-JUnit

         Add JUnit tests

    Add JUnit tests to test the behavior of the code.

    Notes:

    • Add test code in a folder named [project root]\src\test\java\ folder (reason: to follow the convention followed by the project structure so far).
    • Name the test class to match the class being tested (Todo.java can be tested by TodoTest.java), and put it in a package to match. For example,
      • Class being tested seedu.duke.Todo: src\main\java\seedu\duke\Todo.java
      • Test class seedu.duke.TodoTest: src\test\java\seedu\duke\TodoTest.java

    Adding JUnit support to your project: As JUnit is a third-party library, you need to add support to it specifically in your project.

    1. Add a folder named [project root]\src\test\java\ (you may have to do this outside of Intellij)
    2. Go to Intellij and add a new module to the project as follows.
      1. FileNewModule From Existing Sources ...
      2. Choose the [project root]\src\test\ (not the java) folder.
      3. In the next screen, select Create module from existing sources
      4. Keep clicking Next until the process is complete
    3. In the Project panel of Intellij, expand the newly-created test module, right-click on the java folder inside it, and choose Mark Directory asTest Source Root (that will make the folder turn to green color).
    4. Now, create a class inside the java folder and type @Test inside it. Example:
      public class DukeTest {
          @Test
      }
      
    5. Note how the @Test turn to red because Intellij (not having JUnit support yet) does not understand it. But it will pop up a hint, asking if you want to add support for JUnit. Select Add JUnit 5.* to classpath.
    6. In the dialog that pops up, you can optionally tick the Sources, JavaDocs and Annotations boxes. After that, click OK to add the JUnit 5 to the project dependencies.
    7. To check if JUnit integration is working as expected,
      1. Add a dummy test method to the class e.g.,
        import org.junit.jupiter.api.Test;
        
        import static org.junit.jupiter.api.Assertions.assertEquals;
        
        public class DukeTest {
            @Test
            public void dummyTest(){
                assertEquals(2, 2);
            }
        }
        
      2. Run the test (right-click on the class and choose Run DukeTest.

    Refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to use JUnit via Gradle.

    A-Gradle

         Automate project builds using Gradle

    Use Gradle to automate some of the build tasks of the project. Refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to set up Gradle for your project.

    • Minimal: Learn how to use Gradle when it is already set up.
    • Recommended: Learn how to tweak the Gradle gradle set up of for a project.
    • Stretch Goal: Learn how to set up Gradle for a project.

    A-Packages

         Divide classes into packages

    Organize the classes into suitable java packages. e.g., duke.task, duke.command


    A-JavaDoc

         Add JavaDoc comments

    Add JavaDoc comments to the code.


    A-CodingStandard

         Tweak the code to comply with a coding standard

    Tweak the code to comply with a chosen coding standard.


    A-CheckStyle

         Use CheckStyle

    Use checkStyle to detect coding style violations.

    If you are using Gradle for your project, refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to use CheckStyle via Gradle.

    A-Gradle

         Automate project builds using Gradle

    Use Gradle to automate some of the build tasks of the project. Refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to set up Gradle for your project.

    • Minimal: Learn how to use Gradle when it is already set up.
    • Recommended: Learn how to tweak the Gradle gradle set up of for a project.
    • Stretch Goal: Learn how to set up Gradle for a project.

    A-CodeQuality

         Improve code quality

    Critically examines the code and refactor to improve the code quality where necessary.


    A-Assertions

         Use Assertions

    Use assert feature (not JUnit assertions) to document important assumptions that should hold at various points in the code.


    A-Jar

         Package the App as a JAR file

    Package the app as an executable JAR file so that it can be distributed easily.

    If you are using Gradle for your project, refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to create a jar file using Gradle.

    A-Gradle

         Automate project builds using Gradle

    Use Gradle to automate some of the build tasks of the project. Refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to set up Gradle for your project.

    • Minimal: Learn how to use Gradle when it is already set up.
    • Recommended: Learn how to tweak the Gradle gradle set up of for a project.
    • Stretch Goal: Learn how to set up Gradle for a project.

    A-Gradle

         Automate project builds using Gradle

    Use Gradle to automate some of the build tasks of the project. Refer to the Gradle tutorial at the Duke repo (i.e., the repo you forked from) to find how to set up Gradle for your project.

    • Minimal: Learn how to use Gradle when it is already set up.
    • Recommended: Learn how to tweak the Gradle gradle set up of for a project.
    • Stretch Goal: Learn how to set up Gradle for a project.

    A-Travis

         Use Travis for CI

    Use Travis (and GitHub) to perform Continuous Integration (CI).


    A-Enums

         Use Enumerations

    Use Java enums, if applicable.


    A-Varargs

         Use var-args

    Use Java varargs feature, if applicable.


    A-Lambdas

         Use Lambdas

    Use the Lambdas feature of Java in your code, if applicable.


    A-Streams

         Use Streams

    Use the Streams feature of Java in your code, if applicable.


    A-Libraries

         Use external libraries

    Use third-party libraries in your project. For example, you can use the Natty library to parse strings into meaningful dates.


    A-JavaFx

         use JavaFX

    Use JavaFX to create a GUI. Refer to the JavaFX tutorials at the Duke repo (i.e., the repo you forked from) to learn how to get started.


    A-UserGuide

         Add a User Guide

    Add a User Guide to the project. Here is one simple way to do it.

    • Update the given docs\README.md. See this guide to GitHub flavored Markdown (GFMD).
    • Go to the settings page of your Duke fork and enable GitHub pages to publish from the docs folder (you can select a theme too).
    • Go to http://{your username}.github.io/duke/ to view the user guide of your product.

    A-DevGuide

         Add a Developer Guide

    Add a Developer Guide to the project, explaining the design and implementation to future developers.


    A-Release

         Release the product

    Release the product to be used by potential users. e.g., you can make it available on GitHub

    Extensions: Category B

    B-TentativeScheduling

         Tentative scheduling

    Provide a way for an event to be tentatively scheduled in multiple slots, and later to be confirmed to one the slots.


    B-Snooze

         Snoozing/postponing tasks

    Provide a way to easily snooze/postpone/reschedule tasks.


    B-RecurringTasks

         Recurring tasks

    Provide support for managing recurring tasks e.g., a weekly project meeting.


    B-DoAfterTasks

         'Do after' tasks

    Support the managing of tasks that need to be done after a specific time/task e.g., return book after the exam is over.


    B-DoWithinPeriodTasks

         'Do within a period' task

    Provide support for managing tasks that need to be done within a certain period e.g., collect certificate between Jan 15 and 25th.


    B-FixedDurationTasks

         Unscheduled tasks with a fixed duration

    Provide support for managing tasks that takes a fixed amount of time but does not have a fixed start/end time e.g., reading the sales report (needs 2 hours).


    B-Reminders

         Reminders for tasks

    Provide a way to get reminders about tasks e.g., remind the user about upcoming deadlines.


    B-FindFreeTimes

         Find free times

    Provide a way for the user to find free times e.g., when is the nearest day in which I have a 4 hour free slot?.


    B-ViewSchedules

         View schedules

    Provide a way to view tasks in the form of a schedule e.g., view the schedule for a specific date.


    B-DetectAnomalies

         Detect scheduling anomalies

    Deal with schedule anomalies e.g., detect if a task being added clashes with another task in the list.

    Extensions: Category C

    C-DetectDuplicates

         Deal duplicate items

    Add the ability to recognize and deal with duplicate items. e.g., the same task added multiple times.


    C-FlexibleDataSource

         Flexible data source

    Provide more flexibility with the data source e.g., the ability for the user to specify which file to use as the data source.


    C-Sort

         Sorting items managed by the App

    The ability to sort items e.g., sort deadlines chronologically.

    C-NaturalDates

         More natural date formats

    Support more natural date formats e.g., Mon in a user command can be interpreted as the date of the next Monday in the calendar.

    C-BetterSearch

         More flexibility in searching for items

    All more flexibility in search e.g., find items even if the keyword matches the item only partially.

    C-Update

         Easily edit items

    Support a way to easily edit details of items e.g., change the end time of an event without changing anything else.

    Minimal: the ability to update an existing item without having to delete it first

    Other ideas:

    • the ability to clone items (to easily create new items based on existing items)

    C-Tagging

         Tagging items

    Provide a way to tag items e.g., tag a task as #fun.

    C-Priority

         Prioritizing items

    Provide a way to attach priorities to items e.g., mark an item as a high priority (or priority level 1).

    C-Archive

         Archiving items

    Provide a way to archive items so that the user can remove items from the app but still keep a record of them somewhere e.g., archive all tasks in the list into a file so that the user can start over with a clean slate.

    C-MassOps

         Mass operations

    Provide a way to perform tasks on multiple items e.g., delete some specific items in one go.

    C-Statistics

         Statistics and insights

    Provide a way to leverage statistics about the items managed by the App e.g., show the number of tasks that have been completed in the past week.

    C-Undo

         Undo

    Provide a way to undo a command.

    Minimal: the ability to undo the most recent command.

    C-Help

         Give help to users

    Provide in-App guidance to users.

    Minimal: add a command to access a help page.

    Other ideas:

    • Load the App with some sample data at the first run.

    C-FriendlierSyntax

         Friendlier syntax for commands

    Make the command syntax more flexible.

    Minimal: provide shorter aliases for keywords e.g., t can be shorter alias for todo.

    Other ideas:

    • Allow users to define their own aliases
    • Remove the need for the parts of a command to be in a specific order

    Extensions: Category D

    D-Contacts

         Support managing contacts

    Support managing info about contacts e.g., details of friends

    D-Notes

         Support managing notes

    Support managing info about small snippets of textual information the user wants to record e.g., one's own waist size, a name of a movie that the user wants to remember

    D-Expenses

         Support managing expenses

    Support managing info about expenses e.g., the amounts spent on food, books, transport, etc.

    D-Loans

         Support managing loan records

    Support keeping records of loans given/taken e.g., money lent/owed to colleagues/friends

    D-Places

         Support managing info about places

    Support recording info about places e.g., info about restaurants visited, for future reference

    D-Trivia

         Support managing trivia

    Provide the ability to learn/memorize thingse.g., learn vocabulary, answers to questions

    D-Clients

         Support managing client info

    Support managing info about clients e.g., for an insurance agent to keep track of clients

    D-Merchandise

         Support managing merchandise info

    Support managing info about merchandise e.g., a property agent to keep track of properties, a collector of stamps keep track of items in the collection