Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rebecca Lau] iP #476

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
dce5cee
Level-1
rebeccalaujx Aug 19, 2021
247ac39
Level-2
rebeccalaujx Aug 19, 2021
78ea29d
Level-3
rebeccalaujx Aug 19, 2021
f15709b
Level-3
rebeccalaujx Aug 19, 2021
6a5d0e8
Level-4
rebeccalaujx Aug 19, 2021
0be4686
A-TextUiTesting
rebeccalaujx Aug 19, 2021
5cb8123
A-TextUiTesting
rebeccalaujx Aug 19, 2021
0c57b93
Level-5
rebeccalaujx Aug 19, 2021
310178c
Level-5
rebeccalaujx Aug 19, 2021
1cbdef7
Level-6
rebeccalaujx Aug 19, 2021
fd0bb3d
save tasks to hard disk
rebeccalaujx Aug 28, 2021
2ae58cc
changes dates into a MMM dd yyyy format
rebeccalaujx Aug 30, 2021
2fcd257
save tasks to disk
rebeccalaujx Aug 30, 2021
f2aedc3
merged branch 7
rebeccalaujx Aug 30, 2021
e6a51b1
change dates to MMM dd yyyy format
rebeccalaujx Aug 30, 2021
fe0ff94
merged branch 8
rebeccalaujx Aug 30, 2021
e4ad385
add more OOP
rebeccalaujx Sep 1, 2021
8e90406
added some OOP
rebeccalaujx Sep 1, 2021
c27673f
added more oop
rebeccalaujx Sep 1, 2021
7fb685b
add files to packages
rebeccalaujx Sep 1, 2021
cb8b508
added JUnit tests
rebeccalaujx Sep 1, 2021
e48c0b5
packaged the app as an executable JAR file
rebeccalaujx Sep 1, 2021
b4758be
added JavaDocs
rebeccalaujx Sep 2, 2021
f14f614
Tweaked the code to comply with a coding standard
rebeccalaujx Sep 2, 2021
db642c7
Gave users a way to find a task by searching for a keyword
rebeccalaujx Sep 2, 2021
80db064
Merge branch 'branch-A-JavaDoc' and 'branch-A-CodingStandard'
rebeccalaujx Sep 2, 2021
621657a
Merge branch 'branch-Level-9'
rebeccalaujx Sep 2, 2021
07cb01c
Merge branch 'add-gradle-support' of https://github.com/rebeccalaujx/…
rebeccalaujx Sep 5, 2021
87995c8
Automate project builds using Gradle and fixed some checkstyle errors
rebeccalaujx Sep 6, 2021
db907f2
fixed checkstyle issues
rebeccalaujx Sep 6, 2021
9cf988a
created basic GUI for Duke
rebeccalaujx Sep 6, 2021
c6cc3a3
used FXML for GUI
rebeccalaujx Sep 7, 2021
0972eb4
merge branch-Level-10
rebeccalaujx Sep 7, 2021
a4dd0df
Ui class: cleaned up comments
rebeccalaujx Sep 16, 2021
cc9a2e4
Add assertions feature
rebeccalaujx Sep 16, 2021
2f301dd
Improve code quality
rebeccalaujx Sep 16, 2021
20a4b9e
Merge pull request #2 from rebeccalaujx/branch-Assertions
rebeccalaujx Sep 16, 2021
b77329f
Merge pull request #1 from rebeccalaujx/branch-Assertions
rebeccalaujx Sep 16, 2021
c053484
Merge branch 'master' into branch-Assertions and branch-CodeQuality
rebeccalaujx Sep 16, 2021
2ef64a7
Merge pull request #3 from rebeccalaujx/branch-CodeQuality
rebeccalaujx Sep 16, 2021
f29ff73
Add C-MassOps
rebeccalaujx Sep 16, 2021
35b27e9
Add varargs
rebeccalaujx Sep 16, 2021
86cd0e0
Update docs/README.md
rebeccalaujx Sep 17, 2021
9931a27
Update docs/README.md
rebeccalaujx Sep 17, 2021
2e44079
Update docs/README.md
rebeccalaujx Sep 17, 2021
fcab3b7
Update docs/README.md
rebeccalaujx Sep 17, 2021
764206d
Add Ui.png
rebeccalaujx Sep 17, 2021
7f34564
Fix Storage function
rebeccalaujx Sep 17, 2021
9dcab1a
Update JavaDocs
rebeccalaujx Sep 17, 2021
308fc97
Improve GUI
rebeccalaujx Sep 17, 2021
454e98a
Fix Storage
rebeccalaujx Sep 17, 2021
1bb04c1
change class path
rebeccalaujx Sep 17, 2021
1e77943
fix Storage
rebeccalaujx Sep 17, 2021
da29a26
Update Ui.png
rebeccalaujx Sep 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# duke.Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
3. After that, locate the `src/main/java/duke.Duke.java` file, right-click it, and choose `Run duke.Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
4 changes: 0 additions & 4 deletions duke.txt
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
T | 1 | read book
D | 0 | return book | June 6th
E | 0 | project meeting | Aug 6th 2-4pm
T | 1 | join sports club
5 changes: 5 additions & 0 deletions src/main/java/Duke.java → src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package duke;

import duke.command.Command;
import duke.task.TaskList;

import java.io.IOException;

public class Duke {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

public class DukeException extends Exception {
public DukeException(String message) {
super(message);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/Parser.java → src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke;

import duke.command.*;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to specifically list all duke.command imports here instead of using wildcard imports

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to not use wildcard for the import? It might be better to list all the stuff you want to import.


public class Parser {
public static Command parse(String input) throws DukeException {
if (input.equals("bye")) {
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/Storage.java → src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package duke;

import duke.task.*;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to specifically list imports as before

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to list all the stuff you want to import instead of using wildcard.


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Storage {
Expand Down Expand Up @@ -32,12 +35,12 @@ public void rewriteFile(TaskList ls) {
String desc = task.getDesc();
String addOns = task.addOns();
if (type == "todo") {
writer.println("T" + (task.isDone ? " | 1 | " : " | 0 | ") + desc);
writer.println("T" + (task.checkIfDone() ? " | 1 | " : " | 0 | ") + desc);
} else if (type == "deadline") {
writer.println("D" + (ls.getTask(i).isDone ? " | 1 | " : " | 0 | ")
writer.println("D" + (ls.getTask(i).checkIfDone() ? " | 1 | " : " | 0 | ")
+ desc + " | " + addOns);
} else if (type == "event") {
writer.println("E" + (task.isDone ? " | 1 | " : " | 0 | ")
writer.println("E" + (task.checkIfDone() ? " | 1 | " : " | 0 | ")
+ desc + " | " + addOns);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/Ui.java → src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package duke;

import duke.task.Task;
import duke.task.TaskList;

import java.util.Scanner;

public class Ui {
Expand All @@ -15,7 +20,7 @@ public void showWelcome() {
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("Hello! I'm Duke\n" + "What can I do for you?");
System.out.println("Hello! I'm duke.Duke\n" + "What can I do for you?");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may import the duke package inside, and you not really have to specify package all the time.

}

public void goodbye() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;
import duke.task.TaskList;
import duke.Ui;
import duke.Storage;
import duke.DukeException;

public abstract class Command {
public abstract void execute(TaskList ls, Ui ui, Storage storage) throws DukeException;
public abstract boolean isExit();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all but one of the commands have isExit() as false, this can be made into a non-abstract method.

Suggested change
public abstract boolean isExit();
public boolean isExit() {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;
import duke.task.Deadline;

public class DeadlineCommand extends Command {

private String input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;
import duke.task.Task;

public class DeleteCommand extends Command {
private String input;
private int taskNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;
import duke.task.Task;

public class DoneCommand extends Command {
private String input;
private int taskNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;

public class ErrorCommand extends Command {
@Override
public void execute(TaskList ls, Ui ui, Storage storage) throws DukeException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;
import duke.task.Event;

public class EventCommand extends Command {
private String input;
private String taskDesc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;

public class ExitCommand extends Command {
@Override
public void execute(TaskList ls, Ui ui, Storage storage) throws DukeException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;

public class ListCommand extends Command {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package duke.command;
import duke.Ui;
import duke.Storage;
import duke.DukeException;
import duke.task.TaskList;
import duke.task.Todo;


public class TodoCommand extends Command {
private String input;
private String taskDesc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package duke.task;
import duke.DukeException;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
Expand All @@ -14,7 +17,7 @@ public Deadline(String description, String deadline) throws DukeException {
LocalDate localDate = LocalDate.parse(deadline);
this.date = localDate.format(DateTimeFormatter.ofPattern("MMM dd yyyy"));
} catch (DateTimeParseException e) {
throw new DukeException("Deadline should be in a yyyy-mm-dd format.");
throw new DukeException("duke.task.Deadline should be in a yyyy-mm-dd format.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may import duke.task here.

}

if (description.isEmpty() || description == "" || description == " ") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package duke.task;
import duke.DukeException;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
Expand All @@ -14,7 +17,7 @@ public Event(String description, String at) throws DukeException {
LocalDate localDate = LocalDate.parse(at);
this.date = localDate.format(DateTimeFormatter.ofPattern("MMM dd yyyy"));
} catch (DateTimeParseException e) {
throw new DukeException("Event date should be in a yyyy-mm-dd format.");
throw new DukeException("duke.task.Event date should be in a yyyy-mm-dd format.");
}

if (description.isEmpty() || description == "" || description == " ") {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/Task.java → src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

abstract public class Task {
protected String description;
protected boolean isDone;
Expand Down Expand Up @@ -25,6 +27,10 @@ public void markAsDone() {
System.out.println("Nice! I've marked this task as done: \n" + this.toString());
}

public boolean checkIfDone() {
return this.isDone;
}

public String getType() {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package duke.task;
import duke.Ui;
import java.util.ArrayList;
import java.util.List;

public class TaskList {
private ArrayList<Task> tasklist;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/Todo.java → src/main/java/duke/task/Todo.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package duke.task;
import duke.DukeException;

public class Todo extends Task {

public Todo(String description) throws DukeException {
Expand Down
2 changes: 1 addition & 1 deletion text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Hello from
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

Hello! I'm Duke
Hello! I'm duke.Duke
What can I do for you?
Got it. I've added this task:
[T][ ] borrow book
Expand Down
2 changes: 1 addition & 1 deletion text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0

REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
java -classpath ..\bin duke.Duke < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT