-
Notifications
You must be signed in to change notification settings - Fork 462
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
[Tin Jingyao] iP #507
Open
tin-jy
wants to merge
45
commits into
nus-cs2103-AY2223S1:master
Choose a base branch
from
tin-jy: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
[Tin Jingyao] iP #507
Changes from 13 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
556af3f
Add Gradle support
1541204
Add ability to read inputs and echo it as output
tin-jy 18f1898
Add add and list functionality
tin-jy ec9fd31
Add functionality to mark and unmark tasks
tin-jy 400cf62
Add different types of tasks
tin-jy 7bc53d7
Add test cases for text-ui testing
tin-jy 6f5be36
Add error handling for incorrect user inputs
tin-jy ddb1d97
Add functionality to remove tasks
tin-jy 841c78b
Add a FileHandler class to deal with saving inputs in a local file
tin-jy 129758c
Add functionality to save task list into a local file on every change
tin-jy c351d1d
Add functionality for Duke to load task list on startup
tin-jy a69c99c
Add ability for Duke to verify dates and time
tin-jy 462fb51
Add classes Parser, Ui, TaskList to include more OOP
tin-jy 4d4f45d
Place all Duke related Java files into packages
tin-jy fbdbd16
Merge branch 'add-gradle-support' of https://github.com/nus-cs2103-AY…
tin-jy 304acb1
Add more packages and classes for organisation
tin-jy 609dc79
Add more classes and error handling
tin-jy fe3f213
Add JUnit tests for public methods in some classes
tin-jy 86fba2c
Update dependencies in build.gradle
tin-jy 982ba6d
Add JavaDocs
tin-jy 7338f37
Correct style issues to adhere to coding standards
tin-jy aef9014
Add ability to search for tasks using keywords
tin-jy 8009da8
Merge branch 'branch-A-CodingStandard'
tin-jy b99000a
Merge branch 'branch-Level-9'
tin-jy 3bda679
Add checkstyle.xml and suppressions.xml for checkstyle
tin-jy a2c8035
Fix a bug with the find command
tin-jy 6741565
Add test cases
tin-jy ce8111d
Create JAR file
tin-jy 217e318
Add a basic GUI for Duke
tin-jy 7554d3d
Fully implement GUI and allow Duke to respond to commands
tin-jy cfabe0d
Merge branch 'branch-A-CheckStyle'
tin-jy 5d7b0ab
Add package for GUI related java files
tin-jy 1297ade
Add more JUnit tests
tin-jy ddf41bb
Add assert statements
tin-jy dafecc7
Improve code quality
tin-jy 14da0b9
Merge pull request #1 from tin-jy/branch-A-Assertions
tin-jy 4cd2cf6
Merge branch 'master' into branch-A-CodeQuality
tin-jy 3c0576a
Merge pull request #2 from tin-jy/branch-A-CodeQuality
tin-jy 7f02321
Add functionality to change the file path for local storage
tin-jy a883516
Change some output messages
tin-jy 3574c8a
Add some bugfixes
tin-jy c8e2fdc
Fix checkstyle issues
tin-jy 0d08193
Change profile images for Duke and the user.
tin-jy a2eb1a6
Add a user guide in README.md
tin-jy b8d38f9
Fix bug related to local file path
tin-jy 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
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 @@ | ||
[D][0] blab | 02 Mar 2022 1807 |
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,5 @@ | ||
package duke; | ||
|
||
public class Command { | ||
|
||
} | ||
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,109 @@ | ||
package duke; | ||
|
||
import java.io.IOException; | ||
import java.time.DateTimeException; | ||
import java.util.Scanner; | ||
|
||
public class Duke { | ||
|
||
private Storage storage; | ||
private TaskList tasks; | ||
private Ui ui; | ||
|
||
public Duke(String filePath) { | ||
ui = new Ui(); | ||
storage = new Storage(filePath); | ||
try { | ||
tasks = new TaskList(storage.load()); | ||
} catch (Exception e) { | ||
ui.showLoadingError(); | ||
tasks = new TaskList(); | ||
} | ||
} | ||
|
||
public void run() { | ||
ui.showWelcome(); | ||
boolean isExit = false; | ||
while (!isExit) { | ||
try { | ||
Scanner sc = new Scanner(System.in); | ||
String input = sc.nextLine(); | ||
String parsedInput = Parser.parse(input); | ||
if (parsedInput.equalsIgnoreCase("bye")) { | ||
isExit = true; | ||
} else if (parsedInput.equalsIgnoreCase("list")) { | ||
ui.display(tasks.list()); | ||
} else if (parsedInput.toLowerCase().startsWith("mark")) { | ||
int taskNum = Integer.parseInt(parsedInput.substring(4)); | ||
try { | ||
Task task = tasks.mark(taskNum); | ||
ui.display(String.format("I've marked this task as complete:%n%s%n", task)); | ||
} catch (IndexOutOfBoundsException e) { | ||
ui.displayError(e); | ||
} | ||
} else if (parsedInput.toLowerCase().startsWith("unmark")) { | ||
int taskNum = Integer.parseInt(parsedInput.substring(6)); | ||
try { | ||
Task task = tasks.unmark(taskNum); | ||
ui.display(String.format("I've marked this task as incomplete:%n%s%n", task)); | ||
} catch (IndexOutOfBoundsException e) { | ||
ui.displayError(e); | ||
} | ||
} else if (parsedInput.toLowerCase().startsWith("delete")) { | ||
int taskNum = Integer.parseInt(parsedInput.substring(6)); | ||
try { | ||
Task task = tasks.delete(taskNum); | ||
ui.display(String.format("I've deleted this task:%n%s%n", task)); | ||
} catch (IndexOutOfBoundsException e) { | ||
ui.displayError(e); | ||
} | ||
} else if (parsedInput.toLowerCase().startsWith("dwt")) { | ||
String date = parsedInput.substring(3, 11); | ||
String time = parsedInput.substring(11, 15); | ||
String taskName = parsedInput.substring(15); | ||
Task task = new Task.DeadlineTask(taskName, date, time); | ||
tasks.add(task); | ||
ui.display(String.format("Added new deadline task:%n%s%n", task)); | ||
} else if (parsedInput.toLowerCase().startsWith("dnt")) { | ||
String date = parsedInput.substring(3, 11); | ||
String taskName = parsedInput.substring(11); | ||
Task task = new Task.DeadlineTask(taskName, date); | ||
tasks.add(task); | ||
ui.display(String.format("Added new deadline task:%n%s%n", task)); | ||
} else if (parsedInput.toLowerCase().startsWith("ewt")) { | ||
String date = parsedInput.substring(3, 11); | ||
String time = parsedInput.substring(11, 15); | ||
String taskName = parsedInput.substring(15); | ||
Task task = new Task.EventTask(taskName, date, time); | ||
tasks.add(task); | ||
ui.display(String.format("Added new event task:%n%s%n", task)); | ||
} else if (parsedInput.toLowerCase().startsWith("ent")) { | ||
String date = parsedInput.substring(3, 11); | ||
String taskName = parsedInput.substring(11); | ||
Task task = new Task.EventTask(taskName, date); | ||
tasks.add(task); | ||
ui.display(String.format("Added new event task:%n%s%n", task)); | ||
} else if (parsedInput.toLowerCase().startsWith("todo")) { | ||
String taskName = parsedInput.substring(4); | ||
Task task = new Task.TodoTask(taskName); | ||
tasks.add(task); | ||
ui.display(String.format("Added new todo task:%n%s%n", task)); | ||
} else { | ||
ui.display("Sorry I don't recognise that command :("); | ||
} | ||
try { | ||
storage.writeToFile(tasks.list()); | ||
} catch (IOException e) { | ||
ui.showWritingError(); | ||
} | ||
} catch (DateTimeException | IllegalArgumentException e) { | ||
ui.displayError(e); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
new Duke("data/duke.Duke.txt").run(); | ||
} | ||
|
||
} |
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.
I am curious why is this empty?