- Add Increment:
A-MoreOOP
- Add Increments as PRs:
Level-8
,Level-9
,A-JavaDoc
- Add a brief user guide
- Release the product by Monday (March 2) 1200
1 Add Increment: A-MoreOOP
- As in the previous week, commit, tag, and push, as you do the following increments in the
master
branch (no need to use separate branches).
A-MoreOOP
: Use More OOP Refactor the code to extract out closely related code as classes.
- Minimal: Extract the following classes:
Ui
: deals with interactions with the userStorage
: deals with loading tasks from the file and saving tasks in the fileParser
: deals with making sense of the user commandTaskList
: 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 abstractCommand
class, so that you can write the main logic of the App as follows:
You can get some inspiration from how the code of the addressbook-level2 is organized.public void run() {
ui.showWelcome();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine(); // show the divider line ("_______")
Command c = Parser.parse(fullCommand);
c.execute(tasks, ui, storage);
isExit = c.isExit();
} catch (DukeException e) {
ui.showError(e.getMessage());
} finally {
ui.showLine();
}
}
}
2 Add Increments as PRs: Level-8
, Level-9
, A-JavaDoc
- Practice using parallel git branches and PRs, as explained below:
- First, do each increment as a parallel branch (i.e.,
branch-Level-8
,branch-Level-9
,branch-A-JavaDoc
), but do not merge any. - Then, push each branch to your fork, and create a PR within your fork (i.e., from the increment branch to the
master
branch). - Now, let's merge one of the PRs and update the remaining PRs accordingly, as given below:
- Merge one of the PRs on GitHub e.g., Level-8. Remember to choose the
Create merge commit
option when merging. - Pull the updated
master
branch from your fork to your Computer. - Note how the remaining un-merged branches are no longer in sync with the latest
master
. To rectify, merge themaster
branch to each of them. Resolve merge conflicts, if any. - Push the updated branches to your fork. The PRs will update automatically to reflect the updated branch.
- As before, tag the merge commit in the master branch and push the tag to your fork.
- Merge one of the PRs on GitHub e.g., Level-8. Remember to choose the
- Merge the remaining PRs using a procedure similar to the above.
- First, do each increment as a parallel branch (i.e.,
Level-8
: Dates and Times optional
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.
- Minimal: Store deadline dates as a
java.time.LocalDate
in your task objects. Accept dates in a format such asyyyy-mm-dd
format (e.g.,2019-10-15
) and print in a different format such asMMM dd yyyy
e.g., (Oct 15 2019
). - Stretch goal: Use dates and times in more meaningful ways. e.g., add a command to print deadlines/events occurring on a specific date.
Using dates/times in Java
A code snippet using the LocalDate
class:
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
public class Main {
public static void main(String[] args) {
//create dates from strings
LocalDate d1 = LocalDate.parse("2019-12-01");
LocalDate d2 = LocalDate.parse("2019-12-02");
LocalDate d3 = LocalDate.parse("2019-12-02");
//compare dates
System.out.println(d1.isBefore(d2)); // -> true
System.out.println(d1.isAfter(d2)); // -> false
System.out.println(d2.equals(d3)); // -> true
//work with dates
System.out.println(d1.getDayOfWeek()); // -> SUNDAY
System.out.println(d1.getMonth()); // -> DECEMBER
System.out.println(d1.plus(1, ChronoUnit.YEARS)); // -> 2020-12-01
// get today's date and print it in a specific format
LocalDate d4 = LocalDate.now();
System.out.println(d4); // -> 2019-10-15
System.out.println(d4.format(DateTimeFormatter.ofPattern("MMM d yyyy"))); // -> Oct 15 2019
}
}
Level-9
: Find
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)
____________________________________________________________
3 Add a brief user guide
A-UserGuide
: 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. Note: it could take 5-10 minutes for GitHub to update the page.
4 Release the product by Monday (March 2) 1200
- Create a new jar file. The jar file should be cross-platform and should work in a computer that has Java 11.
- Do the following smoke tests to ensure the jar file works (reason: it will be used to grade your iP).
- Copy the jar file to an empty folder and test it from there. This should surface issues with hard-coded file paths.
- Pass the jar file to team members and ask them to do a test drive. Assuming some of your team members' OS differ from yours, this should verify if the app is cross-platform.
- Create a new release on GitHub (e.g.,
v0.2
) and upload the jar file.