Skip to content

Commit d6ecfe2

Browse files
committed
Fixed some naming issues
1 parent 6e54ad7 commit d6ecfe2

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

src/main/java/duke/Command/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void printInvalidTaskNumber(int numberOfTasks) {
5252
System.out.println(" \u2639 OOPS!!! Please input a task number between 1 and " + numberOfTasks + ".");
5353
}
5454

55-
public static void printEmptyTasklist() {
55+
public static void printEmptyTaskList() {
5656
System.out.println(" \u2639 OOPS!!! List is empty");
5757
}
5858

src/main/java/duke/FileIO/FileIO.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
import java.util.Scanner;
1313

1414
public class FileIO {
15+
16+
public static final int INDEX_OF_TASK_TYPE = 1;
17+
1518
public static void readFromFile() {
16-
if (!doesFileExist()) {
19+
if (doesFileNotExist()) {
1720
return;
1821
}
1922
File data = new File("data/data.txt");
@@ -27,7 +30,7 @@ public static void readFromFile() {
2730
}
2831
}
2932

30-
private static boolean doesFileExist() {
33+
private static boolean doesFileNotExist() {
3134
File folder = new File("data");
3235
if (!folder.exists()) {
3336
System.out.println("\u2639 OOPS!!! Folder does not exist. Creating a folder named \"data\" in the same directory...");
@@ -36,7 +39,7 @@ private static boolean doesFileExist() {
3639
System.out.println("Folder is created successfully.");
3740
} else {
3841
System.out.println("Please create a folder named \"data\" in the same directory manually.");
39-
return false;
42+
return true;
4043
}
4144
}
4245
File data = new File("data/data.txt");
@@ -50,22 +53,22 @@ private static boolean doesFileExist() {
5053
System.out.println("Please create a text file named \"data\" in the \"data\" folder manually.");
5154
}
5255
} catch (IOException e) {
53-
return false;
56+
return true;
5457
}
5558
}
56-
return true;
59+
return false;
5760
}
5861

5962
public static void writeToFile(TaskList taskList) {
60-
if (!doesFileExist()) {
63+
if (doesFileNotExist()) {
6164
return;
6265
}
6366
File data = new File("data/data.txt");
6467
try {
6568
FileWriter fw = new FileWriter(data.getAbsolutePath());
6669
ArrayList<Task> list = taskList.getList();
6770
for (int i = 0; i < taskList.getNumberOfTasks(); i++) {
68-
String input = handleStatusAndDescription(list, i);
71+
String input = formatListDataIntoStorageForm(list, i);
6972
fw.write(input + "\n");
7073
}
7174
fw.close();
@@ -74,18 +77,18 @@ public static void writeToFile(TaskList taskList) {
7477
}
7578
}
7679

77-
private static String handleStatusAndDescription(ArrayList<Task> list, int index) {
80+
private static String formatListDataIntoStorageForm(ArrayList<Task> list, int index) {
7881
String output;
7982
String input = list.get(index).getStatusAndDescription();
80-
switch (input.strip().toCharArray()[1]) {
83+
switch (input.strip().toCharArray()[INDEX_OF_TASK_TYPE]) {
8184
case ('T'):
8285
output = "todo " + list.get(index).getDescription();
8386
break;
8487
case ('D'):
85-
output = "deadline " + list.get(index).getDescription() + "/by " + list.get(index).getAdditionalInfomation();
88+
output = "deadline " + list.get(index).getDescription() + "/by " + list.get(index).getAdditionalInformation();
8689
break;
8790
case ('E'):
88-
output = "event " + list.get(index).getDescription() + "/at " + list.get(index).getAdditionalInfomation();
91+
output = "event " + list.get(index).getDescription() + "/at " + list.get(index).getAdditionalInformation();
8992
break;
9093
default:
9194
return null;

src/main/java/duke/Tasks/Deadline.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package duke.Tasks;
22

3-
import duke.Tasks.Task;
4-
53
public class Deadline extends Task {
64
protected String by;
75

@@ -16,7 +14,7 @@ public String getStatusAndDescription() {
1614
}
1715

1816
@Override
19-
public String getAdditionalInfomation() {
17+
public String getAdditionalInformation() {
2018
return by;
2119
}
2220
}

src/main/java/duke/Tasks/Event.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package duke.Tasks;
22

3-
import duke.Tasks.Task;
4-
53
public class Event extends Task {
64
protected String at;
75

@@ -19,8 +17,7 @@ public String getStatusAndDescription() {
1917
return "[E]" + super.getStatusAndDescription() + "(at: " + at + ")";
2018
}
2119

22-
@Override
23-
public String getAdditionalInfomation() {
20+
public String getAdditionalInformation() {
2421
return at;
2522
}
2623
}

src/main/java/duke/Tasks/Task.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public String getStatusAndDescription() {
2929
return getStatusIcon() + description;
3030
}
3131

32-
public String getAdditionalInfomation() {
32+
public String getAdditionalInformation() {
3333
return null;
3434
}
3535
}

src/main/java/duke/Tasks/TaskList.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public int getNumberOfTasks() {
2323

2424
public void printTaskList() {
2525
if (list.isEmpty()) {
26-
Message.printEmptyTasklist();
26+
Message.printEmptyTaskList();
2727
return;
2828
}
2929
System.out.println(" Here are the tasks in your list:");
@@ -62,7 +62,7 @@ public void addTask(String description, boolean printMessage) {
6262
list.add(new ToDo(description));
6363
if (printMessage) {
6464
Message.printGotIt();
65-
printStatusDescriptionAndNumberOftasks();
65+
printStatusDescriptionAndNumberOfTasks();
6666
}
6767
} catch (DukeException e) {
6868
Message.printEmptyTodoDescription();
@@ -86,7 +86,7 @@ public void addEvent(String description, boolean printMessage) {
8686
list.add(new Event(eventInformation[0], eventInformation[1].strip()));
8787
if (printMessage) {
8888
Message.printGotIt();
89-
printStatusDescriptionAndNumberOftasks();
89+
printStatusDescriptionAndNumberOfTasks();
9090
}
9191
}
9292

@@ -107,12 +107,12 @@ public void addDeadline(String description, boolean printMessage) {
107107
list.add(new Deadline(deadlineInformation[0], deadlineInformation[1].strip()));
108108
if (printMessage) {
109109
Message.printGotIt();
110-
printStatusDescriptionAndNumberOftasks();
110+
printStatusDescriptionAndNumberOfTasks();
111111
}
112112
}
113113

114-
private void printStatusDescriptionAndNumberOftasks() {
115-
System.out.println(" " + list.get(list.size()-1).getStatusAndDescription());
114+
private void printStatusDescriptionAndNumberOfTasks() {
115+
System.out.println(" " + list.get(list.size() - 1).getStatusAndDescription());
116116
Message.printNumberOfTasksInList(list.size());
117117
}
118118

@@ -143,7 +143,7 @@ public void deleteTask(String command) {
143143

144144
private boolean isTaskListEmptyOrIsCommandTypeInvalid(String command) {
145145
if (list.isEmpty()) {
146-
Message.printEmptyTasklist();
146+
Message.printEmptyTaskList();
147147
return true;
148148
} else if (command.isEmpty() || !GeneralMethods.isNumeric(command)) {
149149
Message.printInvalidTaskNumber(list.size());

src/main/java/duke/Tasks/ToDo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package duke.Tasks;
22

3-
import duke.Tasks.Task;
4-
53
public class ToDo extends Task {
64

75
public ToDo(String description) {

text-ui-test/data/data.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
todo borrow book
2+
done 1
3+
event project meeting /at Mon 2-4pm
4+
done 2

0 commit comments

Comments
 (0)