-
Notifications
You must be signed in to change notification settings - Fork 223
[Chanell Ng] iP #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chanellNg
wants to merge
63
commits into
nus-cs2103-AY2021S2:master
Choose a base branch
from
chanellNg:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Chanell Ng] iP #244
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
3b19ba1
Add Gradle support
a75fcee
build.gradle: Update version to 8.29
407ffa5
Level-1
chanellNg 06f0689
Add files via upload
chanellNg 9b617be
Level-2
chanellNg 4006726
Update Level_1.java
chanellNg 5487996
Add files via upload
chanellNg b5c3290
update
chanellNg 27b1dca
Delete Level_1.java
chanellNg 2ebb099
Delete Level_2.java
chanellNg 575b392
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg ce02ad4
Level-3
chanellNg 38ed607
Level-4
chanellNg 45deb86
Level-6
chanellNg ae29bdd
update
chanellNg ec45d14
A-TextUiTesting
chanellNg 8dfff5e
Level-7
chanellNg 5557dcb
Delete Level_7.java
chanellNg cabc8e2
Level-7 branch
chanellNg ff30251
Level-8 branch
chanellNg 73a64ba
Level-8
chanellNg 8a94ea4
Merge branch 'branch-Level-8'
chanellNg c942d11
branch-A-JavaDoc
chanellNg 4f0a9d5
Add files via upload
chanellNg add4617
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg 1c760e8
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg d10b9a1
Merge branch 'branch-A-JavaDoc'
chanellNg 743980d
A-MoreOOP
chanellNg 26ef9ce
OOP
chanellNg b7970f1
A-Packages
chanellNg c72addf
A-JUnit
chanellNg a929bc3
A-JUnit
chanellNg d3c2107
A-CodingStandard and A-JavaDoc
chanellNg 11af796
Added JavaDoc comments.
chanellNg 97c5ab0
branch-Level-9
chanellNg 2b307f3
Level-9
chanellNg 7fd1218
Merge remote-tracking branch 'origin/add-gradle-support'
chanellNg 98b7b46
Updated Gradle and Checkstyle
chanellNg 4851440
Level-10
chanellNg 498e37f
Level-10 GUI
chanellNg 17312a9
Added resources files
chanellNg 8d0acb9
Added assert statments
chanellNg ed4a16f
Merge pull request #2 from chanellNg/branch-A-Assertions
chanellNg aeb15f7
Made changes to improve code quality
chanellNg d5e2d9a
Merge pull request #3 from chanellNg/branch-A-CodeQuality
chanellNg bd46e79
BCD extention- adding edit functionality
chanellNg 446ca55
Added BCD extentsion -Edit function
chanellNg 194b0bc
Updated user guide and made changes to Ui
chanellNg 6f462ad
Added product snapshot
chanellNg 925acea
Set theme jekyll-theme-cayman
chanellNg 28aa931
Updated background color
chanellNg 7bebc15
Delete Ui.png
chanellNg 77eec58
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg b231f90
Updated Ui
chanellNg b2572af
Updated gui and shadowJar
chanellNg 87ed919
Set theme jekyll-theme-minimal
chanellNg 6cd61be
Updated user guide in docs folder
chanellNg b993914
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg 17cda08
Set theme jekyll-theme-cayman
chanellNg 30702c2
Updated JavaDoc comments
chanellNg fffce7c
Merge branch 'master' of https://github.com/chanellNg/ip
chanellNg b65e6ea
Update README.md
chanellNg d1837f3
Update README.md
chanellNg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,132 @@ | ||
| package PACKAGE_NAME;public class Level_7 { | ||
| import java.io.IOException; | ||
| import java.util.Scanner; | ||
| import java.io.File; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.FileWriter; | ||
|
|
||
| public class Level_7 { | ||
|
|
||
| private static void createBot(String filePath, Duke bot) throws FileNotFoundException { | ||
| File f = new File(filePath); // create a File for the given file path | ||
| Scanner s = new Scanner(f); // create a Scanner using the File as the source | ||
| Task newTask = new Task(""); | ||
| while (s.hasNext()) { | ||
| String[] taskData = s.nextLine().split(" \\| "); | ||
| String type = taskData[0]; | ||
| String doneStatus = taskData[1]; | ||
| if (type.equals("T")) { | ||
| String details = taskData[2]; | ||
| newTask = new ToDo(details); | ||
| bot.addToBot(newTask); | ||
|
|
||
| } else if (type.equals("E")) { | ||
| String content = taskData[2]; | ||
| String at = taskData[3]; | ||
| newTask = new Event(content, at); | ||
| bot.addToBot(newTask); | ||
|
|
||
| } else { | ||
| String content = taskData[2]; | ||
| String by = taskData[3]; | ||
| newTask = new Deadline(content, by); | ||
| bot.addToBot(newTask); | ||
| } | ||
|
|
||
| if (doneStatus == " 1 ") { | ||
| newTask.markDone(); | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| private static void updateFile(String filePath, Duke bot) throws IOException { | ||
| FileWriter fw = new FileWriter(filePath); | ||
| for(Task element:bot.list) { | ||
| fw.write(element.toString() + "\n"); | ||
|
|
||
| } | ||
| fw.close(); | ||
| } | ||
| public static void main(String[] args) throws DukeException { | ||
| System.out.println("Hello! I'm Duke"); | ||
| System.out.println("What can I do for you?"); | ||
| Duke bot = new Duke(); | ||
| try{ | ||
| File f = new File("data/duke.txt"); | ||
| f.getParentFile().mkdirs(); | ||
| if(f.createNewFile()){ | ||
| System.out.println("File created"); | ||
| }else { | ||
| createBot("data/duke.txt", bot); | ||
| } | ||
| }catch (IOException e){ | ||
| System.out.println("Error in creating file"); | ||
|
|
||
|
|
||
| } | ||
| Scanner sc = new Scanner(System.in); | ||
| String input = sc.nextLine(); | ||
|
|
||
| while (!(input.equals("bye"))) { | ||
| if (input.equals("list")) { | ||
| bot.printList(); | ||
| } else { | ||
| String command = input.split(" ")[0]; | ||
| try { | ||
| if (command.equals("done")) { | ||
| int id = Integer.valueOf(input.split(" ")[1]); | ||
| bot.markTaskAsDone(id); | ||
|
|
||
| } else if (command.equals("todo")) { | ||
| try { | ||
| input = input.split(" ", 2)[1]; | ||
| ToDo newTask = new ToDo(input); | ||
| bot.addToList(newTask); | ||
| //counter++; | ||
| } catch (Exception e) { | ||
| throw new DukeException(("OOPS!!! The description cannot be empty.")); | ||
| } | ||
| } else if (command.equals("event")) { | ||
| input = input.split(" ", 2)[1]; | ||
| String content = input.split("/at")[0]; | ||
| String at = input.split("/at")[1]; | ||
| Event newTask = new Event(content, at); | ||
| bot.addToList(newTask); | ||
| } else if (command.equals("deadline")) { | ||
| input = input.split(" ", 2)[1]; | ||
| String content = input.split("/by")[0]; | ||
| String by = input.split("/by")[1]; | ||
| Deadline newTask = new Deadline(content, by); | ||
| bot.addToList(newTask); | ||
| }else if(command.equals("delete")){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing |
||
| int id = Integer.valueOf(input.split(" ")[1]); | ||
| bot.deleteTask(id); | ||
|
|
||
| } else { | ||
| throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-{"); | ||
| } | ||
| } catch (DukeException e1) { | ||
| System.out.println(e1); | ||
|
|
||
| } | ||
| } | ||
| try { | ||
| updateFile("data/duke.txt", bot); | ||
| }catch (IOException e) { | ||
| System.out.println("Unable to update file"); | ||
| } | ||
| input = sc.nextLine(); | ||
| } | ||
|
|
||
|
|
||
| System.out.println("Bye. Hope to see you again soon!"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing