diff --git a/Daiyan.png b/Daiyan.png new file mode 100644 index 000000000..bf71a0cff Binary files /dev/null and b/Daiyan.png differ diff --git a/README.md b/README.md index af0309a9e..fad32bcad 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,17 @@ -# Duke project template +# CS2103T Individual Project +This is a project by NUS school of computing for the mod CS2103T. I named the main file after Daiyan from Girl's Frontline (An mobile RPG game i adore). The project is currently unfinished and will take the course of this semester to complete. +``` + ____ ____ _ __ __ ____ __ _ +| _) \ / () \ | |\ \/ // () \ | \| | +|____//__/\__\|_| |__|/__\/__\|_|\__| +``` +__________________________________________ +![Daiyan](https://github.com/lyhthaddeus/ip/blob/master/Daiyan.png) -This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it. +Hello I'm Daiyan +What can I do for you? +__________________________________________ -## Setting up in Intellij +[More information on Daiyan](https://iopwiki.com/wiki/Daiyan) -Prerequisites: JDK 17, update Intellij to the most recent version. -1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first) -1. Open the project into Intellij as follows: - 1. Click `Open`. - 1. Select the project directory, and click `OK`. - 1. If there are any further prompts, accept the defaults. -1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).
- In the same dialog, set the **Project language level** field to the `SDK default` option. -1. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output: - ``` - Hello from - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` - -**Warning:** Keep the `src\main\java` folder as the root folder for Java files (i.e., don't rename those folders or move Java files to another folder outside of this folder path), as this is the default location some tools (e.g., Gradle) expect to find Java files. diff --git a/data/storage.txt b/data/storage.txt new file mode 100644 index 000000000..0be97bc8d --- /dev/null +++ b/data/storage.txt @@ -0,0 +1,2 @@ +T | false | task 1 +E | false | task 1 | 1 | 2 diff --git a/src/main/java/Controller/Parser.java b/src/main/java/Controller/Parser.java new file mode 100644 index 000000000..dcfc35365 --- /dev/null +++ b/src/main/java/Controller/Parser.java @@ -0,0 +1,100 @@ +package Controller; + +import java.io.IOException; +import java.util.Scanner; +import DataStructure.TaskList; +import TaskObjects.*; + +import Enums.CommandTypes; +import Exception.InvalidInputException; +import Exception.SyntaxException; + +public class Parser { + + private TaskList taskList; + private static final String LINE_BREAK = "\n__________________________________________\n"; + + public Parser() { + } + + public void start() { + Scanner scanner = new Scanner(System.in); + String input; + System.out.print("How may I assist you commander?" + LINE_BREAK); + this.taskList = Storage.load(); + + while(true) { + input = scanner.nextLine().trim(); + String[] parsed = input.split(" ", 2); + CommandTypes commandTypes = CommandTypes.fromString(parsed[0]); + + try { + switch (commandTypes) { + case BYE, Q: + System.out.println("Bye, hope to see you again Commander." + LINE_BREAK); + return; + case LIST, LS: + taskList.getList(); + break; + case MARK: + if (parsed.length < 2) { + throw new SyntaxException("mark", "mark "); + } + taskList.mark(parsed[1]); + break; + case UNMARK: + if (parsed.length < 2) { + throw new SyntaxException("unmark", "unmark "); + } + taskList.unmarked(parsed[1]); + break; + case DELETE, DEL: + if (parsed.length < 2) { + throw new SyntaxException("delete", "delete "); + } + taskList.delete(parsed[1]); + break; + case TODO: + if (parsed.length < 2) { + throw new SyntaxException("Todo", "todo "); + } + taskList.add(new Todo(parsed[1], false)); + break; + case DEADLINE: + if (parsed.length < 2) { + throw new SyntaxException("Deadline", "deadline /by