Skip to content

Commit

Permalink
Created two assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
sj1999-BIT committed Sep 9, 2021
1 parent 0f66bcb commit cb4d7a5
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 18 deletions.
Binary file modified .gradle/6.7/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/6.7/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/6.7/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/6.7/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/6.7/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/6.7/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified build/classes/java/main/Duke.class
Binary file not shown.
Binary file modified build/classes/java/main/Storage/DeadlineTask.class
Binary file not shown.
Binary file modified build/classes/java/main/Storage/EventsTask.class
Binary file not shown.
Binary file modified build/classes/java/main/Storage/Parser.class
Binary file not shown.
Binary file modified build/classes/java/main/Storage/Storage.class
Binary file not shown.
Binary file modified build/classes/java/main/Storage/TodoTasks.class
Binary file not shown.
Binary file modified build/classes/java/main/Ui.class
Binary file not shown.
Binary file added build/libs/ip-1.0-SNAPSHOT.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions build/resources/main/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: Main

30 changes: 15 additions & 15 deletions build/tmp/compileJava/source-classes-mapping.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
Duke.java
Duke
Ui
Task/DeadlineException.java
Task.DeadlineException
Launcher.java
Launcher
Task/TaskList.java
Task.TaskList
Main.java
Main
Task/EventsException.java
Task.EventsException
Task/TodoException.java
Task.TodoException
Storage/Storage.java
Storage.DeadlineTask
Storage.EventsTask
Storage.Parser
Storage.Storage
Storage.TodoTasks
Task/EventsException.java
Task.EventsException
Task/TodoException.java
Task.TodoException
Task/Task.java
Task.Task
Task/TaskTypes.java
Task.TaskTypes
MainWindow.java
MainWindow
DialogBox.java
DialogBox
Task/Task.java
Task.Task
Task/DeadlineException.java
Task.DeadlineException
Duke.java
Duke
Ui
Main.java
Main
MainWindow.java
MainWindow
11 changes: 9 additions & 2 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class Duke{
private final Ui userInterface = new Ui();
private boolean initialised = false;

public static void main(String[] args) {
Duke user = new Duke();
Expand All @@ -21,7 +22,13 @@ public static void main(String[] args) {
}

public String getResponse(String input) {
return userInterface.choiceOfAction(input);
if (initialised) {
return userInterface.choiceOfAction(input);
} else {
initialised = true;
userInterface.getDataInputList();
return userInterface.greet();
}
}
}

Expand Down Expand Up @@ -51,7 +58,7 @@ public String greet() {
* generate the end message.
*/
public String bye() {
store.saveListInFile("src/main/java/Duke/Duke.txt", taskList);
store.saveListInFile("src/main/java/Duke.txt", taskList);
return "Bye. Hope to see you again soon!";
}
/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Todo r
4 changes: 3 additions & 1 deletion src/main/java/Storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Storage {
*/
public void getDataInputList(TaskList lst) {
try {
File f = new File("src/main/java/Duke/Duke.txt");
File f = new File("src/main/java/Duke.txt");
if(!f.exists()){
f.createNewFile();
}
Expand Down Expand Up @@ -139,8 +139,10 @@ public Task createTask(String action) throws Exception{
return new TodoTasks(action);
} else {
if (type.equals("Deadline")) {
assert action.contains("Deadline") : "invalid format";
return new DeadlineTask(action);
} else if (type.equals("Events")) {
assert action.contains("Events") : "invalid format";
return new EventsTask(action);
} else {
throw new Exception("Error type");
Expand Down

1 comment on commit cb4d7a5

@sj1999-BIT
Copy link

Choose a reason for hiding this comment

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

Added a few assertions which ensures the the final command accepted for the task is in the correct format.
Changed the filepath so as to solve the bug the previously the program was unable to generate the text file for storing information

Please sign in to comment.