-
Notifications
You must be signed in to change notification settings - Fork 438
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
[Li Beining] iP #453
Open
dearvae
wants to merge
39
commits into
nus-cs2103-AY2021S1:master
Choose a base branch
from
dearvae:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Li Beining] iP #453
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3b19ba1
Add Gradle support
6433366
feat(main):Greet, Echo, Exit
dearvae 2c6280c
feat(main):Add, List
dearvae a98a4aa
feat(Task): added new class Task
dearvae 35cac77
feat(main):added ToDos, Events, Deadlines
dearvae 167076e
test: added text-ui-test
dearvae d1fd443
feat(DukeException): added exception handle
dearvae e7b3189
feat(main):added delete
dearvae 5000858
added enum and beautify code
dearvae c016462
add fileHelper and TaskList
dearvae ce40f56
deadline added dateTime
dearvae 63df09e
merge branch level 8 to master
dearvae 340c39e
make code more OOP
dearvae f9224cb
Divide classes into packages
dearvae 5cebe5f
add Junit test for parser
dearvae 0280f8e
Add JavaDoc comments
dearvae 37c6aed
tweak the code to comply coding standard
dearvae 1bea932
add feature find task by keyword
dearvae 55fb07a
fix merge conflict
dearvae 199363e
fix merge conflicts
dearvae 3456e73
merge add_gradle_support
dearvae d9b7eaf
add GUI for Duke
dearvae 6344b5f
fix bug
dearvae 4e1a5f6
refactor code to comply javastandard style
dearvae 15a0ebf
(TaskList) add assertion
dearvae 3398724
Merge pull request #1 from dearvae/branch-A-Assertions
dearvae 2171b87
refractor code for better codeQuality
dearvae df0f331
merge with master
dearvae ebee7eb
Merge pull request #2 from dearvae/branch-A-CodeQuality
dearvae b27cbc5
add extension help command
dearvae 064e9bd
Merge pull request #3 from dearvae/branch-Extension
dearvae 2ede15c
rename to KK
dearvae ddfa302
Update README.md
dearvae 06cd463
Set theme jekyll-theme-leap-day
dearvae 6fac0a1
add ui.png
dearvae c722ee3
update userguide
dearvae 7b5db87
updated UI
dearvae f19f18a
update exception when create deadline object
dearvae 2331709
fix bugs raised by peer comment
dearvae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
T | 1 | return book | ||
T | 1 | yoyo | ||
T | 1 | dsadas | ||
E | 1 | dsadsad | dasdsadas dsad | ||
D | 1 | dsdasd | 2/12/2010 17:22 | ||
T | 0 | dsadas | ||
E | 0 | dsadas | dsad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,41 @@ | ||
import Duke.command.Command; | ||
import Duke.exceptions.DukeException; | ||
import Duke.task.TaskList; | ||
import Duke.utils.Parser; | ||
import Duke.utils.Ui; | ||
|
||
public class Duke { | ||
|
||
private TaskList tasks; | ||
private Ui ui; | ||
|
||
public Duke(String path, String fileName) { | ||
ui = new Ui(); | ||
tasks = new TaskList(path, fileName); | ||
} | ||
|
||
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); | ||
isExit = c.isExit(); | ||
} catch (DukeException e) { | ||
ui.showError(e.getMessage()); | ||
} finally { | ||
ui.showLine(); | ||
} | ||
} | ||
|
||
ui.sayGoodBye(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
new Duke("data/", "duke.txt").run(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package Duke.command; | ||
|
||
import Duke.model.Deadline; | ||
import Duke.model.Event; | ||
import Duke.model.ToDo; | ||
import Duke.task.Task; | ||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public class AddCommand extends Command { | ||
String taskType; | ||
String info; | ||
|
||
public AddCommand(String taskType, String info) { | ||
this.taskType = taskType; | ||
this.info = info; | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void execute(TaskList tasks, Ui ui) { | ||
|
||
Task task; | ||
|
||
if(taskType.equals("todo")) { | ||
task = new ToDo(info); | ||
} else if(taskType.equals("deadline")) { | ||
String[] deadlineParts = info.split(" /by "); | ||
task = new Deadline(deadlineParts[0], deadlineParts[1]); | ||
} else { // event | ||
String[] eventParts = info.split(" /at "); | ||
task = new Event(eventParts[0], eventParts[1]); | ||
} | ||
|
||
tasks.addTask(task); | ||
|
||
ui.showAddMessage(task, tasks); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package Duke.command; | ||
|
||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public abstract class Command { | ||
public abstract boolean isExit(); | ||
public abstract void execute(TaskList tasks, Ui ui); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package Duke.command; | ||
|
||
import Duke.task.Task; | ||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public class DeleteCommand extends Command{ | ||
|
||
private int index; | ||
public DeleteCommand(int index) { | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void execute(TaskList tasks, Ui ui) { | ||
Task task = tasks.get(index); | ||
tasks.remove(index); | ||
ui.showRemovalMessage(task, tasks); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package Duke.command; | ||
|
||
import Duke.task.Task; | ||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public class DoneCommand extends Command { | ||
private int index; | ||
public DoneCommand(int index) { | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void execute(TaskList tasks, Ui ui) { | ||
Task task = tasks.get(index); | ||
tasks.markAsDone(index); | ||
ui.showDoneMessage(task); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package Duke.command; | ||
|
||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public class ExitCommand extends Command { | ||
@Override | ||
public boolean isExit() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void execute(TaskList tasks, Ui ui) { | ||
//do nothing | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package Duke.command; | ||
|
||
import Duke.task.TaskList; | ||
import Duke.utils.Ui; | ||
|
||
public class ListCommand extends Command { | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void execute(TaskList tasks, Ui ui) { | ||
ui.showListMessage(tasks); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package Duke.exceptions; | ||
|
||
public class DukeException extends Exception { | ||
public DukeException(String errorMessage) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can consider adding an empty line here so as to standardize with the rest of the files, just something trivial 👍 |
||
super(errorMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package Duke.model; | ||
|
||
import Duke.task.Task; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class Deadline extends Task { | ||
|
||
private String time; | ||
private LocalDate date; | ||
private LocalDateTime dateTime; | ||
|
||
public Deadline(String description, String time) { | ||
super(description); | ||
this.time = time; | ||
String[] parts = time.split(" "); | ||
String[] timeParts = parts[1].split(":"); | ||
int hour = Integer.parseInt(timeParts[0]); | ||
int minute = Integer.parseInt(timeParts[1]); | ||
date = LocalDate.parse(parts[0], DateTimeFormatter.ofPattern("d/MM/yyyy")); | ||
dateTime = date.atTime(hour, minute); | ||
} | ||
|
||
public Deadline(boolean isDone, String description, String time) { | ||
super(isDone, description); | ||
this.time = time; | ||
String[] parts = time.split(" "); | ||
String[] timeParts = parts[1].split(":"); | ||
int hour = Integer.parseInt(timeParts[0]); | ||
int minute = Integer.parseInt(timeParts[1]); | ||
date = LocalDate.parse(parts[0], DateTimeFormatter.ofPattern("d/MM/yyyy")); | ||
dateTime = date.atTime(hour, minute); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[D]" + super.toString() + " (by: " + dateTime.format(DateTimeFormatter.ofPattern("MMM d yyyy, HH:mm")) + ")"; | ||
} | ||
|
||
@Override | ||
public String toStoreFormat(){ | ||
String type = "D"; | ||
String status = isDone ? "1" : "0"; | ||
String connect = " | "; | ||
return type + connect + status + connect + description + connect + time; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package Duke.model; | ||
|
||
import Duke.task.Task; | ||
|
||
public class Event extends Task { | ||
private String time; | ||
public Event(String description, String time) { | ||
super(description); | ||
this.time = time; | ||
} | ||
|
||
public Event(boolean isDone, String description, String time) { | ||
super(isDone, description); | ||
this.time = time; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[E]" + super.toString() + "(at: " + time + ")"; | ||
} | ||
|
||
@Override | ||
public String toStoreFormat(){ | ||
String type = "E"; | ||
String status = isDone ? "1" : "0"; | ||
String connect = " | "; | ||
return type + connect + status + connect + description + connect + time; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package Duke.model; | ||
|
||
import Duke.task.Task; | ||
|
||
public class ToDo extends Task { | ||
|
||
public ToDo(String description) { | ||
super(description); | ||
} | ||
|
||
public ToDo(boolean isDone, String description) { | ||
super(isDone, description); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[T]" + super.toString(); | ||
} | ||
|
||
@Override | ||
public String toStoreFormat(){ | ||
String type = "T"; | ||
String status = isDone ? "1" : "0"; | ||
String connect = " | "; | ||
return type + connect + status + connect + description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package Duke.task; | ||
|
||
public class Task { | ||
protected boolean isDone; | ||
protected String description; | ||
|
||
public Task(String description) { | ||
isDone = false; | ||
this.description = description; | ||
} | ||
|
||
public Task(boolean isDone, String description) { | ||
this.isDone = isDone; | ||
this.description = description; | ||
} | ||
|
||
public void markAsDone() { | ||
isDone = true; | ||
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols | ||
} | ||
|
||
public String toString() { | ||
return "[" + getStatusIcon() + "] " + description; | ||
} | ||
|
||
public String toStoreFormat(){ | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we privatize variables for encapsulation? If I'm not mistaken, its part of the coding standard that this mod enforces