diff --git a/src/main/java/duke/command/AddCommand.java b/src/main/java/duke/command/AddCommand.java
index db3e95f405..6b728309b1 100644
--- a/src/main/java/duke/command/AddCommand.java
+++ b/src/main/java/duke/command/AddCommand.java
@@ -2,6 +2,7 @@
import duke.task.Task;
import duke.functionality.TaskList;
+
/**
* Represents the add command. A AddCommand
object corresponds to adding that specified task
* to the taskList in the TaskList class.
@@ -10,10 +11,10 @@ public class AddCommand extends Command {
/**
* Constructor of AddCommand class.
- * @param t task object created from user input.
+ * @param task task object created from user input.
*/
- public AddCommand(Task t){
- super(t, null);
+ public AddCommand(Task task) {
+ super(task, null);
}
/**
diff --git a/src/main/java/duke/command/Command.java b/src/main/java/duke/command/Command.java
index 93431a5d56..04ec30f52a 100644
--- a/src/main/java/duke/command/Command.java
+++ b/src/main/java/duke/command/Command.java
@@ -12,11 +12,11 @@ public abstract class Command{
/**
* Constructor of Command class.
- * @param t task object created from user input.
+ * @param task task object created from user input.
* @param number an indicator to the index of the taskList in TaskList class.
*/
- public Command(Task t, Integer number) {
- this.task = t;
+ public Command(Task task, Integer number) {
+ this.task = task;
this.index = number;
}
diff --git a/src/main/java/duke/command/DeleteCommand.java b/src/main/java/duke/command/DeleteCommand.java
index 6bfda2d1fd..691815ea4c 100644
--- a/src/main/java/duke/command/DeleteCommand.java
+++ b/src/main/java/duke/command/DeleteCommand.java
@@ -13,7 +13,6 @@ public class DeleteCommand extends Command {
* @param number an indicator to the index of the taskList in TaskList class.
*/
public DeleteCommand(Integer number) {
-
super(null, number);
}
diff --git a/src/main/java/duke/command/UnmarkCommand.java b/src/main/java/duke/command/UnmarkCommand.java
index a39c15decb..92bc3a4fe0 100644
--- a/src/main/java/duke/command/UnmarkCommand.java
+++ b/src/main/java/duke/command/UnmarkCommand.java
@@ -1,6 +1,7 @@
package duke.command;
import duke.functionality.TaskList;
+
/**
* Represents the unmark command. A UnmarkCommand
object allows users to set the corresponding task as
* not done.
diff --git a/src/main/java/duke/functionality/Parser.java b/src/main/java/duke/functionality/Parser.java
index cba4717b45..1cc2c52d96 100644
--- a/src/main/java/duke/functionality/Parser.java
+++ b/src/main/java/duke/functionality/Parser.java
@@ -25,7 +25,6 @@
* to the actions taken to parse and format user inputs.
*/
public class Parser {
-
private static final int EVENT_OFFSET = 5;
private static final int TODO_OFFSET = 4;
private static final int DEADLINE_OFFSET = 8;
@@ -110,10 +109,10 @@ public static Command parse(String input) throws DukeException {
String[] splitDuration = durationInput.split(" ");
LocalDate date;
LocalTime time;
- try{
+ try {
date = formatDate(splitDuration[0]);
time = formatTime(splitDuration[1]);
- } catch(DateTimeParseException e) {
+ } catch (DateTimeParseException e) {
throw new DukeException("The expected input form is deadline ____ /by yyyy-mm-dd hhmm");
}
@@ -132,11 +131,11 @@ public static Command parse(String input) throws DukeException {
LocalDate date;
LocalTime startTime;
LocalTime endTime;
- try{
+ try {
date = formatDate(splitDuration[0]);
startTime = formatTime(splitDuration[1]);
endTime = formatTime(splitDuration[2]);
- } catch(DateTimeParseException e) {
+ } catch (DateTimeParseException e) {
throw new DukeException("The expected input form is event ____ /at yyyy-mm-dd hhmm hhmm");
}
diff --git a/src/main/java/duke/functionality/Storage.java b/src/main/java/duke/functionality/Storage.java
index d99e572c81..b4ae511463 100644
--- a/src/main/java/duke/functionality/Storage.java
+++ b/src/main/java/duke/functionality/Storage.java
@@ -32,10 +32,10 @@ public Storage(String pwd, String path){
/**
* Returns nothing, but stores the specified task into the taskList in TaskList class.
- * @param t the task created in Parser class.
+ * @param task the task created in Parser class.
*/
- public static void storeToList(Task t) { //same as addToList but no printing
- TaskList.taskList.add(t);
+ public static void storeToList(Task task) { //same as addToList but no printing
+ TaskList.taskList.add(task);
TaskList.numOfTask++;
}
@@ -46,9 +46,9 @@ public static void storeToList(Task t) { //same as addToList but no printing
*/
public static void writeToFile(String path) throws IOException {
FileWriter fw = new FileWriter(path);
- for(int i = 0; i < TaskList.numOfTask; i++) {
- Task t = TaskList.taskList.get(i);
- fw.write(craftOutput(t));
+ for (int i = 0; i < TaskList.numOfTask; i++) {
+ Task task = TaskList.taskList.get(i);
+ fw.write(craftOutput(task));
fw.write(System.lineSeparator());
}
fw.close();
@@ -67,33 +67,33 @@ public static void updateTextFile() {
/**
* Returns nothing, but reads the input from the specified file and stores them in the taskList in TaskList class.
- * @param f the text file that stores all tasks.
+ * @param file the text file that stores all tasks.
* @throws FileNotFoundException if the file is missing.
*/
- public static void readFileDataAndStoreInList(File f) throws FileNotFoundException {
- Scanner sc = new Scanner(f);
+ public static void readFileDataAndStoreInList(File file) throws FileNotFoundException {
+ Scanner sc = new Scanner(file);
while ((sc.hasNextLine())) {
String input = sc.nextLine();
String[] inputSplit = input.split("\\|"); //split input by |
String task = inputSplit[0];
Integer mark = Integer.parseInt(inputSplit[1]);
- if(task.equals("T")) {
+ if (task.equals("T")) {
Todo tempTask = new Todo(inputSplit[2]);
- if(mark == 1) {
+ if (mark == 1) {
tempTask.setTaskDone();
}
storeToList(tempTask);
- } else if(task.equals("D")) {
+ } else if (task.equals("D")) {
Deadline tempTask = new Deadline(inputSplit[2], Parser.formatDate(inputSplit[3]),
Parser.formatTime(inputSplit[4]));
- if(mark == 1) {
+ if (mark == 1) {
tempTask.setTaskDone();
}
storeToList(tempTask);
} else if (task.equals("E")) {
Event tempTask = new Event(inputSplit[2], Parser.formatDate(inputSplit[3]) ,
Parser.formatTime(inputSplit[4]), Parser.formatTime(inputSplit[5]));
- if(mark == 1) {
+ if (mark == 1) {
tempTask.setTaskDone();
}
storeToList(tempTask);
@@ -103,35 +103,35 @@ public static void readFileDataAndStoreInList(File f) throws FileNotFoundExcepti
/**
* Returns a crafted output to be stored in the text file.
- * @param t the task created in Parser class.
+ * @param task the task created in Parser class.
* @return crafted output.
*/
- public static String craftOutput(Task t) {
+ public static String craftOutput(Task task) {
String output = "";
- String doneIcon = t.getStatusIcon();
- if(t instanceof Todo) {
+ String doneIcon = task.getStatusIcon();
+ if (task instanceof Todo) {
if(doneIcon.equals("X")) {
- output = "T|1|" + t.getDescription();
+ output = "T|1|" + task.getDescription();
} else {
- output = "T|0|" + t.getDescription();
+ output = "T|0|" + task.getDescription();
}
- } else if(t instanceof Deadline) {
+ } else if (task instanceof Deadline) {
if(doneIcon.equals("X")) {
- output = "D|1|" + t.getDescription() + "|" + Parser.dateToString(((Deadline) t).getDate())
- + "|" + Parser.timeToString(((Deadline) t).getTime());
+ output = "D|1|" + task.getDescription() + "|" + Parser.dateToString(((Deadline) task).getDate())
+ + "|" + Parser.timeToString(((Deadline) task).getTime());
} else {
- output = "D|0|" + t.getDescription() + "|" + Parser.dateToString(((Deadline) t).getDate())
- + "|" + Parser.timeToString(((Deadline) t).getTime());
+ output = "D|0|" + task.getDescription() + "|" + Parser.dateToString(((Deadline) task).getDate())
+ + "|" + Parser.timeToString(((Deadline) task).getTime());
}
- } else if(t instanceof Event) {
+ } else if (task instanceof Event) {
if(doneIcon.equals("X")) {
- output = "E|1|" + t.getDescription() + "|" + Parser.dateToString(((Event) t).getDate())
- + "|" + Parser.timeToString(((Event) t).getStartTime())
- + "|" + Parser.timeToString(((Event) t).getEndTime());
+ output = "E|1|" + task.getDescription() + "|" + Parser.dateToString(((Event) task).getDate())
+ + "|" + Parser.timeToString(((Event) task).getStartTime())
+ + "|" + Parser.timeToString(((Event) task).getEndTime());
} else {
- output = "E|0|" + t.getDescription() + "|" + Parser.dateToString(((Event) t).getDate())
- + "|" + Parser.timeToString(((Event) t).getStartTime())
- + "|" + Parser.timeToString(((Event) t).getEndTime());
+ output = "E|0|" + task.getDescription() + "|" + Parser.dateToString(((Event) task).getDate())
+ + "|" + Parser.timeToString(((Event) task).getStartTime())
+ + "|" + Parser.timeToString(((Event) task).getEndTime());
}
}
return output;
@@ -144,10 +144,10 @@ public static String craftOutput(Task t) {
public void load() throws IOException {
File directory = new File(pwd + "/data");
File inputFile = new File(pwd + path);
- if(directory.mkdir()) {
+ if (directory.mkdir()) {
System.out.println("You do not have the Directory, do not worry! I will create the directory for you");
}
- if(inputFile.createNewFile()) {
+ if (inputFile.createNewFile()) {
System.out.println("You do not have the file, do not worry! I will create the file for you");
}
readFileDataAndStoreInList(inputFile);
diff --git a/src/main/java/duke/functionality/TaskList.java b/src/main/java/duke/functionality/TaskList.java
index 852c39019a..3ea67ee99c 100644
--- a/src/main/java/duke/functionality/TaskList.java
+++ b/src/main/java/duke/functionality/TaskList.java
@@ -37,10 +37,10 @@ public void deleteTask(int taskNum) {
public void markTask(int taskNum) {
String message = "Nice! I've marked this task as done:\n" ;
int actualTaskNum = taskNum - 1; //minus 1 as list index is from 0
- Task t = taskList.get(actualTaskNum); // get the task from the array
- t.setTaskDone();
+ Task task = taskList.get(actualTaskNum); // get the task from the array
+ task.setTaskDone();
Storage.updateTextFile();
- System.out.println(message + t.toString());
+ System.out.println(message + task.toString());
}
/**
@@ -50,10 +50,10 @@ public void markTask(int taskNum) {
public void unMarkTask(int taskNum) {
String message = "OK, I've marked this task as not done yet:\n";
int actualTaskNum = taskNum - 1;
- Task t = taskList.get(actualTaskNum); // get the task from the array
- t.setTaskNotDone();
+ Task task = taskList.get(actualTaskNum); // get the task from the array
+ task.setTaskNotDone();
Storage.updateTextFile();
- System.out.println(message + t.toString());
+ System.out.println(message + task.toString());
}
/**
@@ -71,13 +71,13 @@ public void printList(){
/**
* Returns nothing, but adds the task specified into the taskList.
- * @param t the task created in Parser class.
+ * @param task the task created in Parser class.
*/
- public void addToList(Task t) {
+ public void addToList(Task task) {
String message = "Got it. I've added this task:\n";
- taskList.add(t);
+ taskList.add(task);
numOfTask++;
Storage.updateTextFile();
- System.out.println(message + t.toString() + "\nNow you have " + numOfTask + " tasks in the list.");
+ System.out.println(message + task.toString() + "\nNow you have " + numOfTask + " tasks in the list.");
}
}
diff --git a/src/main/java/duke/main/Duke.java b/src/main/java/duke/main/Duke.java
index 240a5ff9fe..bf4e6f2239 100644
--- a/src/main/java/duke/main/Duke.java
+++ b/src/main/java/duke/main/Duke.java
@@ -14,7 +14,6 @@
* to a TaskBot that helps keep tracks of all tasks inputted by a user.
*/
public class Duke {
-
private final Storage storage;
private TaskList tasks;
private final Ui ui;
diff --git a/src/main/java/duke/task/Deadline.java b/src/main/java/duke/task/Deadline.java
index 6f61a06884..0f69c6e589 100644
--- a/src/main/java/duke/task/Deadline.java
+++ b/src/main/java/duke/task/Deadline.java
@@ -24,11 +24,11 @@ public Deadline(String description, LocalDate date, LocalTime time) {
this.date = date;
}
- public LocalTime getTime(){
+ public LocalTime getTime() {
return this.time;
}
- public LocalDate getDate(){
+ public LocalDate getDate() {
return this.date;
}
diff --git a/src/main/java/duke/task/Event.java b/src/main/java/duke/task/Event.java
index d7af77f0d1..e2fb59e678 100644
--- a/src/main/java/duke/task/Event.java
+++ b/src/main/java/duke/task/Event.java
@@ -1,4 +1,3 @@
-
package duke.task;
import java.time.LocalDate;
@@ -28,15 +27,15 @@ public Event(String description, LocalDate date, LocalTime startTime, LocalTime
this.endTime = endTime;
}
- public LocalDate getDate(){
+ public LocalDate getDate() {
return this.date;
}
- public LocalTime getStartTime(){
+ public LocalTime getStartTime() {
return this.startTime;
}
- public LocalTime getEndTime(){
+ public LocalTime getEndTime() {
return this.endTime;
}
diff --git a/src/main/java/duke/task/Task.java b/src/main/java/duke/task/Task.java
index 8b91fe670a..8f031e2fb9 100644
--- a/src/main/java/duke/task/Task.java
+++ b/src/main/java/duke/task/Task.java
@@ -17,8 +17,8 @@ public Task(String description) {
this.isDone = false;
}
- public String getStatusIcon(){
- if(this.isDone) {
+ public String getStatusIcon() {
+ if (this.isDone) {
return "X";
} else {
return " ";
@@ -33,7 +33,7 @@ public void setTaskNotDone() {
this.isDone = false;
}
- public String getDescription(){
+ public String getDescription() {
return this.description;
}