-
Notifications
You must be signed in to change notification settings - Fork 228
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
[Goh Wei Kiat] iP #270
Open
mrweikiat
wants to merge
65
commits into
nus-cs2103-AY2021S2:master
Choose a base branch
from
mrweikiat: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
[Goh Wei Kiat] iP #270
Changes from 19 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
3b19ba1
Add Gradle support
a75fcee
build.gradle: Update version to 8.29
7020044
Update Duke.java
mrweikiat 8d73734
level2
mrweikiat fc455aa
level3
mrweikiat f286b75
level 4
mrweikiat 238b224
level5
mrweikiat 98bc1c3
level6
mrweikiat d1475b3
Update JAVADOCS comment
mrweikiat 50e718d
Update Duke.java
mrweikiat 3ba369a
A-TextUiTesting
mrweikiat 4c53e33
Level 6
mrweikiat 1e149a7
Update A-TextUiTesting
mrweikiat a1e2149
feature1
mrweikiat 2348e76
Branch testing
mrweikiat 2687090
Merge branch 'feature1'
mrweikiat 9e92011
Level 7
mrweikiat 67efef3
Level8
mrweikiat 1eb74dd
A-MoreOOP
mrweikiat 5a823a8
A-Packages
mrweikiat 4f103fe
Level 9
mrweikiat ec6e328
Package Justin
mrweikiat 3141a6a
A-JavaDoc
mrweikiat 46a8cc9
Merge remote-tracking branch 'upstream/add-gradle-support'
mrweikiat 6c45111
A-Gradle
mrweikiat bc42771
Level 10 GUI
mrweikiat 6f08404
Added help taskbar
mrweikiat 8207336
Add C-Extensions
mrweikiat 5d0dca3
A-BetterGui
mrweikiat 5e79d8a
Add Assertions
mrweikiat 0e8119a
Improve Code Quality
mrweikiat c8d5d34
Add gradle.yml to workflow
mrweikiat 4044436
Update Ui.png
mrweikiat 9375e8b
Update README.md
mrweikiat 1a76075
Update README.md
mrweikiat 5d86cbf
Update README.md
mrweikiat ae164d8
Update README.md
mrweikiat 6f07dc9
Improve on Ui
mrweikiat 516ac7c
Merge branch 'master' of https://github.com/mrweikiat/ip
mrweikiat 6d88cb0
Update README.md
mrweikiat ac112f7
Update README.md
mrweikiat ef5247a
Update README.md
mrweikiat c735e63
Update README.md
mrweikiat df6b25e
Update Ui.png
mrweikiat 0fc6025
branch-A-CodeQuality
mrweikiat 06271ce
branch-A-CodingStandard
mrweikiat 3e9e0bd
Merge pull request #2 from mrweikiat/branch-A-CodeQuality
mrweikiat 14fe879
branch-A-JavaDoc
mrweikiat 5aabbc7
Merge pull request #3 from mrweikiat/branch-A-JavaDoc
mrweikiat 3748d06
branch-A-Assertions
mrweikiat 2ea782f
Merge pull request #4 from mrweikiat/branch-A-Assertions
mrweikiat d3135ad
branch-Level-10
mrweikiat 3ae9e3e
Merge pull request #8 from mrweikiat/branch-Level-10
mrweikiat e03420c
Merge branch 'master' into branch-A-CodingStandard
mrweikiat c0ff7f4
Merge pull request #9 from mrweikiat/branch-A-CodingStandard
mrweikiat 9f48c36
branch-Level-9
mrweikiat ef654c5
branch-Level-9
mrweikiat 49007e1
Merge pull request #11 from mrweikiat/branch-Level-9
mrweikiat 526d705
Update Code Quality
mrweikiat 9659072
Merge branch 'master' of https://github.com/mrweikiat/ip
mrweikiat 7e573ec
Add jar file
mrweikiat 7ba0d2d
Update README.md
mrweikiat 6cc0997
Update JavaDoc and Code Standard
mrweikiat 081d1f8
Merge branch 'master' of https://github.com/mrweikiat/ip
mrweikiat 4247723
Update README.md
mrweikiat 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 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,4 @@ | ||
E|1|catch dog|2019-12-10 18:00 | ||
D|0|catch mouse|2020-02-02 | ||
T|1|catch cat | ||
1|catch eagle |
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,3 @@ | ||
D|0|catch dog|2021-02-03 | ||
1|catch cat | ||
E|1|catch bird|2019-06-10 19:00 |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class Deadline extends Task { | ||
|
||
protected String by; | ||
protected LocalDate date; | ||
|
||
public Deadline(String description, String by) { | ||
super(description); | ||
this.by = by; | ||
this.date = LocalDate.parse(by); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[D]" + super.toString() + " (by: " + date.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")"; | ||
} | ||
} |
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,28 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.LocalTime; | ||
|
||
public class Event extends Task { | ||
|
||
protected String dateTime; | ||
protected String date; | ||
protected String time; | ||
protected LocalDate date1; | ||
protected LocalTime time1; | ||
|
||
public Event(String description, String dateTime) { | ||
super(description); | ||
this.dateTime = dateTime; | ||
String[] splits = dateTime.split("\\s+"); | ||
this.date = splits[0]; | ||
this.time = splits[1]; | ||
this.date1 = LocalDate.parse(date); | ||
this.time1 = LocalTime.parse(time); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[E]" + super.toString() + " (at: " + date1.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + " " + | ||
time1.format(DateTimeFormatter.ofPattern("HH:mm")) + ")"; | ||
} | ||
} |
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,157 @@ | ||
import java.io.File; | ||
import java.util.Scanner; | ||
|
||
public class Justin { | ||
|
||
private Storage storage; | ||
private TaskList tasks; | ||
private Ui ui; | ||
|
||
|
||
public Justin(String filePath) { | ||
|
||
ui = new Ui(); | ||
this.storage = new Storage(filePath); | ||
tasks = storage.loadFile(filePath); | ||
|
||
} | ||
|
||
public void run() { | ||
|
||
/* | ||
* Justin is a chatbot that help users plan and organise tasks | ||
* Justin stands for JUSt a TImetable(New) : JUSTIN | ||
* | ||
* Justin is able to create and manage new tasks | ||
* 1) Mark tasks off as done | ||
* 2) Set tasks as To Do's - <keyword> <name> | ||
* 3) Set tasks as Deadline's - keyword : <keyword> <name> /by <day> | ||
* 4) Set tasks as Event's - keyword : <keyword> <name> /at <day time> | ||
* 5) Supports deletion of completed tasks with command delete <int> | ||
* | ||
* Justin also supports viewing the entire tasks list with the command list - keyword : <keyword> | ||
* To end off the session user can input bye to terminate program - keyword : <keyword> | ||
* | ||
* @author Goh Wei Kiat aka github : mrweikiat | ||
* @version CS2103T AY20/21 Semester 2, Individual Project 'IP' | ||
*/ | ||
|
||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
// Starting line for UI | ||
ui.showWelcomeMessage(); | ||
ui.showHelpMessage(); | ||
|
||
// Condition for Duke to stop | ||
boolean terminate = false; | ||
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. Should this be canTerminate? Might be better to change to reflect boolean variable name |
||
|
||
//Duke will keep repeating until command given "Bye" | ||
while (!terminate) { | ||
|
||
String text = sc.nextLine(); | ||
|
||
Parser pr = new Parser(text); | ||
|
||
try { | ||
String command = pr.checkCommand(); | ||
|
||
switch (command) { | ||
|
||
case "BYE": | ||
|
||
storage.saveFile(tasks, storage.getFilePath()); | ||
terminate = true; // terminates Duke | ||
ui.showEndMessage(); | ||
break; | ||
|
||
case "LIST": | ||
|
||
ui.showListMessage(); | ||
ui.printList(tasks); | ||
break; | ||
|
||
case "DONE": | ||
|
||
String num = text.substring(5); // take out the int value of the task to be completed | ||
int listNum = Integer.parseInt(num); // changes to int | ||
Task hold = tasks.getList().get(listNum - 1); | ||
hold.markAsDone(); | ||
ui.showDoneMessage(tasks, listNum); | ||
break; | ||
|
||
case "DEADLINE": | ||
|
||
String newText = text.substring(9); // remove deadline from the string text | ||
// set delimiter to take out the description of the deadline | ||
String description = newText.substring(0, newText.indexOf("/") - 1); | ||
// set delimiter to take out date of the deadline | ||
String date = newText.substring(newText.indexOf("/") + 4); | ||
|
||
ui.printLine(); | ||
tasks.addDeadline(description, date); | ||
ui.printLine(); | ||
|
||
break; | ||
|
||
case "TODO": | ||
|
||
String descriptionToDo = text.substring(text.indexOf(" ") + 1); // take out the item from the text | ||
tasks.addToDo(descriptionToDo); | ||
|
||
break; | ||
|
||
case "EVENT": | ||
|
||
String eventText = text.substring(text.indexOf(" ") + 1); // removing the event to get description | ||
// set delimiter to obtain the description and the at | ||
String descriptionEvent = eventText.substring(0, eventText.indexOf("/") - 1); | ||
String dateEvent = eventText.substring(eventText.indexOf("/") + 4); | ||
// splitting the date and time respectively | ||
tasks.addEvent(descriptionEvent, dateEvent); | ||
|
||
break; | ||
|
||
case "DELETE": | ||
|
||
String numDelete = text.substring(7); // take out the int value of the task to be completed | ||
tasks.delete(numDelete); | ||
|
||
break; | ||
|
||
case "FIND": // for level 9 | ||
|
||
String findText = text.substring(text.indexOf(" ")+1); // key for searching | ||
ui.printFoundTask(tasks.find(findText)); | ||
|
||
break; | ||
|
||
default: | ||
|
||
ui.printLine(); | ||
System.out.println("added: " + text); | ||
ui.printLine(); | ||
// create new instance of task and add to the list | ||
Task holder = new Task(text); | ||
tasks.getList().add(holder); // position corresponds to item number | ||
|
||
} | ||
} catch (JustinException m) { | ||
ui.printErrorMessage(m.getMessage()); | ||
} | ||
|
||
|
||
} | ||
sc.close(); | ||
} | ||
|
||
public static void main(String[]args){ | ||
|
||
String userDir = System.getProperty("user.dir"); | ||
String filePath = userDir + File.separator + "data" + File.separator + "justin.txt"; | ||
new Justin(filePath).run(); | ||
|
||
} | ||
} | ||
|
||
|
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,5 @@ | ||
public class JustinException extends Exception { | ||
public JustinException(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,72 @@ | ||
public class Parser { | ||
|
||
private String fullText; | ||
|
||
public Parser(String fullText) { | ||
this.fullText = fullText; | ||
} | ||
|
||
public String checkCommand() throws JustinException { | ||
try { | ||
|
||
validate(fullText); | ||
|
||
if (fullText.equals("bye")) { | ||
|
||
return "BYE"; | ||
|
||
} else if (fullText.equals("list")) { | ||
|
||
return "LIST"; | ||
|
||
} else if (fullText.contains("done")) { | ||
|
||
return "DONE"; | ||
|
||
} else if (fullText.contains("deadline")) { | ||
|
||
return "DEADLINE"; | ||
|
||
} else if (fullText.contains("todo")) { | ||
|
||
return "TODO"; | ||
|
||
} else if (fullText.contains("event")) { | ||
|
||
return "EVENT"; | ||
|
||
} | ||
else if (fullText.contains("delete")) { | ||
|
||
return "DELETE"; | ||
|
||
} else if (fullText.contains("find")) { | ||
|
||
return "FIND"; | ||
|
||
} | ||
|
||
else { | ||
|
||
return "ADD"; | ||
|
||
} | ||
} catch (JustinException m) { | ||
throw new JustinException(m.getMessage()); | ||
} | ||
} | ||
|
||
static void validate(String text) throws JustinException { | ||
if (text.length() < 5 && text.contains("todo") ) { // case 1 | ||
throw new JustinException("☹ OOPS!!! The description of a todo cannot be empty."); | ||
} | ||
else if (text.contains("blah")) { // case 2 | ||
throw new JustinException("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); | ||
} else if (text.length() < 10 && text.contains("deadline")) { // case 3 | ||
throw new JustinException("☹ OOPS!!! The description of a deadline cannot be empty."); | ||
} else if (text.length() < 6 && text.contains("event")) { // case 4 | ||
throw new JustinException("☹ OOPS!!! The description of a event cannot be empty."); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
Might have exceeded line limit