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

[Grant Lee] A-CodeQuality #336

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 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
a3ca5a4
Add configuration for console applications
j-lum Aug 20, 2019
7b60e81
Merge pull request #13 from j-lum/javaexec
j-lum Aug 21, 2019
c4678f7
JavaFX tutorial: Support cross-platform JARs
j-lum Sep 20, 2019
30efbae
JavaFX tutorial: Support cross-platform JARs [#16]
damithc Oct 7, 2019
6b035d6
Complete level 1
grrrrnt Jan 23, 2020
a9df450
Complete level 2
grrrrnt Jan 23, 2020
94e2c64
Complete level 3
grrrrnt Jan 23, 2020
528c331
Complete level 4
grrrrnt Jan 23, 2020
4b9bde2
Complete level 5
grrrrnt Jan 23, 2020
ba78bcd
Complete level 6
grrrrnt Jan 23, 2020
ac6e6aa
Complete automated text UI testing
grrrrnt Jan 29, 2020
886192d
Complete Level-7
grrrrnt Jan 30, 2020
91c538f
Complete Level-8
grrrrnt Jan 30, 2020
149fb0a
Merge master and branch-Level-7
grrrrnt Jan 30, 2020
c0ebbe4
Merge master and branch-Level-8
grrrrnt Jan 30, 2020
0944243
Complete A-MoreOOP
grrrrnt Jan 30, 2020
7f4d11a
Merge remote-tracking branch 'origin/gradle'
grrrrnt Jan 30, 2020
8801225
Add JUnit tests
grrrrnt Feb 2, 2020
f7a954e
Add JavaDoc comments
grrrrnt Feb 6, 2020
67a8283
Tweak code to comply with camelCase
grrrrnt Feb 6, 2020
6d0990d
Complete level 9
grrrrnt Feb 6, 2020
1820d0d
Merge branch 'branch-A-JavaDoc'
grrrrnt Feb 6, 2020
16e5e53
Merge branch 'branch-A-CodingStandard'
grrrrnt Feb 6, 2020
7e75527
Merge branch 'branch-Level-9'
grrrrnt Feb 6, 2020
51210e7
Complete level 10, except getResponse() implementation
grrrrnt Feb 6, 2020
a021641
Complete level 10 (including FXML)
grrrrnt Feb 9, 2020
e4ae347
Add a few assertions
grrrrnt Feb 13, 2020
f81adae
Merge pull request #5 from grrrrnt/branch-Assertions
grrrrnt Feb 13, 2020
babb3b1
Improve code quality
grrrrnt Feb 20, 2020
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
Prev Previous commit
Improve code quality
grrrrnt committed Feb 20, 2020
commit babb3b19e5b0bb3add91572c05c45b2b1813e6d7
10 changes: 0 additions & 10 deletions src/main/java/DeadlineException.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@ public DukeException() {

@Override
public String getMessage(){
return "\u2639 OOPS!!! I'm sorry, but I don't know what that means :-(";
return "\u2639 OOPS!!! I'm sorry, but I don't recognise that command :-(";
}
}
10 changes: 10 additions & 0 deletions src/main/java/EmptyDescriptionException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class EmptyDescriptionException extends DukeException {
public EmptyDescriptionException() {
super();
}

@Override
public String getMessage(){
return "\u2639 OOPS!!! The description cannot be empty.";
}
}
10 changes: 0 additions & 10 deletions src/main/java/EventException.java

This file was deleted.

24 changes: 13 additions & 11 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
@@ -22,25 +22,27 @@ public class Parser {
*/
public String parseInput(String input) throws DukeException {
String msg = "";
String[] inputParts = input.split(" ");
String command = inputParts[0];
if (input.equals("list")) {
msg = taskList.showList();
} else if (input.split(" ")[0].equals("done")) {
int taskNum = Integer.parseInt(input.split(" ")[1]);
} else if (command.equals("done")) {
int taskNum = Integer.parseInt(inputParts[1]);
msg = taskList.done(taskNum);
} else if (input.split(" ")[0].equals("todo") ||
input.split(" ")[0].equals("event") ||
input.split(" ")[0].equals("deadline")) {
} else if (command.equals("todo") ||
command.equals("event") ||
command.equals("deadline")) {
msg = taskList.add(input);
} else if (input.split(" ")[0].equals("delete")) {
int taskNum = Integer.parseInt(input.split(" ")[1]);
} else if (command.equals("delete")) {
int taskNum = Integer.parseInt(inputParts[1]);
msg = taskList.delete(taskNum);
} else if (input.split(" ")[0].equals("find")) {
String query = input.split(" ")[1];
} else if (command.equals("find")) {
String query = inputParts[1];
msg = taskList.find(query);
} else if (input.split(" ")[0].equals("bye")) {
} else if (command.equals("bye")) {
msg = "Bye. Hope to serve you again soon!";
} else {
throw new DukeException();
throw new UnrecognisedCommandException();
}
assert ! msg.equals("") : "Response is not empty";
return msg;
28 changes: 13 additions & 15 deletions src/main/java/TaskList.java
Original file line number Diff line number Diff line change
@@ -34,30 +34,28 @@ public TaskList(Ui ui, Storage storage) {
* @throws DukeException If string format is invalid.
*/
public String add(String s) throws DukeException {
String typeOfTask = s.split(" ", 2)[0];
String[] taskParts = s.split(" ", 2);
String taskType = taskParts[0];
Task toAdd = new Task();
if (typeOfTask.equals("todo")) {
if (taskType.equals("todo")) {
try {
String task = s.split(" ", 2)[1];
toAdd = new Todo(task);
toAdd = new Todo(taskParts[1]);
} catch (ArrayIndexOutOfBoundsException e) {
throw new TodoException();
throw new EmptyDescriptionException();
}
} else if (typeOfTask.equals("event")) {
} else if (taskType.equals("event")) {
try {
String task = s.split(" ", 2)[1];
String[] taskParts = task.split(" /at ");
toAdd = new Event(taskParts[0], taskParts[1]);
String[] taskInfo = taskParts[1].split(" /at ");
toAdd = new Event(taskInfo[0], taskInfo[1]);
} catch (ArrayIndexOutOfBoundsException e) {
throw new EventException();
throw new EmptyDescriptionException();
}
} else if (typeOfTask.equals("deadline")) {
} else if (taskType.equals("deadline")) {
try {
String task = s.split(" ", 2)[1];
String[] taskParts = task.split(" /by ");
toAdd = new Deadline(taskParts[0], taskParts[1]);
String[] taskInfo = taskParts[1].split(" /by ");
toAdd = new Deadline(taskInfo[0], taskInfo[1]);
} catch (ArrayIndexOutOfBoundsException e) {
throw new DeadlineException();
throw new EmptyDescriptionException();
}
}
taskList.add(toAdd);
10 changes: 0 additions & 10 deletions src/main/java/TodoException.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/Ui.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import java.io.InputStream;
import java.util.Scanner;

/**
* Represents an interface to facilitate user input and output.
*/
public class Ui {
private Scanner sc;

public Ui() {}

/**
* Prints string.
*
* @param s String to print.
*/
public void print(String s) {
System.out.println(s);
}

/**
* Prints error message.
*
@@ -27,22 +12,4 @@ public void print(String s) {
public String showError(Exception e) {
return "Something went wrong: " + e.getMessage();
}

/**
* Sets input stream.
*
* @param in Input stream to set.
*/
public void setInput(InputStream in) {
sc = new Scanner(in);
}

/**
* Returns next line from input stream.
*
* @return Next line from input stream.
*/
public String getLine() {
return sc.nextLine();
}
}
10 changes: 10 additions & 0 deletions src/main/java/UnrecognisedCommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class UnrecognisedCommandException extends DukeException {
public UnrecognisedCommandException() {
super();
}

@Override
public String getMessage(){
return "\u2639 OOPS!!! I'm sorry, but I don't know what that means :-(";
}
}
2 changes: 1 addition & 1 deletion tutorials/gradleTutorial.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
de# Gradle Tutorial
# Gradle Tutorial

Gradle is a _build automation tool_ used to automate build processes. There are many ways of integrating Gradle into a project. In this guide, we will be using the _Gradle wrapper_.