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

[Chen Jiehan] Duke Increments #362

Open
wants to merge 131 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
65f72a8
Add support for Gradle workflow
j-lum Aug 6, 2019
0112efe
Add sample checkstyle configuration
j-lum Aug 12, 2019
cfd6da7
Change file mode on `gradle` to be executable
j-lum Aug 18, 2019
6e6ace1
Merge pull request #12 from j-lum/gradle+x
j-lum Aug 18, 2019
edf8e35
Complete Level 1
Aug 21, 2019
ddaef0b
Complete Level 2
Aug 21, 2019
8249041
Complete Level 3
Aug 22, 2019
0600a98
Complete Level 4
Aug 22, 2019
4413d92
Complete Level 5
Aug 22, 2019
13b8591
Complete Level 6
Aug 22, 2019
769b127
Complete Level 7
Aug 26, 2019
a1fd1d8
Complete Level 8
Aug 26, 2019
4d80d71
Merge branch 'branch-Level-8'
Aug 26, 2019
68d6643
A-MoreOOP
Sep 1, 2019
62e7419
A-Packages
Sep 1, 2019
86bfb0c
JUnit
Sep 1, 2019
6881d44
Fix some bugs
Sep 1, 2019
ea0ad5e
Javadoc
Sep 3, 2019
92b4e16
branch-A-CodingStandard
Sep 3, 2019
dfded26
branch-Level-9
Sep 3, 2019
00bba16
resolve merge conflicts
Sep 3, 2019
876163f
Merge branch 'branch-Level-9'
Sep 3, 2019
b11c1a7
Delete DeleteCommandTest.html
ChenJiehan318 Sep 3, 2019
247ea35
Delete type-search-index.zip
ChenJiehan318 Sep 3, 2019
e782c6e
Delete type-search-index.js
ChenJiehan318 Sep 3, 2019
7912df8
Delete stylesheet.css
ChenJiehan318 Sep 3, 2019
66cc53b
Delete serialized-form.html
ChenJiehan318 Sep 3, 2019
4290a0d
Delete search.js
ChenJiehan318 Sep 3, 2019
9008d34
Delete script.js
ChenJiehan318 Sep 3, 2019
558bd01
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
afd75d8
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
36e3558
Delete package-search-index.zip
ChenJiehan318 Sep 3, 2019
5ef995e
Delete package-search-index.js
ChenJiehan318 Sep 3, 2019
d4c0bef
Delete overview-tree.html
ChenJiehan318 Sep 3, 2019
4daec44
Delete overview-summary.html
ChenJiehan318 Sep 3, 2019
4f3758e
Delete member-search-index.zip
ChenJiehan318 Sep 3, 2019
f0d7e18
Delete deprecated-list.html
ChenJiehan318 Sep 3, 2019
10b8524
Delete help-doc.html
ChenJiehan318 Sep 3, 2019
ec81315
Delete member-search-index.js
ChenJiehan318 Sep 3, 2019
6ff5507
Delete index.html
ChenJiehan318 Sep 3, 2019
d3cefaa
Delete element-list
ChenJiehan318 Sep 3, 2019
8b4966e
Delete allclasses-index.html
ChenJiehan318 Sep 3, 2019
656e9f6
Delete constant-values.html
ChenJiehan318 Sep 3, 2019
dd39bb3
Delete allpackages-index.html
ChenJiehan318 Sep 3, 2019
322cb82
Delete TaskTest.html
ChenJiehan318 Sep 3, 2019
352b017
Delete Duke.html
ChenJiehan318 Sep 3, 2019
5716618
Delete AddCommand.html
ChenJiehan318 Sep 3, 2019
da98b49
Delete ByeCommand.html
ChenJiehan318 Sep 3, 2019
1307230
Delete Command.html
ChenJiehan318 Sep 3, 2019
fad62f3
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
d5e69e2
Delete DoneCommand.html
ChenJiehan318 Sep 3, 2019
54a8a50
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
e434d43
Delete ListCommand.html
ChenJiehan318 Sep 3, 2019
a114bcc
Delete DeleteCommand.html
ChenJiehan318 Sep 3, 2019
3233f26
Delete DukeException.html
ChenJiehan318 Sep 3, 2019
e5b3ff5
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
e9d1ff1
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
e5f9a1e
Delete Parser.html
ChenJiehan318 Sep 3, 2019
a01bddc
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
483cac0
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
99dbc77
Delete Storage.html
ChenJiehan318 Sep 3, 2019
d16c6a9
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
3b22308
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
8485586
Delete Deadlines.html
ChenJiehan318 Sep 3, 2019
5b10689
Delete TaskList.html
ChenJiehan318 Sep 3, 2019
44bfc14
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
8a857d9
Delete Task.html
ChenJiehan318 Sep 3, 2019
385b9db
Delete Events.html
ChenJiehan318 Sep 3, 2019
5b0f571
Delete ToDos.html
ChenJiehan318 Sep 3, 2019
5d4a99d
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
15f5e14
Delete glass.png
ChenJiehan318 Sep 3, 2019
36bb766
Delete x.png
ChenJiehan318 Sep 3, 2019
0bb979e
Delete jquery.js
ChenJiehan318 Sep 3, 2019
ac05a15
Delete jquery-ui.structure.min.css
ChenJiehan318 Sep 3, 2019
8f379ba
Delete jquery-ui.structure.css
ChenJiehan318 Sep 3, 2019
1549dc2
Delete jquery-ui.js
ChenJiehan318 Sep 3, 2019
8617092
Delete jquery-ui.min.js
ChenJiehan318 Sep 3, 2019
f9dcad8
Delete ui-icons_cd0a0a_256x240.png
ChenJiehan318 Sep 3, 2019
f2ea70f
Delete ui-bg_glass_75_e6e6e6_1x400.png
ChenJiehan318 Sep 3, 2019
1b93ddc
Delete ui-bg_highlight-soft_75_cccccc_1x100.png
ChenJiehan318 Sep 3, 2019
dd1f236
Delete Ui.html
ChenJiehan318 Sep 3, 2019
9be4104
Delete package-summary.html
ChenJiehan318 Sep 3, 2019
ba3183b
Delete package-tree.html
ChenJiehan318 Sep 3, 2019
3a5cab1
Delete index-1.html
ChenJiehan318 Sep 3, 2019
d53b38a
Delete jquery-ui.min.css
ChenJiehan318 Sep 3, 2019
c1dadb7
Delete jquery-ui.css
ChenJiehan318 Sep 3, 2019
1f202de
Delete jquery-migrate-3.0.1.js
ChenJiehan318 Sep 3, 2019
1cd06f2
Delete jquery-3.3.1.js
ChenJiehan318 Sep 3, 2019
e5ea096
Delete index-10.html
ChenJiehan318 Sep 3, 2019
552686d
Delete index-11.html
ChenJiehan318 Sep 3, 2019
fc037a9
Delete index-9.html
ChenJiehan318 Sep 4, 2019
eb6abf7
Delete index-8.html
ChenJiehan318 Sep 4, 2019
c75971f
Delete index-7.html
ChenJiehan318 Sep 4, 2019
66153f2
Delete index-6.html
ChenJiehan318 Sep 4, 2019
500b483
Delete index-5.html
ChenJiehan318 Sep 4, 2019
aee1d67
Delete index-4.html
ChenJiehan318 Sep 4, 2019
e9ded6e
Delete index-3.html
ChenJiehan318 Sep 4, 2019
f7ea9e4
Delete index-2.html
ChenJiehan318 Sep 4, 2019
e085c39
Delete index-12.html
ChenJiehan318 Sep 4, 2019
673c164
Delete index-15.html
ChenJiehan318 Sep 4, 2019
29c1e9e
Delete index-13.html
ChenJiehan318 Sep 4, 2019
0874001
Delete index-16.html
ChenJiehan318 Sep 4, 2019
8038122
Delete index-14.html
ChenJiehan318 Sep 4, 2019
9528088
Delete ui-bg_glass_55_fbf9ee_1x400.png
ChenJiehan318 Sep 4, 2019
9ae7d3b
Delete ui-bg_glass_65_dadada_1x400.png
ChenJiehan318 Sep 4, 2019
752a306
Delete ui-bg_glass_75_dadada_1x400.png
ChenJiehan318 Sep 4, 2019
fb35ceb
Delete ui-bg_glass_95_fef1ec_1x400.png
ChenJiehan318 Sep 4, 2019
c972bcb
Delete ui-icons_222222_256x240.png
ChenJiehan318 Sep 4, 2019
dc02c20
Delete ui-icons_2e83ff_256x240.png
ChenJiehan318 Sep 4, 2019
67ca51d
Delete ui-icons_454545_256x240.png
ChenJiehan318 Sep 4, 2019
335be23
Delete ui-icons_888888_256x240.png
ChenJiehan318 Sep 4, 2019
81d6360
Delete jszip-utils-ie.js
ChenJiehan318 Sep 4, 2019
ea0f657
Delete jszip-utils.js
ChenJiehan318 Sep 4, 2019
072bb1f
Delete jszip-utils-ie.min.js
ChenJiehan318 Sep 4, 2019
f98eb10
Delete jszip-utils.min.js
ChenJiehan318 Sep 4, 2019
81112fc
Delete jszip.js
ChenJiehan318 Sep 4, 2019
04d981d
Delete jszip.min.js
ChenJiehan318 Sep 4, 2019
9d23054
Add Gui
Sep 11, 2019
b0a1494
Merge branch 'master' of https://github.com/ChenJiehan318/duke
Sep 11, 2019
faeff8a
update dialogbox
Sep 11, 2019
8396d41
FXML
Sep 11, 2019
21eff20
A-Assertions
Sep 17, 2019
b78a57b
Merge pull request #5 from ChenJiehan318/A-Assertions
ChenJiehan318 Sep 17, 2019
288f22b
A-CodeQuality
Sep 17, 2019
8983823
Merge pull request #6 from ChenJiehan318/A-CodeQuality
ChenJiehan318 Sep 17, 2019
9eec2a9
C-FriendlierSyntax
Sep 17, 2019
b1f41cc
Merge pull request #7 from ChenJiehan318/C-FriendlierSyntax
ChenJiehan318 Sep 17, 2019
6295dbc
Add files via upload
ChenJiehan318 Sep 17, 2019
e0035da
Update README.md
ChenJiehan318 Sep 17, 2019
d9dd7e2
Set theme jekyll-theme-hacker
ChenJiehan318 Sep 17, 2019
e18cfca
Add files via upload
ChenJiehan318 Oct 2, 2019
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
Binary file added duke.jar
Binary file not shown.
41 changes: 41 additions & 0 deletions src/main/java/Command/AddCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package Command;
Copy link

Choose a reason for hiding this comment

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

Package naming should begin with small letter to avoid conflict with names of classes or interfaces.


import Storage.Storage;
import TaskList.TaskList;
import TaskList.Task;
import Ui.Ui;

import java.io.IOException;

public class AddCommand extends Command {

protected Task task;

public AddCommand(Task task) {
this.task = task;
}

/**
* execute the command of adding task
Copy link

Choose a reason for hiding this comment

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

Incomplete JavaDocs, should give clearer description.

* @param taskList
* @param ui
* @param storage
* @throws IOException
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
taskList.addList(task);
ui.showAddedMessage(taskList, task);
storage.save(taskList);
}

/**
*
Copy link

Choose a reason for hiding this comment

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

Missing method description

* @return boolean
*
*/
@Override
public boolean isExit() {
return isExit;
}
}
20 changes: 20 additions & 0 deletions src/main/java/Command/ByeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

public class ByeCommand extends Command {

public ByeCommand() {}

@Override
public void execute(TaskList t, Ui ui, Storage storage) {
ui.showGoodbye();
}

@Override
public boolean isExit() {
return isExit;
}
}
18 changes: 18 additions & 0 deletions src/main/java/Command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

import java.io.IOException;

public abstract class Command {

protected boolean isExit = false;

public Command() {}

public abstract void execute(TaskList t, Ui ui, Storage storage) throws IOException;
Copy link

Choose a reason for hiding this comment

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

One suggestion is to allow this method to be overloaded, since not every command will require all 3 parameters to be used.


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.

Ideally, the name of the method should not be the same as the variable name

}
39 changes: 39 additions & 0 deletions src/main/java/Command/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

import java.io.IOException;

public class DeleteCommand extends Command {

private int taskNo;
Copy link

Choose a reason for hiding this comment

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

Variable naming could be clearer, something like taskNumber


public DeleteCommand(int taskNo) {
this.taskNo = taskNo;
}

/**
* execute the command of deleting the task
* @param taskList
* @param ui
* @param storage
* @throws IOException
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
ui.showDeleteMessage(taskList, taskList.list.get(taskNo - 1));
taskList.delete(taskNo);
storage.save(taskList);
}

/**
* check if it is exited
* @return boolean
*/
@Override
public boolean isExit() {
return isExit;
}
}
35 changes: 35 additions & 0 deletions src/main/java/Command/DoneCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

import java.io.IOException;

public class DoneCommand extends Command {

private int taskNo;

public DoneCommand(int taskNo) {
this.taskNo = taskNo;
}

/**
* execute the command of marking a task as done
* @param taskList
* @param ui
* @param storage
* @throws IOException
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
taskList.list.get(taskNo - 1).markAsDone();
ui.showDoneMessage(taskList.list.get(taskNo - 1));
storage.save(taskList);
}

@Override
public boolean isExit() {
return isExit;
}
}
29 changes: 29 additions & 0 deletions src/main/java/Command/FindCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;
import TaskList.Task;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class FindCommand extends Command{
private String word;

public FindCommand(String word) {
this.word = word;
}

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
ui.showFindMessage(taskList.contains(word));
}

@Override
public boolean isExit() {
return false;
}

}
30 changes: 30 additions & 0 deletions src/main/java/Command/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Command;

import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

import java.io.IOException;

public class ListCommand extends Command {

public ListCommand() {
}

/**
* execute the command of listing out all the task
* @param taskList
* @param ui
* @param storage
* @throws IOException
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
ui.showListMessage(taskList);
}

@Override
public boolean isExit() {
return isExit;
}
}
65 changes: 57 additions & 8 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,59 @@
import Command.Command;
Copy link

Choose a reason for hiding this comment

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

This file has incorrect indentation level, plus multiple lines of unnecessary newlines.

import Parser.Parser;
import Storage.Storage;
import TaskList.TaskList;
import Ui.Ui;

import java.io.IOException;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

private Storage storage;
private TaskList tasks;
private Ui ui;

Copy link

Choose a reason for hiding this comment

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

Fields pertaining to Duke such as Storage, TaskList and Ui should be declared outside the main method block.

Copy link

Choose a reason for hiding this comment

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

I believe this is due to the incorrect indentation level

public Duke(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.load());
} catch (IOException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

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 (IOException e) {
ui.showError(e.getMessage());
} finally {
ui.showLine();
}
}
}

public static void main(String[] args) {
Copy link

Choose a reason for hiding this comment

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

File path should be one that is accessible with reference to duke as the root file, rather than your C: Drive

new Duke("/Users/jhchen/Documents/GitHub/duke/src/main/java/duke.txt").run();
}
}
}












10 changes: 10 additions & 0 deletions src/main/java/Duke/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package Duke;

public class DukeException extends Exception {
public DukeException(String s) {
super(s);
}

public DukeException() {
}
}
86 changes: 86 additions & 0 deletions src/main/java/Parser/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package Parser;
Copy link

Choose a reason for hiding this comment

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

This file has incorrect indentation level, and the end of the file should have one newline character for Git


import TaskList.Deadlines;
import TaskList.Events;
import TaskList.ToDos;
import Command.Command;
import Command.AddCommand;
import Command.ByeCommand;
import Command.DeleteCommand;
import Command.DoneCommand;
import Command.ListCommand;
import Command.FindCommand;

public class Parser {
public Parser() {}

/**
* Parse in the full command and return the command accordingly
* @param fullCommand
* @return Command
*/
public static Command parse(String fullCommand) {
int i = fullCommand.indexOf(' ');
String first = getFirstWord(fullCommand);
switch (first) {
Copy link

Choose a reason for hiding this comment

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

switch case indentation is off. Case should be aligned with switch, according to Java Coding Standard documentation.

case "delete":
return new DeleteCommand(Integer.parseInt(fullCommand.substring(i + 1)));
case "done":
return new DoneCommand(Integer.parseInt(fullCommand.substring(i + 1)));
case "list":
return new ListCommand();
case "bye":
return new ByeCommand();
case "find":
return new FindCommand(fullCommand.substring((i + 1)));
case "todo":
if (fullCommand.length() == 4) {
System.out.println("OOPS!!! The description of a todo cannot be empty.");
} else {
ToDos taskTodo = new ToDos(fullCommand.substring(i + 1));
taskTodo.setTaskType("T");
return new AddCommand(taskTodo);
}
case "deadline":
int j = fullCommand.indexOf("/");
int k = fullCommand.indexOf(" ");

if (fullCommand.length() == 8) {
System.out.println("OOPS!!! The description of a deadline cannot be empty.");
} else {
Deadlines taskDeadline = new Deadlines(fullCommand.substring(k + 1, j - 1));
taskDeadline.setTime(fullCommand.substring(j + 4));
taskDeadline.setTaskType("D");
return new AddCommand(taskDeadline);
}
case "event":
int p = fullCommand.indexOf("/");
int q = fullCommand.indexOf(" ");

if (fullCommand.length() == 5) {
System.out.println("OOPS!!! The description of an event cannot be empty.");
} else {
Events taskEvent = new Events(fullCommand.substring(q + 1, p - 1));
taskEvent.setTime(fullCommand.substring(p + 4));
taskEvent.setTaskType("E");
return new AddCommand(taskEvent);
}
default:
System.out.println("OOPS!!! I'm sorry, but I don't know what that means :-()");
return null;
}
}

/**
* to get the first word in a string of input
* @param input
* @return String
*/
public static String getFirstWord(String input) {
if (input.indexOf(" ") > -1) {
return input.substring(0, input.indexOf(" "));
} else {
return input;
}
}
}
Loading