Skip to content

Commit 10e487b

Browse files
committed
Debugged save operation
Signed-off-by: tys <[email protected]>
1 parent a4008de commit 10e487b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/main/java/duke/Duke.java

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class Duke {
1616
static ArrayList<Task> listInputs = new ArrayList<>();
1717
public static String listPath = "/src/main/java/taskList.txt";
1818
public static boolean isPrintMessageEnabled = true;
19+
public static boolean isLoading = true;
1920
//static int listPosition = 0;
2021

2122
private static final String BYE_MESSAGE = " " + "Bye. Hope to see you again soon!";
@@ -162,6 +163,13 @@ public static void eventOperation(String input){
162163
* save command triggered: manually save tasks in list
163164
*/
164165
public static void saveOperation(){
166+
if(listInputs.size() <= 0){
167+
printMessage(" List is empty");
168+
return;
169+
}else if(isLoading == true){
170+
return;
171+
}
172+
165173
isPrintMessageEnabled = false;
166174
try{
167175
writeListToFile(listPath);
@@ -238,17 +246,20 @@ public static void createNewFile(String filePath){
238246
}
239247
}catch(IOException e) {
240248
System.out.println("An error occurred.");
249+
System.out.println("listPath: " + listPath);
241250
}
242251
}
243252

244253
public static void getList(String taskListPath){
245254
isPrintMessageEnabled = false;
255+
isLoading = true;
246256
try {
247257
fileToList(taskListPath);
248258
} catch (FileNotFoundException e) {
249259
createNewFile(taskListPath);
250260
}finally{
251261
isPrintMessageEnabled = true;
262+
isLoading = false;
252263
}
253264
}
254265

0 commit comments

Comments
 (0)