forked from nus-cs2103-AY2324S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UI,Parser, Storage and TaskList
- Loading branch information
1 parent
f56c1a7
commit 96f087e
Showing
10 changed files
with
295 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
public enum Command { | ||
TODO, | ||
DEADLINE, | ||
EVENT, | ||
LIST, | ||
DONE, | ||
DELETE, | ||
FIND, | ||
EXIT, | ||
INVALID, | ||
UNMARK, | ||
MARK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public class DukeException extends Exception { | ||
public DukeException(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
public class Parser { | ||
public static Command parseCommand(String userInput) { | ||
String[] inputParts = userInput.split(" ", 2); // Split input into two parts: command and arguments | ||
String command = inputParts[0].toUpperCase(); // Convert command to uppercase for case-insensitivity | ||
|
||
|
||
switch (command) { | ||
case "TODO": | ||
return Command.TODO; | ||
case "DEADLINE": | ||
return Command.DEADLINE; | ||
case "EVENT": | ||
return Command.EVENT; | ||
case "LIST": | ||
return Command.LIST; | ||
case "DONE": | ||
return Command.DONE; | ||
case "DELETE": | ||
return Command.DELETE; | ||
case "FIND": | ||
return Command.FIND; | ||
case "BYE": | ||
return Command.EXIT; | ||
case "UNMARK": | ||
return Command.UNMARK; | ||
case "MARK": | ||
return Command.MARK; | ||
default: | ||
return Command.INVALID; | ||
} | ||
|
||
|
||
} | ||
|
||
public static String parseDescription(String userInput) { | ||
String[] parts = userInput.split(" ", 2); // Split input into command and arguments | ||
if (parts.length > 1) { | ||
return parts[1]; | ||
} | ||
return ""; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Storage { | ||
public String filePath; | ||
|
||
public Storage(String filePath) { | ||
|
||
this.filePath = filePath; | ||
} | ||
|
||
public TaskList load() throws DukeException { | ||
TaskList tasks = new TaskList(); | ||
File file = new File(filePath); | ||
if (file.exists()) { | ||
tasks = TaskReader.readTasksFromFile(filePath); | ||
System.out.println(tasks); | ||
} | ||
|
||
return tasks; | ||
} | ||
|
||
public void save(TaskList tasks, String filePath) { | ||
TaskWriter.writeTasksToFile(tasks, filePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ public String getName() { | |
} | ||
|
||
public void setName(String name) { | ||
|
||
this.name = name; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.