diff --git a/collated/docs/A0135722L.md b/collated/docs/A0135722L.md new file mode 100644 index 000000000000..20cb4d269776 --- /dev/null +++ b/collated/docs/A0135722L.md @@ -0,0 +1,404 @@ +# A0135722L +###### \DeveloperGuide.md +``` md +### Storage component + +
+ +**API** : [`Storage.java`](../src/main/java/seedu/simply/storage/Storage.java) + +The `Storage` component: +* Saves `UserPref` objects in json format and reads it back. +* Saves the Task Book data in xml format and reads it back. + +### Common classes + +Classes used by multiple components are in the `seedu.simply.commons` package. + +## Implementation + +### Logging + +We are using `java.util.logging` package for logging. The `LogsCenter` class is used to manage the logging levels +and logging destinations. + +* The logging level can be controlled using the `logLevel` setting in the configuration file. + (See [Configuration](#configuration)) +* The `Logger` for a class can be obtained using `LogsCenter.getLogger(Class)` which will log messages according to + the specified logging level. +* Currently log messages are output through: `Console` and to a `.log` file. + +**Logging Levels** + +* `SEVERE` : Critical problem detected which may possibly cause the termination of the application. +* `WARNING` : Can continue, but with caution. +* `INFO` : Information showing the noteworthy actions by the App. +* `FINE` : Details that is not usually noteworthy but may be useful in debugging. + e.g. print the actual list instead of just its size. + +### Configuration + +Certain properties of the application can be controlled (e.g App name, logging level) through the configuration file +(default: `config.json`): + + +## Testing + +You can find the Tests in the `./src/test/java` folder. + +**In Eclipse**: +> If you are not using a recent Eclipse version (i.e. _Neon_ or later), enable assertions in JUnit tests + as described [here](http://stackoverflow.com/questions/2522897/eclipse-junit-ea-vm-option). + +* To run all tests, right-click on the `src/test/java` folder and choose + `Run as` > `JUnit Test`. +* To run a subset of tests, you can right-click on a test package, test class, or a test and choose + to run as a JUnit test. + +**Using Gradle**: +* You can see [UsingGradle.md](UsingGradle.md) for how to run tests using Gradle. + +We have two types of tests: + +1. **GUI Tests** - These are _System Tests_ which can be found in the `guitests` package that test the entire App by simulating user actions on the GUI. + +2. **Non-GUI Tests** - These are tests not involving the GUI. They include: + 1. _Unit tests_ targets the lowest level methods/classes.
+ e.g. `seedu.simply.commons.UrlUtilTest` + 2. _Integration tests_ checks the integration of multiple code units + (these code units are assumed to be working).
+ e.g. `seedu.simply.storage.StorageManagerTest` + 3. Hybrids of unit and integration tests. These tests checks multiple code units as well as + how they are connected together.
+ e.g. `seedu.simply.logic.LogicManagerTest` + +**Headless GUI Testing** : +Thanks to the [TestFX](https://github.com/TestFX/TestFX) library we use, + our GUI tests can run in the _headless_ mode. + In the headless mode, GUI tests do not show up on the screen. + This means that you can do other things on the Computer while the tests are running.
+ See [UsingGradle.md](UsingGradle.md#running-tests) to learn how to run tests in headless mode. + +## Dev Ops + +### Build Automation + +You can see [UsingGradle.md](UsingGradle.md) to learn how to use Gradle for build automation. + +### Continuous Integration + +We use [Travis CI](https://travis-ci.org/) to perform _Continuous Integration_ on our projects. +You can see [UsingTravis.md](UsingTravis.md) for more details. + +### Making a Release + +To make a new release, you can follow the steps below: + + 1. Generate a JAR file [using Gradle](UsingGradle.md#creating-the-jar-file). + 2. Tag the repo with the version number. e.g. `v0.1` + 3. [Create a new release using GitHub](https://help.github.com/articles/creating-releases/) + and upload the JAR file you have created. + +### Managing Dependencies + +A project often depends on third-party libraries. For example, Task Book depends on the +[Jackson library](http://wiki.fasterxml.com/JacksonHome) for XML parsing. Managing these _dependencies_ +can be automated using Gradle. For example, Gradle can download the dependencies automatically, which +is better than alternatives such as:
+1. Including these libraries in the repo. (This bloats the repo size)
+2. Requiring developers to download these libraries manually. (This creates extra work for developers)
+ +## Appendix A : User Stories + +Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unlikely to have) - `*` + +Priority | As a ... | I want to ... | So that I can... + -------- | :-------- | :--------- | :----------- +*** | user | add tasks with a start time and an end time | +*** | user | add tasks with a deadline | +*** | user | add tasks that can be done anytime | +*** | user | edit existing tasks | update tasks details +*** | user | delete existing tasks | remove tasks that are no longer needed +*** | user | complete tasks | acknowledge the completion of tasks +*** | user | undo the most recent operations | undo wrong commands +*** | user | search by partial keyword | find related tasks containing the keyword +*** | user | specify my storage folder | use cloud syncing services on it +** | user | add recurring tasks | +** | user | have some variations in command keywords +** | user | set priorities | indicate tasks that are important +** | user | display completed tasks | know what I have done +** | user | hide completed tasks | conceal tasks that are completed +* | user | start the program with a shortcut/ key combination | save mouse clicks + + +## Appendix B : Use Cases + +#### Use case: Add tasks with a start time and an end time + +**MSS** + +1. User requests to add tasks with start time and end time.
+2. Task manager adds tasks into manager.
+Use case ends.
+ +**Extensions** + +2a. There is already a task in the time slot.
+ +>2a1. Task manager shows an error message.
+ Use case ends.
+ + +#### Use case: Edit existing tasks + +**MSS** + +1. User requests to edit an existing task.
+2. Task manager edits the task.
+Use case ends.
+ +**Extensions** +2a. The task requested by the user does not exist.
+ +>2a1. Task manager shows an error message.
+ Use case ends.
+ + +#### Use case: Delete existing events + +**MSS** + +1. User requests to show the list of tasks.
+2. Task manager shows the list of tasks.
+3. User requests to delete a specific task. +4. Task manager deletes the task.
+Use case ends.
+ + +**Extensions** + +2a. The list is empty.
+ +>Use case ends.
+ +3a. The given task does not exist.
+ +>3a1. Task manager shows an error message.
+ Use case ends.
+ + +#### Use case: Complete tasks + +**MSS** + +1. User requests to mark a task as completed. +2. Task manager marks the task as completed.
+Use case ends.
+ +**Extensions** +2a. The given task does not exist.
+ +>2a1. Task manager shows an error message.
+ Use case ends.
+ + +#### Use case: undo the most recent operations + +**MSS** + +1. User requests to undo previous operations.
+2. Task manager performs the request.
+Use case ends.
+ +**Extensions** +2a. There are no previous operations.
+ +> 2a1. Task manager shows a warning message.
+ Use case ends.
+ + +#### Use case: search by partial keyword + +**MSS** + +1. User requests to search for a task by keyword.
+2. Task Manager shows a list of tasks containing the keyword.
+Use case ends.
+ +**Extensions** + +1a. The matching keyword is not found.
+ +>1a1. Task manager shows an error message.
+ Use case ends.
+ +## Appendix C : Non Functional Requirements + +1. Should work on any [mainstream OS](#mainstream-os) as long as it has Java `1.8.0_60` or higher installed. +2. Should be able to hold up to a maximum of 1000 tasks per day. +3. Should come with automated unit tests and open source code. +4. Should favor DOS style commands over Unix-style commands. +5. Should load the command result within one second of execution. +6. Should not corrupt data if an unexpected crash occurs. +7. Should not require an installer to run the App. +8. Should be free. +9. Should be able to have functioning basic commands without the internet. + +You can also visit the following page for more information on Project Constraints +http://www.comp.nus.edu.sg/~cs2103/AY1617S1/ + + +## Appendix D : Glossary + +##### Mainstream OS + +> Windows, Linux, Unix, OS-X + +##### Private task detail + +> A task detail that is not meant to be shared with others + + +## Appendix E : Product Survey + +##Google Calendar + +###Pros + +1. Contains a quick add function which is similar to what we are trying to achieve, you can type the entire add command in one line with event description, time, location and it will interpret it for you and add as an event. +2. Contains multiple calendars for different aspects of life. Eg. one for work, one for family, one for play. +3. Supports automatic addition of recurring events. +4. Supports sharing of calendar. +5. Supports sharing of events. +6. Supports real time video calls to all attendees of a shared event. +7. Supports colour coding for events so that you can self-categorize according to colour. +8. Supports switching of time frames. eg. view by week, month. +9. Allows user to find a common time for everyone to attend a shared event created by you based on their Google Calendars. +10. Allows setting of time zones for each event, mainly used by frequent travellers. +11. Allows addition of documents, spreadsheets, and other files directly to an event so as to notify all guest of the details in a single platform. +12. Automatically synchronises with google account which is heavily integrated into android. +13. Ties with Google Maps for event locations. So if it is recognised in Google Maps, you can choose an exact meeting place. + +###Cons + +1. Severe mouse clicks required to fill up the numerous columns. +2. Security issues. It is connected to the web so there is the possibility of hacking which can reveal your life schedule. + +##Todoist + +###Pros + +1. Contains a very high limit to storing of data. +2. Contains shortcut keys. Eg. To bold : control b; For italics : control i. +3. Contains tabs like today's or tomorrow's task for ease of access. +4. Contains multiple priority choices to user. +5. Contains duplication of templates from other projects. +6. Allows addition of labels/ tags. +7. Allows premium users to add links and files to a specific task - Eg. Links to work, files and documents. +8. Supports third party integration. Eg. Links to dropbox and other services like Zapier, Google Drive, Cloud Magic, Sunrise Calendar, etc... +9. Supports shifting of tasks. +10. Supports colour code for priority. +11. Supports automatic addition of recurring events. Eg. every day/every Tuesday/ holidays etc... +12. Supports multiple categories called projects for sorting of task such as shopping , work, personal, errands, or create your own
+13. Supports sharing of projects and assigning of task to others. +14. Supports multiple filters like priority settings, tags/labels, tasks assigned to me or others, etc... + +###Cons + +1. Security issues. It is connected to the web so there is the possibility of hacking which can reveal your life schedule. +3. Multiple categories may confuse users. +4. Severe mouse clicks required for adding of tasks and to navigate between categories, checking purposes and boxes for filling of details. +5. Monetary means required for premium access. +6. Usage of a mouse required for shifting of tasks. Eg. drag and drop. + +##Wunderlist + +###Pros + +1. Contains a easy to use search function. +2. Contains a visually pleasing interface. +3. Contains intuitive options and menu selections that is user friendly. +4. Contains customizable backgrounds. +5. Contains multiple task lists. +6. Contains shortcuts to starred tasks, overdues and today's tasks. +7. Contains cloud syncing functionality. +8. Supports multiple platforms such as windows, mac, android and ios. +9. Supports automatic addition of recurring events. +10. Supports setting of reminders and notifications. +11. Supports sharing of events. + +###Cons + +1. No available option for addition of subtasks. +2. No available option for addition of start date for events. +3. Monetary means required for premium access. +4. Uploading of files not supported. +5. Organisation of tasks not supported. +6. Function to sync with third party services like dropbox and google drive is not available. + +##Trello + +###Pros + +1. Supports multiple platforms such as windows, mac, android and ios. +2. Supports sharing of tasks with other users. +3. Supports updates by email when other teammates make changes. +4. Supports syncing of tasks with web and other users in real time. +5. Allows for free subscription, and also offers a professional package, with the privacy and administrative settings required by large enterprises. +6. Contains a visually pleasing interface. +7. Allows tasks to be tracked easily. + +###Cons + +1. No functionality to sort cards and reports in the order of user's preference. +2. No functionalities to assign a task to members in a checklist. +3. No functionality for calendar view for user preference. +4. Due dates are not allowed for input. +``` +###### \UserGuide.md +``` md +###4 Marking tasks as done + +Remember the report that we added at the start? Once you have done it, simply type the following command below and Enter and you will never have to see it again. Unless of course, if you want to, then we will show you how in the later part of this user guide. + +> Format: done <index> + +Example: done D1 + +This will hide the report that you have completed from the main screen. + +
+You can also complete multiple tasks at once by following the formats below. + +> Format: done <index>-<index> + +Example : done T1-T3 + +This marks the range of tasks between the first index and the second index as done while this, + +> Format: done <index>, <index> + +Example: done T1, E2, D4 + +marks the specified indexes as done. + +
+###5 Display tasks + +####5.1 Display completed tasks + +Remember how we have hidden away your completed report? If you wish to see it again, the following display command will display all completed tasks in their respective categories. + +> Format: list done + +From here, you can choose to delete these tasks. Deleting will be covered in the section after this. + +
+####5.2 Display all tasks + +Now that you have seen all the tasks that you have done, to return to the main default screen, simply type the following command and Enter. + +> Format: list + +
+``` diff --git a/collated/docs/A01388993L.md b/collated/docs/A01388993L.md new file mode 100644 index 000000000000..8d45b5c5fd02 --- /dev/null +++ b/collated/docs/A01388993L.md @@ -0,0 +1,51 @@ +# A01388993L +###### \UserGuide.md +``` md +###1 Add Command +There are three variations to the add command. You are able to choose a task to be categorized under events, deadlines or to-dos. To differentiate the formatting for these commands, refer to the section below. +

+####1.1 Add a to-do + +To start things off, let us add a simple task with no date or time, just a simple task to be done anytime and anyday. + +>Format: **add** <to-do description> <#tag> + +Example: add go swimming #fitness +

+>Note: tags are optional and multiple tags can be added to all tasks. + +
+####1.2 Add a deadline + +Perhaps after adding a to-do, now you want to add a task with a deadline. Let's say you have to do a report by next Monday, 7pm. + +>Format: **add** <deadline description>; <date(DDMMYY)>; <end time> <#tag> + +Example: add complete report; 120916; 1900 #fml +

+>Important: The date is compulsory when adding an deadline. If end time is not specified, a default of 11.59pm on the entered date is set. + +
+####1.3 Add an event + +Let's say you have to attend a friend's birthday party on the weekend. You know the date, the time it starts, as well as the time it ends. + +>Format : **add** [<event description>; <date(DDMMYY)>; <start time>; <end time>] <#tag> + +Example: add [Sam's birthday party; 20/12/16 ; 9pm] #birthday #rememberToBuyPresent + +>Note: The start time and end time is optional when adding an event. If neither is specified, the default date will be the current date, the default start time will be the current time and the default end time will be 2359. + +>Important: The square brackets are compulsory when adding an event. + +
+####1.4 Add a tag / multiple tags to existing tasks + +Your friend suddenly informs you that he has heard that your teacher has prepared a 'nice' surprise for students who submit the report due on Monday late. Now that the report due on Monday has become a very important task to do, simply type add followed by the index of the report and the tags to be added and Enter. + +>Format: **add** <index> #tag1 #tag2 + +Example: Add D1 #VeryImportant #omg + +
+``` diff --git a/collated/docs/A0138993L.md b/collated/docs/A0138993L.md new file mode 100644 index 000000000000..12930e5ab92d --- /dev/null +++ b/collated/docs/A0138993L.md @@ -0,0 +1,18 @@ +# A0138993L +###### \DeveloperGuide.md +``` md +### Logic component + +
+ +**API** : [`Logic.java`](../src/main/java/seedu/simply/logic/Logic.java) + +* `Logic` uses the `Parser` class to parse the user command. +* This results in a `Command` object which is executed by the `LogicManager`. +* The command execution can affect the `Model` (e.g. adding a task) and/or raise events. +* The result of the command execution is encapsulated as a `CommandResult` object which is passed back to the `Ui`. + +Given below is the Sequence Diagram for interactions within the `Logic` component for the `execute("delete E1")` + API call.
+
+``` diff --git a/collated/docs/A0139430L.md b/collated/docs/A0139430L.md new file mode 100644 index 000000000000..44b34e7b4f7d --- /dev/null +++ b/collated/docs/A0139430L.md @@ -0,0 +1,149 @@ +# A0139430L +###### \DeveloperGuide.md +``` md +### Model component + +
+ +**API** : [`Model.java`](../src/main/java/seedu/simply/model/Model.java) + +The `Model`: +* Stores a `UserPref` object that represents the user's preference. +* Stores the Task Book data. +* Exposes a `UnmodifiableObservableList` that can be 'observed' e.g. the UI can be bound to this list + so that the UI automatically updates when the data in the list changes. + +> Note that `Model` does not depend on any of the other three components. +``` +###### \UserGuide.md +``` md +###2 Edit a task + +When you accidentally enter the wrong details for any of your tasks, worry not. The multiple edit task methods listed below allow you to update specific task details. +

+>Note: Adding a end time to a to-do will automatically convert your to-do into a deadline due today with the specified end time. + +>Note: Adding a start time to a deadline will automatically convert a deadline to an event. + +>Note: Adding a date to a to-do will automatically convert your to-do into a deadline with a default end time of 2359 on that date. + +>Note: Removing the end time from a deadline will automatically convert your deadline to a to-do. + +>Note: Removing the start time from a event will automatically convert your event to a deadline. + +
+####2.1 Edit task description + +Remember the birthday party previously entered? Perhaps now instead of entering Sam's birthday party, you want to change the description to Samantha's birthday party. To do so, simply follow the command format below. + +>Format: **edit** <index> **des** <description> + +Example: edit E1 des Sam's birthday party + +
+####2.2 Edit task date + +Now, maybe the date of the birthday party you previously entered is also wrong and should be one day later instead. To change the date, use the following command. + +>Format: **edit** <index> **date** <date> + +Example: Edit E1 date 21/12/16 +

+>Note: If you add a date to a to-do, this will automatically convert your to-do into a deadline with a default end time of 2359 on that date. + +
+If you wish, you can also remove the date of a task by following this format. + +>Format: **edit** <index> **date** no date; + +Doing so will change an event into a to-do. Removing the date from a deadline will also change it into a to-do. + +
+####2.3 Edit task start time + +Samantha's birthday party is tomorrow and she has called to inform you that her party is starting two hours earlier at 5pm instead. To change the start time, simply use the following command. + +>Format: **edit** <index> **start** <start time> + +Example: edit E1 start 5pm +

+>Note: Adding a start time to a to-do will automatically convert your to-do into an event with a default day of today, with a default end time of 2359 and start time as entered. + +
+If you wish, you can also remove the start time of a task by following this format. + +>Format: **edit** <index> **start** no start; + +Doing so will change a event into a deadline. + +
+####2.4 Edit task end time + +Samantha has also informed you that the party is scheduled to end at 11pm, so that you can tell your parents when to pick you up. To update the end time, type the following and Enter. + +>Format: **edit** <index> **end** <end time> + +Example: edit E1 end 2300 +

+>Note: Adding a end time to a to-do will automatically convert your to-do into a deadline with a default date of today and end time as entered. + +
+If you wish, you can also remove the end time of a task by following this format. + +>Format: **edit** <index> **end** no end; + +Doing so to an event will result in it's end time being set to a default of 2359. Removing the end time from a deadline will change the end time to a default of 2359. + +
+####2.5 Edit a specific tag + +You have been very busy and forgot to buy Samantha's present so you want to remind yourself that you absolutely have to buy that present tomorrow for her. + +You can do so by changing the existing rememberToBuyPresent tag to AbsolutelyRememberToBuyPresent tag with the following command. + +>Format: **edit** <index> **tag** <old_tag>`>`<new_tag> + +Example: edit E1 #rememberToBuyPresent`>`#AbsolutelyRememberToBuyPresent + +If there is only one tag, you can use the following command instead to change the tag. + +>Format: **edit** <index> new tag + +

+ +###3 Find Task by Keyword + +Should you need to find any task based on details which you only partially remember, the find by keyword command can help you in finding them. Partial keywords are allowed and you can search for tasks by date, time or description. + +> Format: **find** <keyword> + + +Example: find report + +Only tasks with the keyword are displayed. Keywords are NOT case sensitive. + +
+``` +###### \UserGuide.md +``` md +###6 Delete task + +If you no longer need any tasks, simply delete them by using the delete command availabe in the following formats. + +> Format: delete <index> + +> Format: delete <index>-<index> + +> Format: delete <index>, <index> + + +Example: delete T3 + +Example: delete T1-T3 + +Example: delete T1, T3 + +The delete command is flexible and allows you to delete more than 1 task at a time. If the indexes entered are separated by a hyphen (-), Simply will delete all tasks between the numbers including the numbers enter. If the indexes are separated by a comma (,) Simply will delete the tasks entered individually. + +
+``` diff --git a/collated/docs/A0147890U.md b/collated/docs/A0147890U.md index 94b9f3c49de0..1b9bd12017c1 100644 --- a/collated/docs/A0147890U.md +++ b/collated/docs/A0147890U.md @@ -1,660 +1,129 @@ # A0147890U -###### \AboutUs.md -``` md - -# About Us - -We are a team of four computer engineering students based in the [School of Computing, National University of Singapore](http://www.comp.nus.edu.sg). - -## Project Team - -###Project Mentor : Nirandika Wanigasekara - -
- ------ - -#### Lim Wei Ming Ronald - -
-**Role**: Team Leader
-Responsibilities: Documentation, Deliverables and Deadlines, Scheduling and Tracking - -Components in charge of: UI - -* Features Implemented:
- * Set storage folder
- * Undo and Redo
- * List - -Code written: [[functional code](A0147890U.md)][[docs](A0147890U.md)] - -* Other major contributions:
- * Implemented the initial edit task command - * Set up Travis and Coveralls - ------ - -#### Zavier Ong -Role: Developer
-Responsibilities: Code Integration - -Components in charge of: Logic -* Features Implemented:
- * Add task commands - -Code written: [[functional code](A0138993L.md)][[test](A0138993L.md)][[docs](A0138993L.md)] - -* Other major contributions:
- * Implemented DateTime support - * Implemented Parser - * Wrote test cases - ------ - -#### Hu JingRui -Role: Developer
-Responsibilities: Testing - -Components in charge of: Model -* Features Implemented:
- * Find task - * Delete task - * Edit task - -Code written: [[functional code](A0139430L JingRui.md)][[test](A0139430L JingRui.md)][[docs](A0139430L JingRui.md)] - -* Other major contributions:
- * Wrote test cases - ------ - -#### Li Zhiyuan -Role: Developer
-Responsibilities: Code Quality, Tool Expert - -Components in charge of: Storage -* Features Implemented:
- * Done command - - ------ -``` ###### \DeveloperGuide.md ``` md +### UI component -## Appendix A : User Stories - -Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unlikely to have) - `*` - -Priority | As a ... | I want to ... | So that I can... - -------- | :-------- | :--------- | :----------- -*** | user | add events with a start time and an end time | -*** | user | add tasks without a specified time | -*** | user | add tasks without a deadline | -*** | user | edit existing events | update deadlines or venues -*** | user | delete existing events | remove entries that is no longer needed -*** | user | complete events | acknowledge the completion of event -*** | user | undo the most recent operations | undo wrong commands -*** | user | search by partial keyword | find related events containing the keyword -*** | user | be able to specify my storage folder | use cloud syncing services on it -** | user | add tasks that is recurring | -** | user | some variations in command keywords -** | user | set priorities | indicate tasks that are important -* | user | start the program with a shortcut/ key combination | save mouse clicks -* | user | display completed tasks | know what I have done -* | user | hide completed | conceal events that are completed - - -## Appendix B : Use Cases - -#### Use case: Add events with a start time and an end time - -**MSS** - -1.User requests to add events with start time and end time -2.Task manager adds events into manager
-Use case ends - -**Extensions** - -2a. There is already an event in the time slot - ->2a1. Task manager shows an error message - Use case ends - - -#### Use case: Edit existing events - -**MSS** - -1.User requests to edit existing events -2.Task manager edits the events
-Use case ends - -**Extensions** -2a. There is no such event requested by the user - ->2a1. Task manager shows an error message - Use case ends - - -#### Use case: Delete existing events - -**MSS** - -1.User request to show list of events/task -2.Task manager shows list of events/task -3.User request to delete a specific event / task -4.Task manager deletes the event / task
-Use case ends - - -**Extensions** - -2a. The list is empty - ->Use case ends - -3a. The given event/task is non existent - ->3a1. Task manager shows an error message
- Use case ends - - -#### Use case: Complete events - -**MSS** - -1.User request to update a specific event / task to completed -2.Task manager updates the event / task as completed
-Use case ends - -**Extensions** -2a. The given event/task is non existent - ->2a1.Task manager shows an error message
- Use case ends - - -#### Use case: undo the most recent operations - -**MSS** - -1.User request to undo previous operations -2.Task manager undoes the operations
-Use case ends - -**Extensions** -2a. There are no previous operations - -> 2a1.Task manager shows an warning message
- Use case ends - - -#### Use case: search by partial keyword - -**MSS** - -1.User requests to search for an event by keyword -2.Task Manager shows a list of events/tasks containing the keyword -Use case ends - -**Extensions** - -1a. The matching keyword is not found - ->1a1.Task manager shows an error message - Use case ends - -## Appendix C : Non Functional Requirements - -1. Should work on any [mainstream OS](#mainstream-os) as long as it has Java `1.8.0_60` or higher installed. -2. Should be able to hold up to max 100 tasks per day. -3. Should come with automated unit tests and open source code. -4. Should favor DOS style commands over Unix-style commands. - -You can also visit the following page for more information on Project Constraints -http://www.comp.nus.edu.sg/~cs2103/AY1617S1/ - - -## Appendix D : Glossary - -##### Mainstream OS - -> Windows, Linux, Unix, OS-X - -##### Private task detail - -> A task detail that is not meant to be shared with others - - -## Appendix E : Product Survey - -##Google Calendar - -###Pros - -1. Quick add function -2. Similar to what we are trying to achieve, you can type the entire add command in one line with event description, time, location and it will interpret it for you and add as an event. It ties into Google Maps for event locations. So if it is recognised in Google Maps, you can choose an exact meeting place. -3. Support for recurring events -4. Google Calendar is remarkably social -5. Calendar can be shared. -6. Supports shared events. -7. Ability to find a common time for everyone to attend a shared event created by you based on their Google Calendars. -8. Can add a video call such that all attendees to a shared event can join the same video call -9. Ability to set a specific time zone for each event. For the frequent travellers. -10. You can add documents, spreadsheets, and other files directly to an event so that your guests have all the information they need right in the event. -11. Support for multiple calendars for different aspects of life. Eg. one for work, one for family, one for play -12. Google Calendar automatically synchronises with google account which is heavily integrated into android. -13. Colour coding for events so that you can self-categorize according to colour. -14. Calendar view time frame can be switched. View by week, month. - -###Cons - -1. Lots of mouse clicks; lots of different columns to fill. -2. Security. Online so it can be hacked, revealing your life schedule. +
-##Todoist +**API** : [`Ui.java`](../src/main/java/seedu/simply/ui/Ui.java) -###Pros - -1. Colour code for priority, not time -2. Command allows for recurring days eg every day/every Tuesday/ holidays etc. -3. User able to choose subcatergories like task today, task tomorrow but (involves 1 click) -4. Task can divide to further catagories called projects like shopping , work personal, errands, or create your own(involves 1 click) > for bigger projects subcategories can be created. Projects are shareable with others -6. Filters > priority setting priority1, priority 2, assign to me or assign to others -7. Adding priority (click 2 times) one for flag menu, two for flag colour 4 priority choices or add -8. Able to exploit templates for other projects -9. Lots of filters to choose from -10. Add labels/ tags -11. Premium acc – add files to task. Supports third party integration eg link to dropbox/ integrates with other services like Zapier, Google Drive, Cloud Magic, Sunrise Calendar, and others -12. Uses drag and drop to shift tasks -13. Karma system> trend>> shows productivity over time > graph> bar(shows type for task done) / sets goals for the week / enable/ disable for vacations etc… a karma level eg grandmaster 5000+ to make user feel good -14. History : no limit -15. Bold italic control i control b - -###Cons - -1. not jim friendly, involves clicking form filling style eg. Click add> type task>click schedule>click to choose date or for recurring dates > type every day or every week. Edit>click and change -2. Able to link schedules with other people. Eg assign task to others(jim do not need it?) -3. Most of Jim’s todo items arrive as emails. -4. Divides into too many catagories too messy for jim. - - -##Wunderlist - -###Pros - -1. It is available across windows, mac, android and ios. -2. Easy search function -3. Free for non-premium users -4. Nice interface -5. Intuitive options and menu selections that is not complicated -6. Customizable backgrounds to your own liking -7. Able to accept recurring events -8. Can set reminders and notifications -9. Can share between people -10. Multiple task lists -11. Short cuts to starred task, overdues and today task -12. Cloud syncing - - -###Cons - -1. There is no options for subtasks. -2. No start dates for events -3. Need to pay for premium -4. Excel files cannot be uploaded -5. Have to do organization of tasks, events or other stuff by ourselves, they do not group them up for us. -6. Does not sync with google - -##Trello - -###Pros - -1. Works both on web and mobile devices -2. Free subscription, but also offers a professional package, with the privacy and administrative settings required by large enterprises. -3. Good visual -4. Track task easily -5. Able to collaborate with multiple people on a single task -6. Receive email update when other teammates make changes -7. Always in sync - -###Cons - -1. Does not provide a lot of tools to sort cards or reports -2. Inability to put due dates -3. Inability to put tag on members in checklist -4. Does not have calendar +The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `EventListPanel`, +`DeadlineListPanel`, `TodoListPanel` etc. All these, including the `MainWindow`, inherits from the abstract `UiPart` class +and they can be loaded using the `UiPartLoader`. +The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files + that are in the `src/main/resources/view` folder.
+ For example, the layout of the [`MainWindow`](../src/main/java/seedu/simply/ui/MainWindow.java) is specified in + [`MainWindow.fxml`](../src/main/resources/view/MainWindow.fxml) +The `UI` component: +* Executes user commands using the `Logic` component. +* Binds itself to some data in the `Model` so that the UI can auto-update when data in the `Model` changes. +* Responds to events raised from various parts of the App and updates the UI accordingly. ``` ###### \UserGuide.md ``` md +###7 Undo the Most Recent Commands -# User Guide - -* [Getting Started](#getting-started) -* [Features](#features) -* [FAQ](#faq) -* [Command Summary](#command-summary) - -## Getting Started - -1. Ensure you have Java version `1.8.0_60` or later installed in your Computer.
- > Having any Java 8 version is not enough.
- This app will not work with earlier versions of Java 8. - -2. Download the latest `simply.jar` from the [releases](../../../releases) tab. -3. Copy the file to the folder you want to use as the home folder for your Simply. -4. Double-click the file to start the app. The GUI should appear in a few seconds. - -
- -5. Type the command in the command box and press Enter to execute it.
- e.g. typing **`help`** and pressing Enter will open the help window. - -6. Refer to the [Features](#features) section below for details of each command.
- - -## Features - -###1 Add Command -There are three variations to the add command. You are able to choose a task to be categorized under events, deadlines or to-dos. To differentiate the formatting for these commands, refer to the section below. - -####1.1 Add an event - ->Format : **Add** [<event description>; <date(DDMMYY)>; <start time>; <end time>] <#tag> <priority> - -Example: Add [Sam's birthday party; 20/12/16 ; 9pm] #YOLO ! - ->Note: The start time and end time is optional when adding an event. ->Note: ALL tags are optional and Multiple tags can be added ->Note: ALL marking as a priority is also optional ->Note: Time format accepted: 9pm, 9.45pm, 13:59 ->Note: Date format accepted: 20/12/2016, 20/12/16, 201216 - ->Important: The square brackets are compulsory when adding an event. - -####1.2 Add a deadline - ->Format: **Add** <deadline description>; <date(DDMMYY)>; <end time> <#tag> <priority> - -Example: Add complete report; 120916; 1900 #YOLO ! - ->Important: The date and end time are compulsory when adding an deadline - -####1.3 Add a to-do - ->Format: **Add** <to-do description> <#tag> <priority> - -Example: Add go swimming #YOLO ! - ->Note: To do tasks do not have a date or time. - ->***Note: To add a tag, simply add a # followed by the tag name at the back of the command -To add a priority, simply add a ! at the back of the command.*** - -####1.4 Add a tag / multiple tags - -You can add tag by adding a # at the end of the command for event, deadline or to-do. - -Example: Add [Sam's birthday party; 20/12/16; 9pm] #dontbelate -Example: Add complete report; 120916; 1900 #prayforuserguide -Example: Add go swimming #yolo #summerishere #waterforlife - -You can also add tag to an existing task. - ->Format: **Add** <index> #tag1 #tag2 - -Example: Add E1 #win #victor #finally - - -###2 Edit a task - -The multiple edit task functions allow you to update specific task details. - -####2.1 Edit all task details in one go - ->Format: **Edit** <index> [<event description>; <date>; <start time>; <end time>; <tags>;] - ->Format: **Edit** <index> <deadline description>; <date>; <end time>; <tags>; - ->Format: **Edit** <index> <to-do description>; - -To add certain task details like start time, simply add their corresponding sections in the command format. - -To remove certain task details like end time, simply leave their corresponding sections in the command format blank. - ->Note: Adding a start time and end time to a to-do will automatically convert your to-do into and event. - ->Note: Adding a end time to a to-do will automatically convert your to-do into a deadline. - ->Note: Adding a start time to a deadline will automatically convert a deadline to an event. - ->Note: Add a date to a to-do will automatically convert your to-do into a deadline with a default end time of 2359 on that date. - ->Note: Removing date from events and deadlines will automatically convert them into a to-do with no date or time. - ->Note: Removing start time from events will automatically convert them into deadlines. - ->Note: Removing end time from deadlines will automatically set the end time of the deadline to 2359. - -####2.2 Edit task description - ->Format: **Edit** <index> **des** <description> - -Example: Edit T1 des eat apple - -####2.3 Edit task date - ->Format: **Edit** <index> **date** <date> - -Example: Edit E1 date 12/09/16 - ->Note: If you add a date to a to-do, this will automatically convert your to-do into a deadline with a default end time of 2359 on that date. - -####2.4 Edit task start time - ->Format: **Edit** <index> **start** <start time> - -Example: Edit E1 start 7am - ->Note: Adding a start time to a to-do will automatically convert your to-do into an event with a default day of today and start time as entered. - -####2.5 Edit task end time +Oh no! What happens if you accidentally deleted something by mistake? In life, there are no undos but here, there are. The following undo command enables you to undo the most recent executed command, restoring anything lost. ->Format: **Edit** <index> **end** <end time> - -Example: Edit E1 end 1900 - ->Note: Adding a end time to a to-do will automatically convert your to-do into a deadline with a default date of today and end time as entered. - -####2.6 Edit a specific tag - ->Format: **Edit** <index> **tag** <old_tag> ***>*** <new_tag> - -Example: Edit D1 #doOrdie > #died - - -###3 Find Task by Keyword - -The find by keyword command enables you to search for any events, deadlines, to-dos that have been added to Simply. If the searched task is not found, an error message will be shown. - -> Format: **Find** <keyword> - - -Example: - -Find **siloso** - -Find 050316 - -Find 2359 - -Find #CS2103 - - -Only the tasks with the keyword are displayed. Keywords are NOT case sensitive. - - -###4 Mark done tasks - -When you are done with tasks, enter this command to mark them as done and hide them away. - -> Format: Done <index> - -> Format: Done <index>-<index> - -> Format: Done <index>, <index> - - -Example: - -Done T1 - -Done T1-T3 - -Done T1, T3 - - ->Note: if you want to select more than one task to complete, you can separated the task by a hyphen (-) to complete all tasks that are within the range. In addition, you also need to separate the task by a comma (,) to individually delete them. - - -###5 Display tasks - -####5.1 Display completed tasks - -The display command will display the completed tasks in their respective categories. - -> Format: list done - -####5.2 Display all tasks - -This is mainly used to return to the default screen showing all tasks. - -> Format: list - - -###6 Undo the Most Recent Commands - -The undo command enables you to undo the most recent executed command. - -> Format: Undo <number of operations> - -Example: - -Undo - -Undo 2 - - ->Note: The undo command can only undo a maximum of 5 executed commands +> Format: undo <number of operations> +Example: undo 2 +

>Note: If no number is entered, the default number of times the command will undo is 1. +

+>Note: If you perform a add command to add a task after undoing another command, you will no longer be able to redo your undone command. +
+###8 Redo the Most Recent Undone Commands -###7 Redo the Most Recent Commands - -The redo command enables you to redo the most recent undone command. - -> Format: Redo <number of operations> - -Example: - -Redo +If after using the undo command, you realise that the command you just undid is correct. Simply, type the following command to redo it. -Redo 2 - ->Note: The Redo command can only undo a maximum of 5 undone commands +> Format: redo <number of operations> +Example: redo 2 +

>Note: If no number is entered, the default number of times the command will redo is 1. +
+###9 Clearing the program -###8 Delete task - -####8.1 Deleting a task - -The delete command enables you to delete the tasks that you no longer need. - -> Format: Delete <index> +If you wish to remove all tasks in Simply and start off on a clean slate, simply use the following command. -> Format: Delete <index>-<index> +>Format: clear -> Format: Delete <index>, <index> +
+###10 Exiting the program +When you are done and wish to exit the program, simply type exit and Enter. This saves all your data and exits the program. -Example: +> Format: **exit** -Delete T3 +
+###11 Help -Delete T1-T3 +Should you forget how to use any of the commands, you can simply type help in the command box and Enter. +This opens a window showing the command summary for your quick reference. If you need more in-depth details like the advanced features of each command, please refer back to this user guide. -Delete T1, T3 +> Format: **help** +
+###12 Setting Storage Folder ->Note: The delete command is flexible and allows you to delete more than 1 task at a time. If the indexes entered are separated by a hyphen (-), Simply will delete all tasks between the numbers including the numbers enter. If the indexes are separated by a comma (,) Simply will delete the tasks entered individually. - -####8.2 Deleting a tag / multiple tags - ->Format: **Delete** <index> #tag1 #tag2 - -Example: Delete E1 #win #victor #finally - - -###9 Exiting the program - -This command enables you to close the program. - -> Format: **Exit** - -Example: Exit - - -###10 Help - -> Format: **Help** - - -Example : Help - - -###11 Setting Storage Folder +If for any reason, you wish to change the location of the stored data file. Maybe so that you can synchronise that folder with online cloud storage services, you can change the folder by using the following command. >Format: **storage** <valid file path> Example: storage C:\Users\Ronald\Documents\DummyFolder -The task manager shifts your file from the current storage folder to the newly specified one on exit. +The task manager shifts your data file from the current storage folder to the newly specified one on exit. +
+## How do I transfer my data to another Computer? -## FAQ - -**Q**: How do I transfer my data to another Computer?
-**A**: Install the app in the other computer and overwrite the empty data file it creates with - the file that contains the data of your previous Address Book folder. +**A**: Install the app in the other computer and overwrite the default data file it generates with + your current data file. + +>Note: Search for the default taskbook.xml file that is stored in the data folder and overwrite it. +
+###Date and Time Formats Accepted + Date | Time | + -------- | :-------- | +120916| 1300| +12-09-16| 1pm| +12/09/16| 1.00pm| +12.09.16| | +
###Command Summary No. | Command | Format - -------- | :-------- | :--------- | :----------- -1| Add event| add [event_description; date; start_time; end_time] -2| Add deadline | add deadline_description; date; end_time + -------- | :-------- | :--------- | +1| Add event| add [event_description; date; start_time; end_time] +2| Add deadline | add deadline_description; date; end_time 3| Add to-do | add to-do_description 4| Add with tags | add [event_description, date, start_time, end_time] #tag -5| Edit | edit <index> <new_event_description> +5| Edit | edit <index> **des** <new_task_description> + | | edit <index> **date** <new_task_date> + | | edit <index> **start** <new_task_startTime> + | | edit <index> **end** <new_task_endTime> + | | edit <index> **tag** <new_tag> + | | edit <index> **tag** oldTag**>**newTag 6| Find | find <keywords> 7| Done | done <index>, <index> -8| Undo | undo <number of times to undo, up to 5> -9| Redo | redo <number of times to redo, up to 5> -10| Delete | delete <index>, <index> -11| Exit | exit -12| help | help -13| list | list -14| list done| list done -15| storage| storage <valid file path> + | | done <index>-<index> +8| List | list done + | | list +10| Delete | delete <index>, <index> + | | delete <index>-<index> +11| Undo | undo <number of times to undo> +12| Redo | redo <number of times to redo> +13| Clear | clear +14| Exit | exit +15| Help | help +16| Storage| storage <valid file path> ``` ###### \UserStoriesCases.md ``` md diff --git a/collated/main/A0135722L Zhiyuan.md b/collated/main/A0135722L Zhiyuan.md index 9881e2ade1a6..144bb3bed33a 100644 --- a/collated/main/A0135722L Zhiyuan.md +++ b/collated/main/A0135722L Zhiyuan.md @@ -1,5 +1,5 @@ # A0135722L Zhiyuan -###### \java\seedu\address\logic\commands\DoneCommand.java +###### \java\seedu\simply\logic\commands\DoneCommand.java ``` java public class DoneCommand extends Command { @@ -113,7 +113,7 @@ public class DoneCommand extends Command { } ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java private Command prepareComplete(String args) { final Matcher matcher = ARGS_FORMAT_COMPLETE.matcher(args.trim()); @@ -171,18 +171,17 @@ public class DoneCommand extends Command { } /** - * Parses arguments in the context of the select task command. ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java public synchronized void markDone(ReadOnlyTask target) throws TaskNotFoundException { taskBook.completeTask(target); updateFilteredListToShowAllUncompleted(); - indicateAddressBookChanged(); + indicateTaskBookChanged(); } ``` -###### \java\seedu\address\model\task\UniqueTaskList.java +###### \java\seedu\simply\model\task\UniqueTaskList.java ``` java public boolean completed(ReadOnlyTask target) { int completeIndex = internalList.lastIndexOf(target); @@ -203,42 +202,3 @@ public class DoneCommand extends Command { } } ``` -###### \java\seedu\address\model\TaskBook.java -``` java - public boolean completeTask(ReadOnlyTask target) throws UniqueTaskList.TaskNotFoundException { - int category = target.getTaskCategory(); - if(category == 1){ - if (events.completed(target)) { - return true; - } else { - throw new UniqueTaskList.TaskNotFoundException(); - } - } - else if(category == 2){ - if (deadlines.completed(target)) { - return true; - } else { - throw new UniqueTaskList.TaskNotFoundException(); - } - } - else{ - if (todo.completed(target)) { - return true; - } else { - throw new UniqueTaskList.TaskNotFoundException(); - } - } - } - - public void overdueTask() { - for (Task task: events) { - events.markOverdue(task); - //System.out.println("events:" + task.getOverdue()); - } - for (Task task: deadlines) { - deadlines.markOverdue(task); - //System.out.println("deadlines:" + task.getOverdue()); - } - } - -``` diff --git a/collated/main/A0135722L.md b/collated/main/A0135722L.md new file mode 100644 index 000000000000..666c8e59b9ba --- /dev/null +++ b/collated/main/A0135722L.md @@ -0,0 +1,29 @@ +# A0135722L +###### \java\seedu\simply\model\TaskBook.java +``` java + public boolean completeTask(ReadOnlyTask target) throws UniqueTaskList.TaskNotFoundException { + int category = target.getTaskCategory(); + if(category == 1){ + if (events.completed(target)) { + return true; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + else if(category == 2){ + if (deadlines.completed(target)) { + return true; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + else{ + if (todo.completed(target)) { + return true; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + } + +``` diff --git a/collated/main/A0138993L.md b/collated/main/A0138993L.md index e33cfb49bfba..606a9ceeed90 100644 --- a/collated/main/A0138993L.md +++ b/collated/main/A0138993L.md @@ -1,7 +1,7 @@ # A0138993L -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java - * Adds a task to the address book. + * Adds a task to the task book. */ public class AddCommand extends Command { @@ -34,7 +34,7 @@ public class AddCommand extends Command { /** * Convenience constructor using raw values. ``` -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java * @throws IllegalValueException if any of the raw values are invalid */ @@ -54,14 +54,15 @@ public class AddCommand extends Command { false, new UniqueTagList(tagSet) ); - if (!startBeforeEnd(toAdd.getStart().toString(), toAdd.getEnd().toString())){ + if (!startBeforeEnd(toAdd.getStart().toString(), toAdd.getEnd().toString())) { throw new IllegalValueException(END_TIME_BEFORE_START_TIME_MESSAGE); } - if (this.toAdd.getOverdue()==1) + if (this.toAdd.getOverdue()==1) { overdue =1; + } } ``` -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java public AddCommand(String name, String date, String end, Set tags) //deadline throws IllegalValueException { @@ -79,11 +80,12 @@ public class AddCommand extends Command { false, new UniqueTagList(tagSet) ); - if (this.toAdd.getOverdue()==1) + if (this.toAdd.getOverdue()==1) { overdue =1; + } } ``` -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java public AddCommand(String name, Set tags) //todos throws IllegalValueException { @@ -107,15 +109,16 @@ public class AddCommand extends Command { return overdue; } ``` -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java private boolean startBeforeEnd(String start, String end) { LocalTime start_time = LocalTime.of(Integer.parseInt(start.substring(0,2)), Integer.parseInt(start.substring(2, 4))); LocalTime end_time = LocalTime.of(Integer.parseInt(end.substring(0,2)), Integer.parseInt(end.substring(2, 4))); - if (start_time.isBefore(end_time)) + if (start_time.isBefore(end_time)) { return true; - else + } else { return false; + } } @Override @@ -128,33 +131,71 @@ public class AddCommand extends Command { try { model.addTask(toAdd); - if (toAdd.getTaskCategory() == 1){ - char category = 'E'; - int index = model.getFilteredEventList().indexOf(toAdd); - EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); - return new CommandResult(String.format(EVENT_SUCCESS, toAdd)); - } - else if (toAdd.getTaskCategory() == 2){ - char category = 'D'; - int index = model.getFilteredDeadlineList().indexOf(toAdd); - EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); - return new CommandResult(String.format(DEADLINE_SUCCESS, toAdd)); - } - else{ - char category = 'T'; - int index = model.getFilteredTodoList().indexOf(toAdd); - EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); - return new CommandResult(String.format(TODO_SUCCESS, toAdd)); - } + return addAndSelectTaskToCorrectLIst(toAdd); } catch (UniqueTaskList.DuplicateTaskException e) { return new CommandResult(MESSAGE_DUPLICATE_TASK); } - + } + /** +``` +###### \java\seedu\simply\logic\commands\AddCommand.java +``` java + * Adds and selects the Task when added into Simply + * @param toAdd the tasks added + * @return the command Result whether it is a event, deadline or todo + */ + private CommandResult addAndSelectTaskToCorrectLIst(Task toAdd) { + if (toAdd.getTaskCategory() == 1){ + selectEvent(toAdd); + return new CommandResult(String.format(EVENT_SUCCESS, toAdd)); + } else if (toAdd.getTaskCategory() == 2){ + selectDeadline(toAdd); + return new CommandResult(String.format(DEADLINE_SUCCESS, toAdd)); + } else{ + selectTodo(toAdd); + return new CommandResult(String.format(TODO_SUCCESS, toAdd)); + } + } + /** +``` +###### \java\seedu\simply\logic\commands\AddCommand.java +``` java + * selects the added task in the todolist + * @param toAdd the added task + */ + private void selectTodo(Task toAdd) { + char category = 'T'; + int index = model.getFilteredTodoList().indexOf(toAdd); + EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); + } + /** +``` +###### \java\seedu\simply\logic\commands\AddCommand.java +``` java + * selects the added task in the deadline list + * @param toAdd the added task + */ + private void selectDeadline(Task toAdd) { + char category = 'D'; + int index = model.getFilteredDeadlineList().indexOf(toAdd); + EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); + } + /** +``` +###### \java\seedu\simply\logic\commands\AddCommand.java +``` java + * selects the added task in the events list + * @param toAdd the added task + */ + private void selectEvent(Task toAdd) { + char category = 'E'; + int index = model.getFilteredEventList().indexOf(toAdd); + EventsCenter.getInstance().post(new JumpToListRequestEvent(index, category)); } ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java */ public class Parser { @@ -227,44 +268,43 @@ public class Parser { final String arguments = matcher.group("arguments"); switch (commandWord) { - case AddCommand.COMMAND_WORD: { + case AddCommand.COMMAND_WORD : return prepareAdd(userInput, arguments); - } - case SelectCommand.COMMAND_WORD: + case SelectCommand.COMMAND_WORD : return prepareSelect(arguments); - case DeleteCommand.COMMAND_WORD: + case DeleteCommand.COMMAND_WORD : return prepareDelete(arguments); - case EditCommand.COMMAND_WORD: + case EditCommand.COMMAND_WORD : return prepareEdit(arguments); - case DoneCommand.COMMAND_WORD: + case DoneCommand.COMMAND_WORD : return prepareComplete(arguments); - case SpecifyStorageCommand.COMMAND_WORD: + case SpecifyStorageCommand.COMMAND_WORD : return prepareSpecifyStorage(arguments); - case UndoCommand.COMMAND_WORD: + case UndoCommand.COMMAND_WORD : return prepareUndo(arguments); - case RedoCommand.COMMAND_WORD: + case RedoCommand.COMMAND_WORD : return prepareRedo(arguments); - case ClearCommand.COMMAND_WORD: + case ClearCommand.COMMAND_WORD : return new ClearCommand(); - case FindCommand.COMMAND_WORD: + case FindCommand.COMMAND_WORD : return prepareFind(arguments); - case ListCommand.COMMAND_WORD: + case ListCommand.COMMAND_WORD : return new ListCommand(arguments); - case ExitCommand.COMMAND_WORD: + case ExitCommand.COMMAND_WORD : return new ExitCommand(); - case HelpCommand.COMMAND_WORD: + case HelpCommand.COMMAND_WORD : return new HelpCommand(); default: @@ -273,7 +313,7 @@ public class Parser { } /** ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java * Chooses which kind of task to create and prepare * @param userInput takes in the user input from the command line interface @@ -281,26 +321,20 @@ public class Parser { * @return the prepared command */ private Command prepareAdd(String userInput, final String arguments) { - if (ARGS_FORMAT_EVENT_DATA.matcher(userInput).find()) + if (ARGS_FORMAT_EVENT_DATA.matcher(userInput).find()) { return prepareEvent(arguments); - else if (ARGS_FORMAT_DEADLINE_DATA.matcher(userInput).find()) + } else if (ARGS_FORMAT_DEADLINE_DATA.matcher(userInput).find()) { return prepareDeadline(arguments); - else if (ARGS_FORMAT_ADD_TAGS.matcher(userInput).find()) + } else if (ARGS_FORMAT_ADD_TAGS.matcher(userInput).find()) { return prepareAddTags(arguments); - else if (ARGS_FORMAT_TODO_DATA.matcher(userInput).find()) + } else if (ARGS_FORMAT_TODO_DATA.matcher(userInput).find()) { return prepareToDo(arguments); - else + } else { return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); + } } - - /** - * Parses arguments in the context of the add tag command. - * - * @param args full command args string - * @return the prepared command - */ ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java * @param args full command args string * @return the prepared command @@ -324,7 +358,7 @@ public class Parser { /** * Parses arguments in the context of the add task command. ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java * @param args full command args string * @return the prepared command @@ -351,7 +385,7 @@ public class Parser { /** * Parses arguments in the context of the add task command. ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java * @param args full command args string * @return the prepared command @@ -393,16 +427,11 @@ public class Parser { final Collection tagStrings = Arrays.asList(tagArguments.replaceFirst(" #", "").split(" #")); return new HashSet<>(tagStrings); } - - /** - * Parses arguments in the context of the delete task command. - * - * @param args full command args string - * @return the prepared command - */ + ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java + * Parses arguments in the context of the select task command. * @param args full command args string * @return the prepared command */ @@ -445,15 +474,9 @@ public class Parser { return Optional.of(Integer.parseInt(index)); } - - /** - * Parses arguments in the context of the find task command. - * - * @param args full command args string - * @return the prepared command - */ + ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public synchronized void overdueTask() { @@ -461,14 +484,14 @@ public class Parser { public void run() { taskBook.overdueTask(); indicateTaskOverdueChanged(); - indicateAddressBookChanged(); + indicateTaskBookChanged(); }; }; scheduler.scheduleAtFixedRate(overdue, 0, 1, TimeUnit.SECONDS); } ``` -###### \java\seedu\address\model\task\Date.java +###### \java\seedu\simply\model\task\Date.java ``` java * Represents a Task date in Simply. * Guarantees: immutable; is valid as declared in {@link #isValidDate(String)} @@ -476,31 +499,31 @@ public class Parser { public class Date implements Comparable { public static final String MESSAGE_DATE_CONSTRAINTS = "Dates should be entered in the format DDMMYY, DD.MM.YY, DD/MM/YY, DD-MM-YY"; - public static final String DATE_VALIDATION_REGEX = "([3][01][1][012]\\d{2})|([3][01][0]\\d{3})|([012]\\d{1}[1][012]\\d{2})|"+ //6digits - "([012]\\d{1}[0]\\d{3})|"+ - "([3][01]-[1][012]-\\d{2})|([3][01]-[0]\\d{1}-\\d{2})|([12]\\d{1}-[1][012]-\\d{2})|"+ //2d-2d-2d - "([12]\\d{1}-[0]\\d{1}-\\d{2})|([0]\\d{1}-[1][012]-\\d{2})|([0]\\d{1}-[0]\\d{1}-\\d{2})|"+ - "([3][01]\\.[1][012]\\.\\d{2})|([3][01]\\.[0]\\d{1}\\.\\d{2})|([12]\\d{1}\\.[1][012]\\.\\d{2})|"+ //2d.2d.2d - "([12]\\d{1}\\.[0]\\d{1}\\.\\d{2})|([0]\\d{1}\\.[1][012]\\.\\d{2})|([0]\\d{1}\\.[0]\\d{1}\\.\\d{2})|"+ - "([3][01]/[1][012]/\\d{2})|([3][01]/[0]\\d{1}/\\d{2})|([12]\\d{1}/[1][012]/\\d{2})|"+ //2d/2d/2d - "([12]\\d{1}/[0]\\d{1}/\\d{2})|([0]\\d{1}/[1][012]/\\d{2})|([0]\\d{1}/[0]\\d{1}/\\d{2})|"+ - "(no date)"; + public static final String DATE_VALIDATION_REGEX = "([3][01][1][012]\\d{2})|([3][01][0]\\d{3})|([012]\\d{1}[1][012]\\d{2})|" + + "([012]\\d{1}[0]\\d{3})|" //DDMMYY + + "([3][01]-[1][012]-\\d{2})|([3][01]-[0]\\d{1}-\\d{2})|([12]\\d{1}-[1][012]-\\d{2})|" //DD-MM-YY + + "([12]\\d{1}-[0]\\d{1}-\\d{2})|([0]\\d{1}-[1][012]-\\d{2})|([0]\\d{1}-[0]\\d{1}-\\d{2})|" + + "([3][01]\\.[1][012]\\.\\d{2})|([3][01]\\.[0]\\d{1}\\.\\d{2})|([12]\\d{1}\\.[1][012]\\.\\d{2})|" //DD.MM.YY + + "([12]\\d{1}\\.[0]\\d{1}\\.\\d{2})|([0]\\d{1}\\.[1][012]\\.\\d{2})|([0]\\d{1}\\.[0]\\d{1}\\.\\d{2})|" + + "([3][01]/[1][012]/\\d{2})|([3][01]/[0]\\d{1}/\\d{2})|([12]\\d{1}/[1][012]/\\d{2})|" //DD/MM/YY + + "([12]\\d{1}/[0]\\d{1}/\\d{2})|([0]\\d{1}/[1][012]/\\d{2})|([0]\\d{1}/[0]\\d{1}/\\d{2})|" + + "(no date)"; public static final String MESSAGE_PAST_DATE = "Cannot enter a date that have already past!"; - + public final String value; private int beforeCurrentDate; /** - * Validates given date. ``` -###### \java\seedu\address\model\task\Date.java +###### \java\seedu\simply\model\task\Date.java ``` java + * Validates given date. * @throws IllegalValueException if given date string is invalid. */ public Date(String date) throws IllegalValueException { - //assert date != null; - if (date == null) + if (date == null) { date = "default"; + } date = date.trim(); if (!isValidDate(date)) { throw new IllegalValueException(MESSAGE_DATE_CONSTRAINTS); @@ -509,10 +532,10 @@ public class Date implements Comparable { beforeCurrentDate = isAfterCurrentDate(date); this.value = date; } + /** ``` -###### \java\seedu\address\model\task\Date.java +###### \java\seedu\simply\model\task\Date.java ``` java - /** * checks if the current date have been past * @param date * @return int value of 1 if date have past 2 if current date 0 if date is in the future @@ -521,43 +544,55 @@ public class Date implements Comparable { if (date.contains("-")) { String[] date_cat = date.split("-"); String date_year = "20" + date_cat[2]; - LocalDate now = LocalDate.now(); LocalDate test = LocalDate.of(Integer.parseInt(date_year), Integer.parseInt(date_cat[1]), Integer.parseInt(date_cat[0])); - if (test.isAfter(now)) - return 1; - else if (test.isEqual(now)) - return 2; - else - return 0; - } - else//accounting for no date + LocalDate now = LocalDate.now(); + return currentDateStatus(now, test); + } else//accounting for no date return 1; } + /** ``` -###### \java\seedu\address\model\task\Date.java +###### \java\seedu\simply\model\task\Date.java ``` java + * @param now current local date + * @param test the date entered by the user + * @return the status of the date with 1 being past and 2 being equal and 0 being in the future + */ + private int currentDateStatus(LocalDate now, LocalDate test) { + if (test.isAfter(now)) { + return 1; + } else if (test.isEqual(now)) { + return 2; + } else { + return 0; + } + } + /** +``` +###### \java\seedu\simply\model\task\Date.java +``` java * standardize the date format to DD-MM-YY * @param date * @return the date format of DD-MM-YY */ private String standardFormatDate(String date) { - if (date.equals("default")) - return local_date(); - else if (date.equals("no date")) - return date; - else if (date.contains(".")) - return date.replaceAll("\\.", "-"); - else if (date.contains("-")) - return date; - else if (date.contains("/")) - return date.replaceAll("/", "-"); - else { - return date.substring(0, 2) + "-" + date.substring(2, 4) + "-" + date.substring(4, 6); - } + if (date.equals("default")) { + return local_date(); + } else if (date.equals("no date")) { + return date; + } else if (date.contains(".")) { + return date.replaceAll("\\.", "-"); + } else if (date.contains("-")) { + return date; + } else if (date.contains("/")) { + return date.replaceAll("/", "-"); + } else { + return date.substring(0, 2) + "-" + date.substring(2, 4) + "-" + date.substring(4, 6); + } } ``` -###### \java\seedu\address\model\task\Date.java +###### \java\seedu\simply\model\task\Date.java ``` java public String local_date(){ LocalDate now = LocalDate.now(); @@ -569,13 +604,13 @@ public class Date implements Comparable { /** * Returns true if a given string is a valid task date. */ - public static boolean isValidDate(String test) { - if (test.matches(DATE_VALIDATION_REGEX) || test.equals("default")) - return true; - else - return false; - } - + public static boolean isValidDate(String test) { + if (test.matches(DATE_VALIDATION_REGEX) || test.equals("default")) { + return true; + } else { + return false; + } + } public int getBeforeCurrentDate() { return beforeCurrentDate; } @@ -598,7 +633,7 @@ public class Date implements Comparable { } ``` -###### \java\seedu\address\model\task\End.java +###### \java\seedu\simply\model\task\End.java ``` java * Represents a task's end time in Simply * Guarantees: immutable; is valid as declared in {@link #isValidEnd(String)} @@ -606,13 +641,13 @@ public class Date implements Comparable { public class End implements Comparable { public static final String MESSAGE_END_CONSTRAINTS = "Task end time can be entered in 24hour or 12hour format."; - public static final String END_VALIDATION_REGEX = "([01]\\d{1}[0-5]\\d{1})|" + - "([2][0-3][0-5]\\d{1})|" + - "([1-9](?:pm|am|PM|AM))|" + - "(1[0-2](?:pm|am|PM|AM))|" + - "([1-9]\\.[0-5]{1}\\d{1}(?:pm|am))|" + - "(1[0-2]\\.[0-5]{1}\\d{1}(?:pm|am))|" + - "(no end)"; + public static final String END_VALIDATION_REGEX = "([01]\\d{1}[0-5]\\d{1})|" + + "([2][0-3][0-5]\\d{1})|" + + "([1-9](?:pm|am|PM|AM))|" + + "(1[0-2](?:pm|am|PM|AM))|" + + "([1-9]\\.[0-5]{1}\\d{1}(?:pm|am))|" + + "(1[0-2]\\.[0-5]{1}\\d{1}(?:pm|am))|" + + "(no end)"; public static final String DEFAULT_END_TIME = "2359"; public final String value; private int pastEndTime =0; @@ -621,75 +656,110 @@ public class End implements Comparable { * * Validates given end time. ``` -###### \java\seedu\address\model\task\End.java +###### \java\seedu\simply\model\task\End.java ``` java - * @throws IllegalValueException if given address string is invalid. + * @throws IllegalValueException if given task string is invalid. */ public End(String end) throws IllegalValueException { - //assert end != null; - if (end == null) - end = "default"; + if (end == null) { + end = "default"; + } if (!isValidEnd(end)) { throw new IllegalValueException(MESSAGE_END_CONSTRAINTS); } - if (end.equals("default")) - this.value = DEFAULT_END_TIME; - else if (end.equals("no end")) - this.value = "no end"; - else { - this.value = changeTo24HourFormat(end); - if (isPastEndTime(value)) { - pastEndTime =1; - } + if (end.equals("default")) { + this.value = DEFAULT_END_TIME; + } else if (end.equals("no end")) { + this.value = "no end"; + } else { + this.value = changeTo24HourFormat(end); + if (isPastEndTime(value)) { + pastEndTime =1; + } } } + /** ``` -###### \java\seedu\address\model\task\End.java +###### \java\seedu\simply\model\task\End.java ``` java + * checks if the end time have past + * @param end the user input end time + * @return true is it has past and false if it has not past + */ public boolean isPastEndTime(String end) { String localTime = new String(""); - String new_min = new String(LocalTime.now().getMinute() + ""); - String new_hr = new String(LocalTime.now().getHour() + ""); - if (new_hr.length() ==1) - new_hr = "0" + new_hr; - if (new_min.length() ==1 ) - new_min = "0" + new_min; + String new_min = formatLocalTimeMinutes(); + String new_hr = formatLocalTimeHours(); localTime = new_hr +""+ new_min; - if (Integer.parseInt(end) - Integer.parseInt(localTime) < 0){ - // System.out.println("end:" + Integer.parseInt(end) + " local:" + Integer.parseInt(localTime)); + if (Integer.parseInt(end) - Integer.parseInt(localTime) < 0) { return true; - } - else + } else { return false; + } } + /** ``` -###### \java\seedu\address\model\task\End.java +###### \java\seedu\simply\model\task\End.java ``` java - private String changeTo24HourFormat(String end) { - if (Character.isDigit(end.charAt(end.length()-1))) - return end; - else if (end.length() == 3) { - if (end.substring(1).equalsIgnoreCase("pm")) - return (Integer.parseInt(end.substring(0,1))+12) + "00"; - else - return "0" + end.substring(0, 1) + "00"; - } - else if (end.length() == 4) { - if (end.substring(2).equalsIgnoreCase("pm")) - return (Integer.parseInt(end.substring(0,2))+12) + "00"; - else - return end.substring(0, 2) + "00"; - } - else { - String[] time_cat = end.split("\\."); - if (time_cat[0].length() ==1) - time_cat[0] = "0" + time_cat[0]; - if (time_cat[1].substring(2).equalsIgnoreCase("pm")) - time_cat[0] = "" + (Integer.parseInt(time_cat[0]) + 12); - return time_cat[0] + time_cat[1].substring(0, 2); + * formatting the local time class hours to the desired format + * @return the formatted hours + */ + private String formatLocalTimeHours() { + String new_hr = new String(LocalTime.now().getHour() + ""); + if (new_hr.length() ==1) { + new_hr = "0" + new_hr; } - - } + return new_hr; + } + /** +``` +###### \java\seedu\simply\model\task\End.java +``` java + * formatting the local time class minutes to the desired format + * @return the formatted minutes + */ + private String formatLocalTimeMinutes() { + String new_min = new String(LocalTime.now().getMinute() + ""); + if (new_min.length() ==1 ) { + new_min = "0" + new_min; + } + return new_min; + } + /** +``` +###### \java\seedu\simply\model\task\End.java +``` java + * changing the end time to 24 hour format for easier sorting and display + * @param end the user input end time + * @return the standardize format of the user end time + */ + private String changeTo24HourFormat(String end) { + if (Character.isDigit(end.charAt(end.length()-1))) { + return end; + } else if (end.length() == 3) { + if (end.substring(1).equalsIgnoreCase("pm")) { + return (Integer.parseInt(end.substring(0,1))+12) + "00"; + } else { + return "0" + end.substring(0, 1) + "00"; + } + } else if (end.length() == 4) { + if (end.substring(2).equalsIgnoreCase("pm")) { + return (Integer.parseInt(end.substring(0,2))+12) + "00"; + } else { + return end.substring(0, 2) + "00"; + } + } else { + String[] time_cat = end.split("\\."); + if (time_cat[0].length() ==1) { + time_cat[0] = "0" + time_cat[0]; + } + if (time_cat[1].substring(2).equalsIgnoreCase("pm")) { + time_cat[0] = "" + (Integer.parseInt(time_cat[0]) + 12); + } + return time_cat[0] + time_cat[1].substring(0, 2); + } + + } public int getPastEndTime() { return pastEndTime; @@ -698,12 +768,13 @@ public class End implements Comparable { /** * Returns true if a given string is a valid task end time. */ - public static boolean isValidEnd(String test) { - if (test.matches(END_VALIDATION_REGEX) || test.equals("default")) - return true; - else - return false; - } + public static boolean isValidEnd(String test) { + if (test.matches(END_VALIDATION_REGEX) || test.equals("default")) { + return true; + } else { + return false; + } + } @Override public String toString() { @@ -723,7 +794,7 @@ public class End implements Comparable { } ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * Represents a task's start time in Simply. * Guarantees: immutable; is valid as declared in {@link #isValidStart(String)} @@ -731,27 +802,28 @@ public class End implements Comparable { public class Start implements Comparable { public static final String MESSAGE_START_CONSTRAINTS = "Task start time can be entered in 24hour or 12hour format."; - public static final String START_VALIDATION_REGEX = "([01]\\d{1}[0-5]\\d{1})|" + - "([2][0-3][0-5]\\d{1})|" + - "([1-9](?:pm|am|PM|AM))|" + - "(1[0-2](?:pm|am|PM|AM))|" + - "([1-9]\\.[0-5]{1}\\d{1}(?:pm|am|AM|PM))|" + - "(1[0-2]\\.[0-5]{1}\\d{1}(?:pm|am|AM|PM))|" + - "(no start)"; + public static final String START_VALIDATION_REGEX = "([01]\\d{1}[0-5]\\d{1})|" + + "([2][0-3][0-5]\\d{1})|" + + "([1-9](?:pm|am|PM|AM))|" + + "(1[0-2](?:pm|am|PM|AM))|" + + "([1-9]\\.[0-5]{1}\\d{1}(?:pm|am|AM|PM))|" + + "(1[0-2]\\.[0-5]{1}\\d{1}(?:pm|am|AM|PM))|" + + "(no start)"; public final String value; /** * Validates given start time. ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * @throws IllegalValueException if given start time string is invalid. */ public Start(String start) throws IllegalValueException { //assert start != null; - if (start == null) - start = "default"; + if (start == null) { + start = "default"; + } start = start.trim(); if (!isValidStart(start)) { throw new IllegalValueException(MESSAGE_START_CONSTRAINTS); @@ -761,127 +833,132 @@ public class Start implements Comparable { } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * Calculates the start time of the task * @param start the start time from the user input in any format * @return standardized format of the start time */ private String calculateStartTimeValue(String start) { - if (start.equals("default")) { - String new_hr = startTimeHour(); - String new_min = startTimeMin(); - return new_hr +""+ new_min; - } - else if (start.equals("no start")) - return "no start"; - else - return changeTo24HourFormat(start); + if (start.equals("default")) { + String new_hr = startTimeHour(); + String new_min = startTimeMin(); + return new_hr +""+ new_min; + } else if (start.equals("no start")) { + return "no start"; + } else { + return changeTo24HourFormat(start); + } } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * calculates the local time minutes * @return the local minutes */ private String startTimeMin() { String new_min = new String(LocalTime.now().getMinute() + ""); - if (new_min.length() ==1 ) + if (new_min.length() ==1 ) { new_min = "0" + new_min; + } return new_min; } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * calculates the local time hour * @return the local hour */ private String startTimeHour() { String new_hr = new String(LocalTime.now().getHour() + ""); - if (new_hr.length() ==1) + if (new_hr.length() ==1) { new_hr = "0" + new_hr; + } return new_hr; } ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java /** * changes the user input to 24 hour format * @param start * @return 24 hr clock */ - private String changeTo24HourFormat(String start) { - if (Character.isDigit(start.charAt(start.length()-1))) - return start; - else if (start.length() == 3) { - return format1DigitStartTime(start); - } - else if (start.length() == 4) { - return format2DigitStartTime(start); - } - else { - return formatGeneralStartTime(start); - } + private String changeTo24HourFormat(String start) { + if (Character.isDigit(start.charAt(start.length()-1))) { + return start; + } else if (start.length() == 3) { + return format1DigitStartTime(start); + } else if (start.length() == 4) { + return format2DigitStartTime(start); + } else { + return formatGeneralStartTime(start); + } } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * formats the general time format of hh.mm to 24 hour format * @param start * @return 24 hour clock format */ private String formatGeneralStartTime(String start) { - String[] time_cat = start.split("\\."); - if (time_cat[0].length() ==1) - time_cat[0] = "0" + time_cat[0]; - if (time_cat[1].substring(2).equalsIgnoreCase("pm")) - time_cat[0] = "" + (Integer.parseInt(time_cat[0]) + 12); - return time_cat[0] + time_cat[1].substring(0, 2); + String[] time_cat = start.split("\\."); + if (time_cat[0].length() ==1) { + time_cat[0] = "0" + time_cat[0]; + } + if (time_cat[1].substring(2).equalsIgnoreCase("pm")) { + time_cat[0] = "" + (Integer.parseInt(time_cat[0]) + 12); + } + return time_cat[0] + time_cat[1].substring(0, 2); } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * formats 2 digit start time to 24 hour clock * @param start * @return 24 hour clock format */ private String format2DigitStartTime(String start) { - if (start.substring(2).equalsIgnoreCase("pm")) - return (Integer.parseInt(start.substring(0,2))+12) + "00"; - else - return start.substring(0, 2) + "00"; + if (start.substring(2).equalsIgnoreCase("pm")) { + return (Integer.parseInt(start.substring(0,2))+12) + "00"; + } else { + return start.substring(0, 2) + "00"; + } } /** ``` -###### \java\seedu\address\model\task\Start.java +###### \java\seedu\simply\model\task\Start.java ``` java * formats 1 digit start time to 24 hour clock * @param start * @return 24 hour clock format */ private String format1DigitStartTime(String start) { - if (start.substring(1).equalsIgnoreCase("pm")) - return (Integer.parseInt(start.substring(0,1))+12) + "00"; - else - return "0" + start.substring(0, 1) + "00"; + if (start.substring(1).equalsIgnoreCase("pm")) { + return (Integer.parseInt(start.substring(0,1))+12) + "00"; + } else { + return "0" + start.substring(0, 1) + "00"; + } } /** * Returns if a given string is a valid task start time. */ - public static boolean isValidStart(String test) { - if (test.matches(START_VALIDATION_REGEX) || test.equals("default")) - return true; - else - return false; - } + public static boolean isValidStart(String test) { + if (test.matches(START_VALIDATION_REGEX) || test.equals("default")) { + return true; + } else { + return false; + } + } @Override public String toString() { @@ -901,7 +978,7 @@ public class Start implements Comparable { } ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java * Represents a Task in the end book. * Guarantees: details are present and not null, field values are validated. @@ -920,7 +997,7 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { /** ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java * Every field must be present and not null. */ @@ -933,17 +1010,18 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { this.taskCategory = taskCategory; this.isCompleted = isCompleted; this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list - if (isOverdue(this.getDate(), this.getEnd())==1) - this.overdue =1; - else if (isOverdue(this.getDate(), this.getEnd()) ==2) - this.overdue =2; - else - this.overdue =0; + if (isOverdue(this.getDate(), this.getEnd())==1) { + this.overdue =1; + } else if (isOverdue(this.getDate(), this.getEnd()) ==2) { + this.overdue =2; + } else { + this.overdue =0; + } } /** ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java * Copy constructor for deadline. */ @@ -955,17 +1033,18 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { this.taskCategory = taskCategory; this.isCompleted = isCompleted; this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list - if (isOverdue(this.getDate(), this.getEnd())==1) - this.overdue =1; - else if (isOverdue(this.getDate(), this.getEnd()) ==2) - this.overdue =2; - else - this.overdue =0; + if (isOverdue(this.getDate(), this.getEnd())==1) { + this.overdue =1; + } else if (isOverdue(this.getDate(), this.getEnd()) ==2) { + this.overdue =2; + } else { + this.overdue =0; + } } /** ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java * Copy constructor for todo. */ @@ -982,7 +1061,7 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { /** ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java * Copy constructor. */ @@ -990,19 +1069,16 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { this(source.getName(), source.getDate(), source.getStart(), source.getEnd(), source.getTaskCategory(), source.getOverdue(),source.getIsCompleted(), source.getTags()); } ``` -###### \java\seedu\address\model\task\Task.java +###### \java\seedu\simply\model\task\Task.java ``` java public int isOverdue(Date checkDate, End checkEnd) { if (checkDate.isAfterCurrentDate(checkDate.toString()) == 0){ return 1; - } - else if ((checkDate.isAfterCurrentDate(checkDate.toString()) ==2) && (checkEnd.isPastEndTime(checkEnd.toString()))){ + } else if ((checkDate.isAfterCurrentDate(checkDate.toString()) ==2) && (checkEnd.isPastEndTime(checkEnd.toString()))){ return 1; - } - else if ((checkDate.isAfterCurrentDate(checkDate.toString()) ==2) && (!checkEnd.isPastEndTime(checkEnd.toString()))){ + } else if ((checkDate.isAfterCurrentDate(checkDate.toString()) ==2) && (!checkEnd.isPastEndTime(checkEnd.toString()))){ return 2; - } - else { + } else { return 0; } } @@ -1106,8 +1182,12 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { */ ``` -###### \java\seedu\address\model\task\UniqueTaskList.java +###### \java\seedu\simply\model\task\UniqueTaskList.java ``` java + * marks the task as overdue + * @param key the selected task + * @return status of the task with 1 being overdue 2 being today and 0 being the default + */ public int markOverdue(ReadOnlyTask key) { assert key != null; int overdueIndex = internalList.indexOf(key); @@ -1115,19 +1195,17 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { if (overduedTask.isOverdue(overduedTask.getDate(), overduedTask.getEnd()) == 1) { overduedTask.setOverdue(1); return overduedTask.getOverdue(); - } - else if (overduedTask.isOverdue(overduedTask.getDate(), overduedTask.getEnd()) == 2) { + } else if (overduedTask.isOverdue(overduedTask.getDate(), overduedTask.getEnd()) == 2) { overduedTask.setOverdue(2); return overduedTask.getOverdue(); - } - else { + } else { overduedTask.setOverdue(0); return overduedTask.getOverdue(); } } ``` -###### \java\seedu\address\model\task\UniqueTaskList.java +###### \java\seedu\simply\model\task\UniqueTaskList.java ``` java public int getTaskIndex(ReadOnlyTask key) { assert key != null; @@ -1135,99 +1213,9 @@ public class Task implements ReadOnlyTask, ModifyTask, Comparable { } ``` -###### \java\seedu\address\model\TaskBook.java +###### \java\seedu\simply\model\TaskBook.java ``` java - * Wraps all data at the address-book level - * Duplicates are not allowed (by .equals comparison) - */ -public class TaskBook implements ReadOnlyTaskBook { - - private final UniqueTaskList events; - private UniqueTaskList deadlines; - private UniqueTaskList todo; - private final UniqueTagList tags; - - { - events = new UniqueTaskList(); - deadlines = new UniqueTaskList(); - todo = new UniqueTaskList(); - tags = new UniqueTagList(); - } - - public TaskBook() {} - - /** - * Tasks and Tags are copied into this addressbook - */ - public TaskBook(ReadOnlyTaskBook toBeCopied) { - this(toBeCopied.getUniqueEventList(), toBeCopied.getUniqueDeadlineList(), toBeCopied.getUniqueTodoList(), toBeCopied.getUniqueTagList()); - } - - /** - * Tasks and Tags are copied into this addressbook - */ - public TaskBook(UniqueTaskList events, UniqueTaskList deadlines, UniqueTaskList todo, UniqueTagList tags) { - resetData(events.getInternalList(), deadlines.getInternalList(), todo.getInternalList(), tags.getInternalList()); - } - - public static ReadOnlyTaskBook getEmptyAddressBook() { - return new TaskBook(); - } - - //// list overwrite operations - - public ObservableList getEvents() { - return events.getInternalList(); - } - - public ObservableList getDeadlines() { - return deadlines.getInternalList(); - } - - public ObservableList getTodo() { - return todo.getInternalList(); - } - - //public ObservableList getCompleted() { - // return completed.getInternalList(); - //} - - public void setEvents(List events) { - this.events.getInternalList().setAll(events); - } - - public void setDeadlines(List deadlines) { - this.deadlines.getInternalList().setAll(deadlines); - } - - public void setTodo(List todo) { - this.todo.getInternalList().setAll(todo); - } - - //public void setCompleted(List completed) { - // this.completed.getInternalList().setAll(completed); - //} - - public void setTags(Collection tags) { - this.tags.getInternalList().setAll(tags); - } - - public void resetData(Collection newEvents, Collection newDeadlines, - Collection newTodo, Collection newTags) { - setEvents(newEvents.stream().map(Task::new).collect(Collectors.toList())); - setDeadlines(newDeadlines.stream().map(Task::new).collect(Collectors.toList())); - setTodo(newTodo.stream().map(Task::new).collect(Collectors.toList())); - setTags(newTags); - } - - public void resetData(ReadOnlyTaskBook newData) { - resetData(newData.getEventList(), newData.getDeadlineList(), newData.getTodoList(), newData.getTagList()); - } - - //// task-level operations - - /** - * Adds a task to the address book. + * Adds a task to the task book. * Also checks the new task's tags and updates {@link #tags} with any new tags found, * and updates the Tag objects in the task to point to those in {@link #tags}. * @@ -1235,12 +1223,13 @@ public class TaskBook implements ReadOnlyTaskBook { */ public void addTask(Task t) throws UniqueTaskList.DuplicateTaskException { syncTagsWithMasterList(t); - if (t.getTaskCategory() == 1) + if (t.getTaskCategory() == 1) { events.add(t); - else if (t.getTaskCategory() == 2) + } else if (t.getTaskCategory() == 2) { deadlines.add(t); - else + } else { todo.add(t); + } } /** @@ -1266,3 +1255,30 @@ public class TaskBook implements ReadOnlyTaskBook { task.setTags(new UniqueTagList(commonTagReferences)); } ``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public boolean checkTask(ReadOnlyTask toCheck) { + int taskCategory = toCheck.getTaskCategory(); + if(taskCategory == 1){ + return events.contains(toCheck); + } else if(taskCategory == 2){ + return deadlines.contains(toCheck); + } else if(taskCategory == 3){ + return todo.contains(toCheck); + } + return false; + } + +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public void overdueTask() { + for (Task task: events) { + events.markOverdue(task); + } + for (Task task: deadlines) { + deadlines.markOverdue(task); + } + } + +``` diff --git a/collated/main/A0139430L.md b/collated/main/A0139430L.md new file mode 100644 index 000000000000..0ad9187b3d75 --- /dev/null +++ b/collated/main/A0139430L.md @@ -0,0 +1,993 @@ +# A0139430L +###### \java\seedu\simply\logic\commands\DeleteCommand.java +``` java + public DeleteCommand(ArrayList targetIndexes) throws IllegalValueException { + pass = targetIndexes; + extractToEachList(targetIndexes); + sortAndReverse(targetIndexesE); + sortAndReverse(targetIndexesD); + sortAndReverse(targetIndexesT); + } + + private void extractToEachList(ArrayList targetIndexes) throws IllegalValueException { + for(int i= 0; i < targetIndexes.size(); i++){ + String temp = targetIndexes.get(i); + String stringIdx = temp.substring(1); + Integer intIdx = Integer.valueOf(stringIdx); + if (temp.charAt(0)=='E') { + targetIndexesE.add(intIdx); + } + else if (temp.charAt(0)=='D') { + targetIndexesD.add(intIdx); + } + else if (temp.charAt(0)=='T') { + targetIndexesT.add(intIdx); + } + else{ + throw new IllegalValueException(MESSAGE_CATEGORY_CONSTRAINTS); + } + } + } + +``` +###### \java\seedu\simply\logic\commands\DeleteCommand.java +``` java + @Override + public CommandResult execute() { + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + UnmodifiableObservableList lastShownDeadlineList = model.getFilteredDeadlineList(); + UnmodifiableObservableList lastShownTodoList = model.getFilteredTodoList(); + ArrayList tasksToDeleteList = new ArrayList(); + + if (targetIndexesE.size()>0) { + for (int i=0; i0){ + for (int i=0; i0){ + for (int i=0; i list) { + Collections.sort(list); + Collections.reverse(list); + } + +} +``` +###### \java\seedu\simply\logic\commands\EditCommand.java +``` java +public class EditCommand extends Command{ + + public static final String COMMAND_WORD = "edit"; + + public static final String DESCRIPTION_WORD = "des"; + public static final String DATE_WORD = "date"; + public static final String START_WORD = "start"; + public static final String END_WORD = "end"; + public static final String TAG_WORD = "tag"; + public static final String ADD_WORD = "add"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits an existing task in Simply. " + +"Parameters: INDEX
\n" + +"Example: " + COMMAND_WORD + " T1 " + DESCRIPTION_WORD + " beach party\t\t" + +"Example: " + COMMAND_WORD + " D1 " + DATE_WORD + " 120516\n" + +"Example: " + COMMAND_WORD + " E1 " + START_WORD + " 1600\t\t\t" + +"Example: " + COMMAND_WORD + " E2 " + END_WORD + " 2300\n" + +"Example: " + COMMAND_WORD + " D2 " + TAG_WORD + " sentosa"; + + public static final String MESSAGE_EDIT_TASK_SUCCESS = "Edited task: %1$s%2$s Changes: %3$s"; + + public final Integer targetIndex; + public final String editArgs; + public final char category; + + public EditCommand(Integer index, String args, char category) { + this.targetIndex = index; + this.editArgs = args; + this.category = category; + } + + @Override + public CommandResult execute() { + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + UnmodifiableObservableList lastShownDeadlineList = model.getFilteredDeadlineList(); + UnmodifiableObservableList lastShownTodoList = model.getFilteredTodoList(); + if(category == 'E'){ + if (lastShownEventList.size() < targetIndex) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } + + ReadOnlyTask eventToEdit = lastShownEventList.get(targetIndex - 1); + + try { + model.addToUndoStack(); + model.getCommandHistory().add("edit"); + Task edited = model.editTask(eventToEdit, editArgs, category); + lastShownEventList = model.getFilteredEventList(); + EventsCenter.getInstance().post(new JumpToListRequestEvent(lastShownEventList.indexOf(edited), category)); + } catch (TaskNotFoundException ive) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } catch (IllegalValueException ive) { + indicateAttemptToExecuteIncorrectCommand(); + Command command = new IncorrectCommand(ive.getMessage()); + return command.execute(); + } + model.changeTaskCategory(); + return new CommandResult(String.format(MESSAGE_EDIT_TASK_SUCCESS, category, targetIndex, editArgs)); + } + + else if(category == 'D'){ + if (lastShownDeadlineList.size() < targetIndex) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } + + ReadOnlyTask deadlineToEdit = lastShownDeadlineList.get(targetIndex - 1); + + try { + model.addToUndoStack(); + model.getCommandHistory().add("edit"); + Task edited = model.editTask(deadlineToEdit, editArgs, category); + lastShownDeadlineList = model.getFilteredDeadlineList(); + EventsCenter.getInstance().post(new JumpToListRequestEvent(lastShownDeadlineList.indexOf(edited), category)); + } catch (TaskNotFoundException ive) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } catch (IllegalValueException ive) { + indicateAttemptToExecuteIncorrectCommand(); + Command command = new IncorrectCommand(ive.getMessage()); + return command.execute(); + } + model.changeTaskCategory(); + return new CommandResult(String.format(MESSAGE_EDIT_TASK_SUCCESS, category, targetIndex, editArgs)); + } + + else if(category == 'T'){ + if (lastShownTodoList.size() < targetIndex) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } + + ReadOnlyTask todoToEdit = lastShownTodoList.get(targetIndex - 1); + + try { + model.addToUndoStack(); + model.getCommandHistory().add("edit"); + Task edited = model.editTask(todoToEdit, editArgs, category); + lastShownTodoList = model.getFilteredTodoList(); + EventsCenter.getInstance().post(new JumpToListRequestEvent(lastShownTodoList.indexOf(edited), category)); + } catch (TaskNotFoundException ive) { + indicateAttemptToExecuteIncorrectCommand(); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } catch (IllegalValueException ive) { + indicateAttemptToExecuteIncorrectCommand(); + Command command = new IncorrectCommand(ive.getMessage()); + return command.execute(); + } + model.changeTaskCategory(); + return new CommandResult(String.format(MESSAGE_EDIT_TASK_SUCCESS, category, targetIndex, editArgs)); + } + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); + } + +} +``` +###### \java\seedu\simply\logic\commands\FindCommand.java +``` java + @Override + public CommandResult execute() { + model.updateFilteredEventList(keywords); + model.updateFilteredDeadlineList(keywords); + model.updateFilteredTodoList(keywords); + return new CommandResult(getMessageForTaskListShownSummary(model.getFilteredEventList().size(), model.getFilteredDeadlineList().size(), model.getFilteredTodoList().size())); + } + +} +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java + /** + * Parses arguments in the context of the add tag command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareAddTags(String args) { + final Matcher matcher = ARGS_FORMAT_ADD_TAGS.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); + } + args = args.trim(); + char category = args.charAt(0); + Optional index = parseIndex(args.substring(1, args.indexOf(" "))); + args = args.substring(args.indexOf(' ') + 1); + if(!index.isPresent()) { + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE)); + } + Integer pass = index.get(); + args = "add ".concat(args); + + return new EditCommand(pass, args, category); + } + +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java + /** + * Parses arguments in the context of the delete task command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareDelete(String args){ + final Matcher matcher = ARGS_FORMAT_DELETE.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + DeleteCommand.MESSAGE_USAGE)); + } + ArrayList indexes = new ArrayList (Arrays.asList(args.trim().replaceAll(" ", "").split(","))); + if (args.contains("-")) { + char cat = args.charAt(1); + String[] temp = args.replaceAll(" ", "").replaceAll(Character.toString(cat),"").split("-"); + int start; + int end; + //check format of start and end if it is integer + try{ + start = Integer.parseInt(temp[0]); + end = Integer.parseInt(temp[temp.length-1]); + }catch(NumberFormatException nfe){ + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); + } + indexes = rangeToMultiple(start, end , cat); + } + //check if index is an integer 1st number check + Iterator itr = indexes.iterator(); + String tempIndex = itr.next(); + String indexToDelete = tempIndex.substring(1, tempIndex.length()); + Optional index = parseIndex(indexToDelete); + if (!index.isPresent()) { + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); + } + //check if index is an integer the rest + while (itr.hasNext()) { + tempIndex = itr.next(); + indexToDelete = tempIndex.substring(1, tempIndex.length()); + index = parseIndex(indexToDelete); + if(!index.isPresent()){ + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); + } + } + try { + return new DeleteCommand(indexes); + } catch (IllegalValueException ive) { + return new IncorrectCommand(ive.getMessage()); + } + } +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java + private ArrayList rangeToMultiple(int start, int end, char cat){ + //making format of String: T(start), T2, T3.....T(end) + String newArgs = Character.toString(cat).concat(Integer.toString(start)); + for(int i = start+1; i<= end; i++){ + newArgs = newArgs.concat(",".concat(Character.toString(cat))); + newArgs = newArgs.concat(Integer.toString(i)); + } + ArrayList indexes = new ArrayList (Arrays.asList(newArgs.trim().replaceAll(" ", "").split(","))); + return indexes; + } + +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java + /** + * Parses arguments in the context of the Edit command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareEdit(String args) { + final Matcher matcher = ARGS_FORMAT_EDIT.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + EditCommand.MESSAGE_USAGE)); + } + /*final Collection indexes = Arrays.asList(args.trim().replaceAll(" ", "")); + Iterator itr = indexes.iterator(); + ArrayList pass = new ArrayList(); //by right arraylist is redundant cause 1 value only, leave here first in case next time want use + Optional index = parseIndex(itr.next()); */ + + args = args.trim(); + char category = args.charAt(0); + Optional index = parseIndex(args.substring(1, args.indexOf(" "))); + args = args.substring(args.indexOf(' ') + 1); + + if(!index.isPresent()) { + return new IncorrectCommand( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE)); + } + + Integer pass = index.get(); + return new EditCommand(pass, args, category); + } + +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java + /** + * Parses arguments in the context of the find task command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareFind(String args) { + final Matcher matcher = ARGS_FORMAT_KEYWORDS.matcher(args.trim()); + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + FindCommand.MESSAGE_USAGE)); + } + + // keywords delimited by whitespace + // final String[] keywords = matcher.group("keywords").split("\\s+"); + final String[] keywords = {args.trim()}; + final Set keywordSet = new HashSet<>(Arrays.asList(keywords)); + return new FindCommand(keywordSet); + } + +} +``` +###### \java\seedu\simply\model\ModelManager.java +``` java + @Override + public synchronized void deleteTask(ReadOnlyTask target) { + taskBook.removeTask(target); + indicateTaskBookChanged(); + } + +``` +###### \java\seedu\simply\model\ModelManager.java +``` java + @Override + public synchronized boolean checkTask(ReadOnlyTask target) { + return taskBook.checkTask(target); + } + + @Override + public synchronized Task editTask(ReadOnlyTask target, String args, char category) throws TaskNotFoundException, IllegalValueException { + Task temp = taskBook.changeTask(target, args, category); + updateFilteredListToShowAllUncompleted(); + indicateTaskBookChanged(); + return temp; + } + + @Override + public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskException { + taskBook.addTask(task); + updateFilteredListToShowAllUncompleted(); + indicateTaskBookChanged(); + } + +``` +###### \java\seedu\simply\model\ModelManager.java +``` java + @Override + public synchronized void changeTaskCategory() { + try { + taskBook.changeTaskCategory(); + } catch (DuplicateTaskException | TaskNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + indicateTaskBookChanged(); + } + + //=========== Filtered Task List Accessors =============================================================== + + @Override + public UnmodifiableObservableList getFilteredEventList() { + return new UnmodifiableObservableList<>(filteredEvents); + } + + public UnmodifiableObservableList getFilteredDeadlineList() { + return new UnmodifiableObservableList<>(filteredDeadlines); + } + + public UnmodifiableObservableList getFilteredTodoList() { + return new UnmodifiableObservableList<>(filteredTodos); + } + + @Override + public void updateFilteredListToShowAll() { + filteredEvents.setPredicate(null); + filteredDeadlines.setPredicate(null); + filteredTodos.setPredicate(null); + } + +``` +###### \java\seedu\simply\model\ModelManager.java +``` java + @Override + public boolean run(ReadOnlyTask Task) { + + return anyKeyWords.stream() + .filter(keyword -> (StringUtil.containsIgnoreCase(Task.getName().taskDetails.toLowerCase(), keyword) + || StringUtil.containsIgnoreCase(Task.getDate().value, keyword) + || StringUtil.containsIgnoreCase(Task.getStart().value, keyword) + || StringUtil.containsIgnoreCase(Task.getEnd().value, keyword) + || StringUtil.containsIgnoreCase(Task.getTags().toString(), keyword)) + && Task.getIsCompleted() == false) + .findAny() + .isPresent(); + } + + @Override + public String toString() { + return "name=" + String.join(", ", anyKeyWords); + } + } + + +} +``` +###### \java\seedu\simply\model\task\Date.java +``` java + @Override + public int compareTo(Date o) { + if(this.toString().compareTo("no date")==0 & o.toString().compareTo("no date")==0) { + return 0; + } else if(this.toString().compareTo("no date")==0) { + return -1; + } else if(o.toString().compareTo("no date")==0) { + return 1; + } + + String[] temp = this.value.split("-"); + String[] temp2 = o.toString().split("-"); + + String date = temp[2].concat(temp[1]).concat(temp[0]); + String date2 = temp2[2].concat(temp2[1]).concat(temp2[0]); + + return date.compareTo(date2); + } + +} +``` +###### \java\seedu\simply\model\task\End.java +``` java + @Override + public int compareTo(End o) { + if(this.value.compareTo("no end") == 0 & o.toString().compareTo("no end") == 0) { + return 0; + } else if(this.value.compareTo("no end") == 0 ) { + return -1; + } else if(o.toString().compareTo("no end") == 0 ) { + return 1; + } + return this.value.compareTo(o.toString()); + } + +} +``` +###### \java\seedu\simply\model\task\Start.java +``` java + @Override + public int compareTo(Start o) { + if(this.value.compareTo("no start") == 0 & o.toString().compareTo("no start") == 0) { + return 0; + } else if(this.value.compareTo("no start") == 0) { + return -1; + } else if(o.toString().compareTo("no start") == 0) { + return 1; + } + return this.value.compareTo(o.toString()); + } + +} +``` +###### \java\seedu\simply\model\task\Task.java +``` java + public boolean setTags(String specific_tag, String replacement) throws IllegalValueException{ + Tag tempTag = new Tag(specific_tag); + Iterator itr = tags.iterator(); + while(itr.hasNext()){ + Tag temp = itr.next(); + if(temp.equals(tempTag)){ + temp.setTagName(replacement); + return true; + } + } + return false; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof ReadOnlyTask // instanceof handles nulls + && this.isSameStateAs((ReadOnlyTask) other)); + } + + @Override + public int hashCode() { + // use this method for custom fields hashing instead of implementing your own + return Objects.hash(name, date, start, end);//, tags); + } + + @Override + public String toString() { + return getAsText(); + } + +``` +###### \java\seedu\simply\model\task\Task.java +``` java + @Override + public int compareTo(Task other) { + if(this.isCompleted==true & other.isCompleted == false) + return 1; + else if(this.isCompleted==false & other.isCompleted == true) + return -1; + + if(this.date.compareTo(other.date)==0){ + return compareTime(other); + } + + return this.date.compareTo(other.date); + } + + private int compareTime(Task other) { + if (this.start.compareTo(other.start)==0) + return this.end.compareTo(other.end); + else + return this.start.compareTo(other.start); + } + + +} +``` +###### \java\seedu\simply\model\task\UniqueTaskList.java +``` java + public boolean contains(ReadOnlyTask toCheck) { + if (toCheck.getTaskCategory()==3) { + return findUncompletedDuplicate(toCheck); + } + else + return internalList.contains(toCheck); + } + private boolean findUncompletedDuplicate(ReadOnlyTask toCheck) { + for (int i =0; i getInternalList() { + return internalList; + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof UniqueTaskList // instanceof handles nulls + && this.internalList.equals( + ((UniqueTaskList) other).internalList)); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } + + /** +``` +###### \java\seedu\simply\model\task\UniqueTaskList.java +``` java + public Task edit(ReadOnlyTask key, String args) throws IllegalValueException { + // TODO Auto-generated method stub + String keyword = args.substring(0, args.indexOf(' ')); + args = args.substring(args.indexOf(' ') + 1); + + int editIndex = internalList.indexOf(key); + Task toEdit = new Task(internalList.get(editIndex)); + if (keyword.equals(EditCommand.DESCRIPTION_WORD)) { + return editDescription(args, editIndex, toEdit); + } else if (keyword.equals(EditCommand.DATE_WORD)) { + return editDate(args, editIndex, toEdit); + } else if (keyword.equals(EditCommand.START_WORD)) { + return editStart(args, editIndex, toEdit); + } else if (keyword.equals(EditCommand.END_WORD)) { + return editEnd(args, editIndex, toEdit); + } else if (keyword.equals(EditCommand.TAG_WORD)) { + return editTag(args, editIndex, toEdit); + } else if (keyword.equals(EditCommand.ADD_WORD)) { + return addTag(args, editIndex, toEdit); + } + else { + return null; + } + } + private Task addTag(String args, int editIndex, Task toEdit) throws IllegalValueException { + String[] newTag = args.replaceAll(" ", "").replaceFirst("#", "").split("#"); + final Set tagSet = new HashSet<>(); + for (int i = 0; i < newTag.length; i++) { + tagSet.add(new Tag(newTag[i])); + } + UniqueTagList addTagList = new UniqueTagList(tagSet); + toEdit.addTags(addTagList); + internalList.set(editIndex, toEdit); + return toEdit; + } + private Task editTag(String args, int editIndex, Task toEdit) throws IllegalValueException, DuplicateTagException { + if (args.contains(">")){ + String[] beforeAndAfter = args.replaceAll(" ","").split(">"); + toEdit.setTags(beforeAndAfter[0], beforeAndAfter[beforeAndAfter.length-1]); + } + else { + toEdit.setTags(new UniqueTagList(new Tag(args)));; + } + + internalList.set(editIndex, toEdit); + return toEdit; + } + private Task editEnd(String args, int editIndex, Task toEdit) throws IllegalValueException { + End newEnd = new End(args); + if (this.isNotValidTime(toEdit.getStart().toString(), newEnd.toString())) { + throw new IllegalValueException(AddCommand.END_TIME_BEFORE_START_TIME_MESSAGE); + } + if (args.compareTo("no end") == 0 & toEdit.getTaskCategory()!=3) { //not todo default end time 2359 + toEdit.setEnd(new End("2359")); + } + else if (toEdit.getTaskCategory()==3 & args.compareTo("no end") != 0){ //todo to Deadline + toEdit.setDate(new Date(this.getCurrentDate())); + toEdit.setStart(new Start("no start")); + toEdit.setEnd(newEnd); + toEdit.setTaskCategory(2); + } + else + toEdit.setEnd(newEnd); + internalList.set(editIndex, toEdit); + FXCollections.sort(internalList); + return toEdit; + } + private Task editStart(String args, int editIndex, Task toEdit) throws IllegalValueException { + Start newStart = new Start(args); + if (this.isNotValidTime(newStart.toString(), toEdit.getEnd().toString())) { + throw new IllegalValueException(AddCommand.START_TIME_BEFORE_END_TIME_MESSAGE); + } + else if (args.compareTo("no start") == 0 & toEdit.getTaskCategory()==1) { //event to deadline + toEdit.setStart(newStart); + toEdit.setTaskCategory(2); + } + else if (toEdit.getTaskCategory()==2) { //deadline to event + toEdit.setStart(newStart); + toEdit.setTaskCategory(1); + } + else if (toEdit.getTaskCategory()==3) { //todo to Event + toEdit.setDate(new Date(this.getCurrentDate())); + toEdit.setStart(newStart); + toEdit.setEnd(new End("2359")); + toEdit.setTaskCategory(1); + } + else + toEdit.setStart(newStart); + internalList.set(editIndex, toEdit); + FXCollections.sort(internalList); + return toEdit; + } + private boolean isNotValidTime(String start, String end) { + if (start.compareTo("no start")==0 || end.compareTo("no end")==0) + return false; + if (start.compareTo(end) >= 0) + return true; + return false; + } + private Task editDate(String args, int editIndex, Task toEdit) throws IllegalValueException { + if (args.compareTo("no date") == 0 & toEdit.getTaskCategory()!=3){ // change to Todo + toEdit.setDate(new Date("no date")); + toEdit.setStart(new Start("no start")); + toEdit.setEnd(new End("no end")); + toEdit.setTaskCategory(3); + } + else if (toEdit.getTaskCategory()==3){//todo to deadline + toEdit.setDate(new Date(args)); + toEdit.setEnd(new End("2359")); + toEdit.setTaskCategory(2); + } + else + toEdit.setDate(new Date(args)); + internalList.set(editIndex, toEdit); + FXCollections.sort(internalList); + return toEdit; + } + private Task editDescription(String args, int editIndex, Task toEdit) throws IllegalValueException { + toEdit.setName(new Name(args)); + internalList.set(editIndex, toEdit); + return toEdit; + } + +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public void removeTask(ReadOnlyTask key) { + int taskCategory = key.getTaskCategory(); + if (taskCategory == 1) { + events.remove(key); + } else if (taskCategory == 2) { + deadlines.remove(key); + } else { + todo.remove(key); + } + } +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public Task changeTask(ReadOnlyTask target, String args, char category) throws TaskNotFoundException, IllegalValueException { + // TODO Auto-generated method stub + if(category == 'E'){ + Task temp = events.edit(target, args); + if (temp!=null) { + return temp; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + else if(category == 'D'){ + Task temp = deadlines.edit(target, args); + if (temp!=null) { + return temp; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + else if(category == 'T'){ + Task temp = todo.edit(target, args); + if (temp!=null) { + return temp; + } else { + throw new UniqueTaskList.TaskNotFoundException(); + } + } + return null; + } + +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public void changeTaskCategory() throws TaskNotFoundException, DuplicateTaskException { + for (Task task: events) { + if (task.getTaskCategory()!=1) { + events.remove(task); + changeFromEventToDeadlinesOrTodo(task); + } + } + for (Task task: deadlines) { + if (task.getTaskCategory()!=2) { + deadlines.remove(task); + changeFromDeadlineToEventOrTodo(task); + } + } + for (Task task: todo) { + if (task.getTaskCategory()!=3) { + todo.remove(task); + changeFromTodoToEventOrDeadline(task); + } + } + } + + /** +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + * @param task the selected task + * @throws DuplicateTaskException + */ + private void changeFromTodoToEventOrDeadline(Task task) throws DuplicateTaskException { + if (task.getTaskCategory()==1) { + events.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(events.getTaskIndex(task), 'E')); + } else if (task.getTaskCategory()==2) { + deadlines.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(deadlines.getTaskIndex(task), 'D')); + } + } + + + /** +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + * @param task the selected task + * @throws DuplicateTaskException + */ + private void changeFromDeadlineToEventOrTodo(Task task) throws DuplicateTaskException { + if (task.getTaskCategory()==1) { + events.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(events.getTaskIndex(task), 'E')); + } else if (task.getTaskCategory()==3) { + todo.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(todo.getTaskIndex(task), 'T')); + } + } + + + /** +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + * @param task the selected task + * @throws DuplicateTaskException + */ + private void changeFromEventToDeadlinesOrTodo(Task task) throws DuplicateTaskException { + if (task.getTaskCategory()==2) { + deadlines.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(deadlines.getTaskIndex(task), 'D')); + } else if (task.getTaskCategory()==3) { + todo.add(task); + EventsCenter.getInstance().post(new JumpToListRequestEvent(todo.getTaskIndex(task), 'T')); + } + } + + //// tag-level operations +``` +###### \java\seedu\simply\model\TaskBook.java +``` java + public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { + tags.add(t); + } + + //// util methods + + @Override + public String toString() { + return events.getInternalList().size() + " events, " + tags.getInternalList().size() + " tags"; + } + + public String toStringDeadlines() { + return deadlines.getInternalList().size() + " deadlines, " + tags.getInternalList().size() + " tags"; + } + + public String toStringTodo() { + return todo.getInternalList().size() + " todo, " + tags.getInternalList().size() + " tags"; + } + + @Override + public List getEventList() { + return Collections.unmodifiableList(events.getInternalList()); + } + + public List getDeadlineList() { + return Collections.unmodifiableList(deadlines.getInternalList()); + } + + public List getTodoList() { + return Collections.unmodifiableList(todo.getInternalList()); + } + + @Override + public List getTagList() { + return Collections.unmodifiableList(tags.getInternalList()); + } + + @Override + public UniqueTaskList getUniqueEventList() { + return this.events; + } + + public UniqueTaskList getUniqueDeadlineList() { + return this.deadlines; + } + + public UniqueTaskList getUniqueTodoList() { + return this.todo; + } + + @Override + public UniqueTagList getUniqueTagList() { + return this.tags; + } + + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof TaskBook // instanceof handles nulls + && this.events.equals(((TaskBook) other).events) + && this.tags.equals(((TaskBook) other).tags)); + } + + @Override + public int hashCode() { + // use this method for custom fields hashing instead of implementing your own + return Objects.hash(events, tags); + } + +} +``` diff --git a/collated/main/A0147890U.md b/collated/main/A0147890U.md index 8688061cf0d2..d3d65f4b8d0f 100644 --- a/collated/main/A0147890U.md +++ b/collated/main/A0147890U.md @@ -1,5 +1,5 @@ # A0147890U -###### \java\seedu\address\commons\events\ui\OverdueChangedEvent.java +###### \java\seedu\simply\commons\events\ui\OverdueChangedEvent.java ``` java public class OverdueChangedEvent extends BaseEvent { @@ -10,7 +10,7 @@ public class OverdueChangedEvent extends BaseEvent { } ``` -###### \java\seedu\address\logic\commands\AddCommand.java +###### \java\seedu\simply\logic\commands\AddCommand.java ``` java // checks if redo stack needs to be dumped and dumps if needed. private void dumpRedoStack() { @@ -22,10 +22,11 @@ public class OverdueChangedEvent extends BaseEvent { } ``` -###### \java\seedu\address\logic\commands\ListCommand.java +###### \java\seedu\simply\logic\commands\ListCommand.java ``` java /** - * Lists all tasks in the address book to the user. + * Lists all tasks in the task book to the user. + * Either lists all tasks or lists all completed tasks. */ public class ListCommand extends Command { @@ -59,7 +60,7 @@ public class ListCommand extends Command { } } ``` -###### \java\seedu\address\logic\commands\RedoCommand.java +###### \java\seedu\simply\logic\commands\RedoCommand.java ``` java /** * @@ -87,12 +88,12 @@ public class RedoCommand extends Command { assert model != null; if (numTimes > model.getRedoStack().size()) { - Command command = new IncorrectCommand("There are not so many tasks available to be redone."); + Command command = new IncorrectCommand("There are not so many tasks available to be redo."); return command.execute(); } for (int i = 0; i < numTimes; i++) { - TaskBook currentTaskBook = new TaskBook(model.getAddressBook()); + TaskBook currentTaskBook = new TaskBook(model.getTaskBook()); SaveState saveToResetTo = model.getRedoStack().pop(); @@ -103,7 +104,6 @@ public class RedoCommand extends Command { Config config = saveToResetTo.getSaveStateConfig(); model.setConfig(config); - System.out.println(config.getAddressBookFilePath()); try { ConfigUtil.saveConfig(config, Config.DEFAULT_CONFIG_FILE); } catch (IOException e) { @@ -119,7 +119,7 @@ public class RedoCommand extends Command { } ``` -###### \java\seedu\address\logic\commands\SpecifyStorageCommand.java +###### \java\seedu\simply\logic\commands\SpecifyStorageCommand.java ``` java public class SpecifyStorageCommand extends Command { private static final Logger logger = LogsCenter.getLogger(SpecifyStorageCommand .class); @@ -148,7 +148,7 @@ public class SpecifyStorageCommand extends Command { try { Config config = model.getConfig(); - config.setAddressBookFilePath(folderPath); + config.setTaskBookFilePath(folderPath); ConfigUtil.saveConfig(config, Config.DEFAULT_CONFIG_FILE); } catch (IOException e) { logger.warning("config file could not be saved to"); @@ -160,7 +160,7 @@ public class SpecifyStorageCommand extends Command { } ``` -###### \java\seedu\address\logic\commands\UndoCommand.java +###### \java\seedu\simply\logic\commands\UndoCommand.java ``` java /** * @@ -194,7 +194,7 @@ public class UndoCommand extends Command { } for (int i = 0; i < numTimes; i++) { - TaskBook currentTaskBook = new TaskBook(model.getAddressBook()); + TaskBook currentTaskBook = new TaskBook(model.getTaskBook()); SaveState saveToResetTo = model.getUndoStack().pop(); TaskBook taskToResetTo = saveToResetTo.getSaveStateTaskBook(); @@ -218,8 +218,13 @@ public class UndoCommand extends Command { } } ``` -###### \java\seedu\address\logic\parser\Parser.java +###### \java\seedu\simply\logic\parser\Parser.java ``` java + /* @author Ronald + * Parses arguments in the context of the undo command + * @param number of times to undo, args + * @return the prepared Undo command + */ private Command prepareUndo(String args) { int numTimes; if (args.trim().equals("")) { @@ -233,16 +238,16 @@ public class UndoCommand extends Command { } return new UndoCommand(numTimes); } - + +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java /** * @author Ronald + * Parses arguments in the context of the redo command * @param number of times to redo, args - * @return the prepared command + * @return the prepared Redo command */ - -``` -###### \java\seedu\address\logic\parser\Parser.java -``` java private Command prepareRedo(String args) { int numTimes; if (args.trim().equals("")) { @@ -256,16 +261,16 @@ public class UndoCommand extends Command { } return new RedoCommand(numTimes); } - + +``` +###### \java\seedu\simply\logic\parser\Parser.java +``` java /** * @Ronald + * Parses argumnents in the form of the specify storage command * @param String data storage file path args * @return the prepared SpecifyStorageCommand */ - -``` -###### \java\seedu\address\logic\parser\Parser.java -``` java private Command prepareSpecifyStorage(String args) { args = args.trim().replace("\\", "/"); try { @@ -276,7 +281,7 @@ public class UndoCommand extends Command { if (new File(args.trim()).exists() == false) { return new IncorrectCommand("Please enter a valid file path"); } - args = args + "/addressbook.xml"; + args = args + "/taskbook.xml"; return new SpecifyStorageCommand(args); } @@ -284,54 +289,69 @@ public class UndoCommand extends Command { /** * Parses arguments in the context of the add todo command. ``` -###### \java\seedu\address\MainApp.java +###### \java\seedu\simply\MainApp.java ``` java @Override public void stop() { - logger.info("============================ [ Stopping Address Book ] ============================="); + logger.info("============================ [ Stopping Task Book ] ============================="); ui.stop(); - try { - storage.saveUserPrefs(userPrefs); - } catch (IOException e) { - logger.severe("Failed to save preferences " + StringUtil.getDetails(e)); - } + saveUserPreferences(); + Path sourceFilePath = getSourceFilePath(); Path targetFilePath = getTargetFilePath(); - + assert sourceFilePath != null; assert targetFilePath != null; - + + moveFileToSpecifiedFolder(sourceFilePath, targetFilePath); + + Platform.exit(); + System.exit(0); + } + +``` +###### \java\seedu\simply\MainApp.java +``` java + private void moveFileToSpecifiedFolder(Path sourceFilePath, Path targetFilePath) { try { Files.move(sourceFilePath, targetFilePath, REPLACE_EXISTING); } catch (IOException e) { logger.warning("Failed to move file. Please check if file paths are valid."); } - - Platform.exit(); - System.exit(0); } ``` -###### \java\seedu\address\MainApp.java +###### \java\seedu\simply\MainApp.java +``` java + private void saveUserPreferences() { + try { + storage.saveUserPrefs(userPrefs); + } catch (IOException e) { + logger.severe("Failed to save preferences " + StringUtil.getDetails(e)); + } + } + +``` +###### \java\seedu\simply\MainApp.java ``` java private Path getSourceFilePath() { - String sourceFile = storage.getAddressBookFilePath(); + String sourceFile = storage.getTaskBookFilePath(); Path sourceFilePath = Paths.get(sourceFile); return sourceFilePath; } - + ``` -###### \java\seedu\address\MainApp.java +###### \java\seedu\simply\MainApp.java ``` java private Path getTargetFilePath() { config = initConfig(getApplicationParameter("config")); - Path targetFilePath = Paths.get(config.getAddressBookFilePath()); + Path targetFilePath = Paths.get(config.getTaskBookFilePath()); return targetFilePath; } - + ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public ArrayList getCommandHistory() { @@ -339,7 +359,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public void addToUndoStack() { @@ -351,7 +371,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public Config getConfig() { @@ -359,7 +379,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public void setConfig(Config config) { @@ -367,7 +387,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public Stack getUndoStack() { @@ -375,15 +395,15 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public Stack getRedoStack() { return this.redoStack; } - + ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java /** Raises an event to indicate task overdue status might have changed */ private void indicateTaskOverdueChanged() { @@ -391,7 +411,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public void updateFilteredListToShowAllCompleted() { @@ -416,7 +436,7 @@ public class UndoCommand extends Command { } ``` -###### \java\seedu\address\model\ModelManager.java +###### \java\seedu\simply\model\ModelManager.java ``` java @Override public void updateFilteredListToShowAllUncompleted() { @@ -440,9 +460,9 @@ public class UndoCommand extends Command { }); } - + ``` -###### \java\seedu\address\model\SaveState.java +###### \java\seedu\simply\model\SaveState.java ``` java public class SaveState { private final TaskBook taskBook; @@ -467,7 +487,7 @@ public class SaveState { } } ``` -###### \java\seedu\address\ui\DeadlineCard.java +###### \java\seedu\simply\ui\DeadlineCard.java ``` java public class DeadlineCard extends UiPart { @@ -502,12 +522,12 @@ public class DeadlineCard extends UiPart { @FXML public void initialize() { - String endTime = twelveHourConvertor(deadline.getEnd().value); + String endTime = deadline.getEnd().value; name.setText(deadline.getName().taskDetails); id.setText("D" + displayedIndex + ". "); - date.setText("Date:" + " " + deadline.getDate().value); - end.setText("End time:" + " " + endTime); + date.setText("Date:" + " " + deadline.getDate().value); + end.setText("End time:" + " " + endTime); tags.setText(deadline.tagsString()); registerAsAnEventHandler(this); @@ -565,7 +585,7 @@ public class DeadlineCard extends UiPart { } } ``` -###### \java\seedu\address\ui\EventCard.java +###### \java\seedu\simply\ui\EventCard.java ``` java public class EventCard extends UiPart { @@ -602,14 +622,14 @@ public class EventCard extends UiPart { @FXML public void initialize() { - String startTime = twelveHourConvertor(event.getStart().value); - String endTime = twelveHourConvertor(event.getEnd().value); + String startTime = event.getStart().value; + String endTime = event.getEnd().value; name.setText(event.getName().taskDetails); id.setText("E" + displayedIndex + ". "); - date.setText("Date:" + " " + event.getDate().value); + date.setText("Date:" + " " + event.getDate().value); start.setText("Start time:" + " " + startTime); - end.setText("End time:" + " " + endTime); + end.setText("End time:" + " " + endTime); tags.setText(event.tagsString()); registerAsAnEventHandler(this); @@ -668,13 +688,13 @@ public class EventCard extends UiPart { } } ``` -###### \java\seedu\address\ui\TodoCard.java +###### \java\seedu\simply\ui\TodoCard.java ``` java import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import seedu.address.model.task.ReadOnlyTask; +import seedu.simply.model.task.ReadOnlyTask; public class TodoCard extends UiPart { @@ -725,7 +745,7 @@ public class TodoCard extends UiPart { } } ``` -###### \java\seedu\address\ui\UiPart.java +###### \java\seedu\simply\ui\UiPart.java ``` java /** * changes color of the card border depending on task overdue status @@ -748,38 +768,3 @@ public class TodoCard extends UiPart { } ``` -###### \java\seedu\address\ui\UiPart.java -``` java - /** - * @param 24 hour string value - * @return 12 hour string value - * this method converts 24 hour format to 12 hour format for display in event and deadline cards - */ - protected String twelveHourConvertor(String value) { - int toBeConverted = Integer.parseInt(value); - int firstTwoDigits = toBeConverted / 100; - int twelveHourFormat = 0; - String twelveHourClock; - if (firstTwoDigits == 12) { - twelveHourFormat = toBeConverted; - } - else { - twelveHourFormat = toBeConverted % 1200; - } - - twelveHourClock = Integer.toString(twelveHourFormat); - - twelveHourClock = new StringBuilder(twelveHourClock).insert(twelveHourClock.length() - 2, '.').toString(); - - if (firstTwoDigits == 12) { - twelveHourClock = twelveHourClock + "pm"; - } else if (firstTwoDigits > 12) { - twelveHourClock = twelveHourClock + "pm"; - } else { - twelveHourClock = twelveHourClock + "am"; - } - - return twelveHourClock; - } - -``` diff --git a/collated/main/A0147890Uunused.md b/collated/main/A0147890Uunused.md new file mode 100644 index 000000000000..2679c5733601 --- /dev/null +++ b/collated/main/A0147890Uunused.md @@ -0,0 +1,37 @@ +# A0147890Uunused +###### \java\seedu\simply\ui\UiPart.java +``` java + //unused because find cannot search by 12hr formats + /** + * @param 24 hour string values + * @return 12 hour string value + * this method converts 24 hour format to 12 hour format for display in event and deadline cards + */ + protected String twelveHourConvertor(String value) { + int toBeConverted = Integer.parseInt(value); + int firstTwoDigits = toBeConverted / 100; + int twelveHourFormat = 0; + String twelveHourClock; + if (firstTwoDigits == 12) { + twelveHourFormat = toBeConverted; + } + else { + twelveHourFormat = toBeConverted % 1200; + } + + twelveHourClock = Integer.toString(twelveHourFormat); + + twelveHourClock = new StringBuilder(twelveHourClock).insert(twelveHourClock.length() - 2, '.').toString(); + + if (firstTwoDigits == 12) { + twelveHourClock = twelveHourClock + "pm"; + } else if (firstTwoDigits > 12) { + twelveHourClock = twelveHourClock + "pm"; + } else { + twelveHourClock = twelveHourClock + "am"; + } + + return twelveHourClock; + } + +``` diff --git a/collated/test/A0138993L.md b/collated/test/A0138993L.md index 91e75121aef9..6a11611ce373 100644 --- a/collated/test/A0138993L.md +++ b/collated/test/A0138993L.md @@ -23,7 +23,7 @@ public class DeadlineCardHandle extends GuiHandle { return getTextFromLabel(NAME_FIELD_ID); } - public String getAddress() { + public String getTask() { return getTextFromLabel(END_FIELD_ID); } @@ -33,8 +33,7 @@ public class DeadlineCardHandle extends GuiHandle { public boolean isSamePerson(ReadOnlyTask person){ - return getFullName().equals(person.getName()) && getPhone().equals(person.getDate()) - && getAddress().equals(person.getEnd()); + return getFullName().equals(person.getName().toString()) && getPhone().substring(5).trim().equals(person.getDate().toString()); } @Override @@ -42,7 +41,7 @@ public class DeadlineCardHandle extends GuiHandle { if(obj instanceof DeadlineCardHandle) { DeadlineCardHandle handle = (DeadlineCardHandle) obj; return getFullName().equals(handle.getFullName()) - && getAddress().equals(handle.getAddress()) + && getTask().equals(handle.getTask()) && getPhone().equals(handle.getPhone()); } return super.equals(obj); @@ -50,7 +49,7 @@ public class DeadlineCardHandle extends GuiHandle { @Override public String toString() { - return getFullName() + " " + getAddress(); + return getFullName() + " " + getTask(); } } ``` @@ -191,7 +190,7 @@ public class DeadlineListPanelHandle extends GuiHandle { public DeadlineCardHandle getDeadlineCardHandle(ReadOnlyTask person) { Set nodes = getAllCardNodes(); Optional personCardNode = nodes.stream() - .filter(n -> new TodoCardHandle(guiRobot, primaryStage, n).isSamePerson(person)) + .filter(n -> new DeadlineCardHandle(guiRobot, primaryStage, n).isSamePerson(person)) .findFirst(); if (personCardNode.isPresent()) { return new DeadlineCardHandle(guiRobot, primaryStage, personCardNode.get()); @@ -232,13 +231,13 @@ public class TodoCardHandle extends GuiHandle { } public boolean isSamePerson(ReadOnlyTask person){ - return getFullName().equals(person.getName()); + return getFullName().equals(person.getName().toString()); } @Override public boolean equals(Object obj) { - if(obj instanceof DeadlineCardHandle) { - DeadlineCardHandle handle = (DeadlineCardHandle) obj; + if(obj instanceof TodoCardHandle) { + TodoCardHandle handle = (TodoCardHandle) obj; return getFullName().equals(handle.getFullName()); } return super.equals(obj); @@ -405,10 +404,47 @@ public class TodoListPanelHandle extends GuiHandle { } } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\guitests\SimplyGuiTest.java +``` java + * Asserts the deadline shown in the card is same as the given deadline + */ + public void assertDeadlineMatching(ReadOnlyTask person, DeadlineCardHandle card) { + //System.out.println(person + " " + card + "assertDeadline"); + assertTrue(TestUtil.compareCardAndDeadline(card, person)); + } + + /** +``` +###### \java\guitests\SimplyGuiTest.java +``` java + * Asserts the todo shown in the card is same as the given todo + */ + public void assertTodoMatching(ReadOnlyTask person, TodoCardHandle card) { + //System.out.println(person + " " + card + "assertDeadline"); + assertTrue(TestUtil.compareCardAndTodo(card, person)); + } + + /** + * Asserts the size of the person list is equal to the given number. + */ + protected void assertListSize(int size) { + int numberOfPeople = personListPanel.getNumberOfPeople(); + assertEquals(size, numberOfPeople); + } + + /** + * Asserts the message shown in the Result Display area is same as the given string. + * @param expected + */ + protected void assertResultMessage(String expected) { + assertEquals(expected, resultDisplay.getText()); + } +} +``` +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java private void assertCommandBehavior(String inputCommand, String expectedMessage, - ReadOnlyTaskBook expectedAddressBook, + ReadOnlyTaskBook expectedTaskBook, List expectedShownList, List expectedDeadlineShownList, List expectedTodoShownList) throws Exception { @@ -423,8 +459,8 @@ public class TodoListPanelHandle extends GuiHandle { assertEquals(expectedTodoShownList, model.getFilteredTodoList()); //Confirm the state of data (saved and in-memory) is as expected - assertEquals(expectedAddressBook, model.getAddressBook()); - assertEquals(expectedAddressBook, latestSavedAddressBook); + assertEquals(expectedTaskBook, model.getTaskBook()); + assertEquals(expectedTaskBook, latestSavedTaskBook); } @@ -452,8 +488,8 @@ public class TodoListPanelHandle extends GuiHandle { List threeDeadlines = helper.generateDeadlineList(3); List threeTodos = helper.generateTodoList(3); - TaskBook expectedAB = helper.generateAddressBook(threePersons, threeDeadlines, threeTodos); - expectedAB.resetData(TaskBook.getEmptyAddressBook()); + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.resetData(TaskBook.getEmptyTaskBook()); assertCommandBehavior("clear", ClearCommand.MESSAGE_SUCCESS, expectedAB, expectedAB.getEventList(), expectedAB.getDeadlineList(), expectedAB.getTodoList()); } @@ -481,7 +517,7 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_list_done_events() throws Exception { @@ -493,7 +529,7 @@ public class TodoListPanelHandle extends GuiHandle { List eventList = helper.generateEventList(done); List deadlineList = helper.generateDeadlineList(undone1); List todoList = helper.generateTodoList(undone2); - TaskBook expectedAB = helper.generateAddressBook(eventList, deadlineList, todoList); + TaskBook expectedAB = helper.generateTaskBook(eventList, deadlineList, todoList); expectedAB.completeTask(done); helper.addToModel(model, eventList, deadlineList, todoList); model.markDone(done); @@ -506,7 +542,7 @@ public class TodoListPanelHandle extends GuiHandle { Collections.emptyList()); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_list_done_deadline() throws Exception { @@ -518,7 +554,7 @@ public class TodoListPanelHandle extends GuiHandle { List eventList = helper.generateEventList(undone1); List deadlineList = helper.generateDeadlineList(done); List todoList = helper.generateTodoList(undone2); - TaskBook expectedAB = helper.generateAddressBook(eventList, deadlineList, todoList); + TaskBook expectedAB = helper.generateTaskBook(eventList, deadlineList, todoList); expectedAB.completeTask(done); helper.addToModel(model, eventList, deadlineList, todoList); model.markDone(done); @@ -531,7 +567,7 @@ public class TodoListPanelHandle extends GuiHandle { Collections.emptyList()); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_list_done_todo() throws Exception { @@ -543,7 +579,7 @@ public class TodoListPanelHandle extends GuiHandle { List eventList = helper.generateEventList(undone1); List deadlineList = helper.generateDeadlineList(undone2); List todoList = helper.generateTodoList(done); - TaskBook expectedAB = helper.generateAddressBook(eventList, deadlineList, todoList); + TaskBook expectedAB = helper.generateTaskBook(eventList, deadlineList, todoList); expectedAB.completeTask(done); helper.addToModel(model, eventList, deadlineList, todoList); model.markDone(done); @@ -565,7 +601,7 @@ public class TodoListPanelHandle extends GuiHandle { List eventList = helper.generateEventList(toBeAdded); List deadlineList = helper.generateEventList(toBeAdded1); List todoList = helper.generateEventList(toBeAdded2); - TaskBook expectedAB = helper.generateAddressBook(eventList, deadlineList, todoList); + TaskBook expectedAB = helper.generateTaskBook(eventList, deadlineList, todoList); helper.addToModel(model, eventList, deadlineList, todoList); model.addToUndoStack(); expectedAB.addTask(helper.generateDeadline(1)); @@ -579,14 +615,14 @@ public class TodoListPanelHandle extends GuiHandle { } */ ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectEvent() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.adam(); List eventList = helper.generateEventList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(eventList, Collections.emptyList(), Collections.emptyList()); + TaskBook expectedAB = helper.generateTaskBook(eventList, Collections.emptyList(), Collections.emptyList()); expectedAB.completeTask(toBeMarked); helper.addToModel(model, eventList, Collections.emptyList(), Collections.emptyList()); @@ -599,19 +635,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectEventRange() throws Exception { TestDataHelper helper = new TestDataHelper(); - Task toBeMarked1 = helper.generateEventWithName("lala"); - Task toBeMarked2 = helper.generateEventWithName("lalala"); - Task toBeMarked3 = helper.generateEventWithName("lalalala"); - List eventList = helper.generateEventList(toBeMarked1, toBeMarked2, toBeMarked3); - TaskBook expectedAB = helper.generateAddressBook(eventList, Collections.emptyList(), Collections.emptyList()); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked2); - expectedAB.completeTask(toBeMarked3); + List eventList = helper.generateUncompleteList(3, 'E'); + TaskBook expectedAB = helper.generateTaskBook(eventList, Collections.emptyList(), Collections.emptyList()); + expectedAB = this.completeList(expectedAB, eventList, 0, 1, 2); helper.addToModel(model, eventList, Collections.emptyList(), Collections.emptyList()); assertCommandBehavior("done E1-E3", @@ -623,19 +654,15 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectEventMultiple() throws Exception { TestDataHelper helper = new TestDataHelper(); - Task toBeMarked1 = helper.generateEventWithName("lala"); - Task unmarked = helper.generateEventWithName("lalala"); - Task toBeMarked3 = helper.generateEventWithName("lalalala"); - List eventList = helper.generateEventList(toBeMarked1, unmarked, toBeMarked3); - List unmarkedList = helper.generateEventList(unmarked); - TaskBook expectedAB = helper.generateAddressBook(eventList, Collections.emptyList(), Collections.emptyList()); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked3); + List eventList = helper.generateUncompleteList(3, 'E'); + List unmarkedList = helper.generateEventList(eventList.get(1)); + TaskBook expectedAB = helper.generateTaskBook(eventList, Collections.emptyList(), Collections.emptyList()); + expectedAB = this.completeList(expectedAB, eventList, 0, 2); helper.addToModel(model, eventList, Collections.emptyList(), Collections.emptyList()); assertCommandBehavior("done E1, E3", @@ -647,14 +674,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectDeadline() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.beta(); List deadlineList = helper.generateDeadlineList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), deadlineList, Collections.emptyList()); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), deadlineList, Collections.emptyList()); expectedAB.completeTask(toBeMarked); helper.addToModel(model, Collections.emptyList(), deadlineList, Collections.emptyList()); @@ -667,19 +694,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectDeadlineRange() throws Exception { TestDataHelper helper = new TestDataHelper(); - Task toBeMarked1 = helper.generateDeadlineWithName("la"); - Task toBeMarked2 = helper.generateDeadlineWithName("lala"); - Task toBeMarked3 = helper.generateDeadlineWithName("lalala"); - List deadlineList = helper.generateDeadlineList(toBeMarked1, toBeMarked2, toBeMarked3); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), deadlineList, Collections.emptyList()); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked2); - expectedAB.completeTask(toBeMarked3); + List deadlineList = helper.generateUncompleteList(3, 'D'); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), deadlineList, Collections.emptyList()); + expectedAB = this.completeList(expectedAB, deadlineList, 0, 1, 2); helper.addToModel(model, Collections.emptyList(), deadlineList, Collections.emptyList()); assertCommandBehavior("done D1-D3", @@ -691,19 +713,15 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectDeadlineMultiple() throws Exception { TestDataHelper helper = new TestDataHelper(); - Task toBeMarked1 = helper.generateDeadlineWithName("la"); - Task unmarked = helper.generateDeadlineWithName("lala"); - Task toBeMarked3 = helper.generateDeadlineWithName("lalala"); - List deadlineList = helper.generateDeadlineList(toBeMarked1, unmarked, toBeMarked3); - List unmarkedList = helper.generateDeadlineList(unmarked); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), deadlineList, Collections.emptyList()); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked3); + List deadlineList = helper.generateUncompleteList(3, 'D'); + List unmarkedList = helper.generateDeadlineList(deadlineList.get(2-1)); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), deadlineList, Collections.emptyList()); + expectedAB = this.completeList(expectedAB, deadlineList, 0, 2); helper.addToModel(model, Collections.emptyList(), deadlineList, Collections.emptyList()); assertCommandBehavior("done D1, D3", @@ -715,14 +733,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectTodo() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.charlie(); List todoList = helper.generateTodoList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), Collections.emptyList(), todoList); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), Collections.emptyList(), todoList); expectedAB.completeTask(toBeMarked); helper.addToModel(model, Collections.emptyList(), Collections.emptyList(), todoList); @@ -735,19 +753,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_markCorrectTodoRange() throws Exception { TestDataHelper helper = new TestDataHelper(); - Task toBeMarked1 = helper.generateTodoWithName("la"); - Task toBeMarked2 = helper.generateTodoWithName("lala"); - Task toBeMarked3 = helper.generateTodoWithName("lalala"); - List todoList = helper.generateTodoList(toBeMarked1, toBeMarked2, toBeMarked3); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), Collections.emptyList(), todoList); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked2); - expectedAB.completeTask(toBeMarked3); + List todoList = helper.generateUncompleteList(3, 'T'); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), Collections.emptyList(), todoList); + expectedAB = this.completeList(expectedAB, todoList, 0, 1, 2); helper.addToModel(model, Collections.emptyList(), Collections.emptyList(), todoList); assertCommandBehavior("done T1-T3", @@ -758,20 +771,25 @@ public class TodoListPanelHandle extends GuiHandle { Collections.emptyList()); } + private TaskBook completeList(TaskBook expectedAB, List todoList, Integer... k) throws TaskNotFoundException { + List toBeCompletedIndex = Arrays.asList(k); + for(int i=0; i unmarkedList = helper.generateTodoList(unmarked); - List todoList = helper.generateTodoList(toBeMarked1, unmarked, toBeMarked3); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), Collections.emptyList(), todoList); - expectedAB.completeTask(toBeMarked1); - expectedAB.completeTask(toBeMarked3); + List todoList = helper.generateUncompleteList(3, 'T'); + List unmarkedList = helper.generateTodoList(todoList.get(1)); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), Collections.emptyList(), todoList); + expectedAB = this.completeList(expectedAB, todoList, 0, 2); helper.addToModel(model, Collections.emptyList(), Collections.emptyList(), todoList); assertCommandBehavior("done T1, T3", @@ -783,14 +801,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_noEventIndex() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.adam(); List eventList = helper.generateEventList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(eventList, Collections.emptyList(), Collections.emptyList()); + TaskBook expectedAB = helper.generateTaskBook(eventList, Collections.emptyList(), Collections.emptyList()); expectedAB.completeTask(toBeMarked); helper.addToModel(model, eventList, Collections.emptyList(), Collections.emptyList()); @@ -803,14 +821,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_noDeadlineIndex() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.beta(); List deadlineList = helper.generateDeadlineList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), deadlineList, Collections.emptyList()); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), deadlineList, Collections.emptyList()); expectedAB.completeTask(toBeMarked); helper.addToModel(model, Collections.emptyList(), deadlineList, Collections.emptyList()); @@ -823,14 +841,14 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_done_noTodoIndex() throws Exception { TestDataHelper helper = new TestDataHelper(); Task toBeMarked = helper.charlie(); List todoList = helper.generateTodoList(toBeMarked); - TaskBook expectedAB = helper.generateAddressBook(Collections.emptyList(), Collections.emptyList(), todoList); + TaskBook expectedAB = helper.generateTaskBook(Collections.emptyList(), Collections.emptyList(), todoList); expectedAB.completeTask(toBeMarked); helper.addToModel(model, Collections.emptyList(), Collections.emptyList(), todoList); @@ -879,10 +897,10 @@ public class TodoListPanelHandle extends GuiHandle { model.addTask(p); } - assertCommandBehavior(commandWord , expectedMessage, model.getAddressBook(), eventList, deadlineList, todoList); + assertCommandBehavior(commandWord , expectedMessage, model.getTaskBook(), eventList, deadlineList, todoList); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_selectInvalidArgsFormat_errorMessageShown() throws Exception { @@ -890,35 +908,35 @@ public class TodoListPanelHandle extends GuiHandle { assertIncorrectIndexFormatBehaviorForCommand("select", expectedMessage); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_selectEventIndexNotFound_errorMessageShown() throws Exception { assertIndexNotFoundBehaviorForCommand("select E6"); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_selectDeadlineIndexNotFound_errorMessageShown() throws Exception { assertIndexNotFoundBehaviorForCommand("select D6"); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_selectTodoIndexNotFound_errorMessageShown() throws Exception { assertIndexNotFoundBehaviorForCommand("select T6"); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_select_jumpsToCorrectEvent() throws Exception { TestDataHelper helper = new TestDataHelper(); List threeEvents = helper.generateEventsList(3); - TaskBook expectedAB = helper.generateAddressBook(threeEvents, Collections.emptyList(), Collections.emptyList()); + TaskBook expectedAB = helper.generateTaskBook(threeEvents, Collections.emptyList(), Collections.emptyList()); helper.addToModel(model, threeEvents, Collections.emptyList(), Collections.emptyList()); assertCommandBehavior("select E2", @@ -931,7 +949,7 @@ public class TodoListPanelHandle extends GuiHandle { assertEquals(model.getFilteredEventList().get(1), threeEvents.get(1)); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_select_jumpsToCorrectDeadline() throws Exception { @@ -940,7 +958,7 @@ public class TodoListPanelHandle extends GuiHandle { List threeDeadlines = helper.generateDeadlineList(3); List threeTodos = helper.generateTodoList(3); - TaskBook expectedAB = helper.generateAddressBook(threeEvents, threeDeadlines, threeTodos); + TaskBook expectedAB = helper.generateTaskBook(threeEvents, threeDeadlines, threeTodos); helper.addToModel(model, threeEvents, threeDeadlines, threeTodos); assertCommandBehavior("select D2", @@ -953,7 +971,7 @@ public class TodoListPanelHandle extends GuiHandle { assertEquals(model.getFilteredDeadlineList().get(1), threeDeadlines.get(1)); } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_select_jumpsToCorrectTodo() throws Exception { @@ -962,7 +980,7 @@ public class TodoListPanelHandle extends GuiHandle { List threeDeadlines = helper.generateDeadlineList(3); List threeTodos = helper.generateTodoList(3); - TaskBook expectedAB = helper.generateAddressBook(threeEvents, threeDeadlines, threeTodos); + TaskBook expectedAB = helper.generateTaskBook(threeEvents, threeDeadlines, threeTodos); helper.addToModel(model, threeEvents, threeDeadlines, threeTodos); assertCommandBehavior("select T2", @@ -976,7 +994,7 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_edit_eventToTodo() throws Exception { @@ -999,7 +1017,7 @@ public class TodoListPanelHandle extends GuiHandle { List expectedDeadlinesList = helper.generateDeadlineList(d1, d2); List expectedTodosList = helper.generateTodoList(t1, t2, t3); - TaskBook expectedAB = helper.generateAddressBook(twoEvents, twoDeadlines, twoTodos); + TaskBook expectedAB = helper.generateTaskBook(twoEvents, twoDeadlines, twoTodos); helper.addToModel(model, twoEvents, twoDeadlines, twoTodos); expectedAB.changeTask(p1, "date no date", 'E'); expectedAB.changeTaskCategory(); @@ -1014,7 +1032,7 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_edit_deadlineToTodo() throws Exception { @@ -1037,7 +1055,7 @@ public class TodoListPanelHandle extends GuiHandle { List expectedDeadlinesList = helper.generateDeadlineList(d2); List expectedTodosList = helper.generateTodoList(t1, t2, t3); - TaskBook expectedAB = helper.generateAddressBook(twoEvents, twoDeadlines, twoTodos); + TaskBook expectedAB = helper.generateTaskBook(twoEvents, twoDeadlines, twoTodos); helper.addToModel(model, twoEvents, twoDeadlines, twoTodos); expectedAB.changeTask(d1, "date no date", 'D'); expectedAB.changeTaskCategory(); @@ -1052,7 +1070,7 @@ public class TodoListPanelHandle extends GuiHandle { } ``` -###### \java\seedu\address\logic\LogicManagerTest.java +###### \java\seedu\simply\logic\LogicManagerTest.java ``` java @Test public void execute_find_onlyMatchesPartialWordsInNames() throws Exception { @@ -1082,7 +1100,7 @@ public class TodoListPanelHandle extends GuiHandle { List expectedTodoList = helper.generateTodoList(TTarget1, TTarget2); helper.addToModel(model, fourPersons, fourDeadlines, fourTodos); - TaskBook expectedAB = helper.generateAddressBook(fourPersons, fourDeadlines, fourTodos); + TaskBook expectedAB = helper.generateTaskBook(fourPersons, fourDeadlines, fourTodos); assertCommandBehavior("find KEY", Command.getMessageForTaskListShownSummary(expectedList.size(), expectedDeadlineList.size(), expectedTodoList.size()), @@ -1113,7 +1131,7 @@ public class TodoListPanelHandle extends GuiHandle { List fourEvents = helper.generateEventList(p3, p1, p4, p2); List fourDeadlines = helper.generateDeadlineList(d3, d1, d4, d2); List fourTodos = helper.generateTodoList(t3, t1, t4, t2); - TaskBook expectedAB = helper.generateAddressBook(fourEvents, fourDeadlines, fourTodos); + TaskBook expectedAB = helper.generateTaskBook(fourEvents, fourDeadlines, fourTodos); List expectedList = fourEvents; List expectedDeadlineList = fourDeadlines; List expectedTodoList = fourTodos; @@ -1145,6 +1163,25 @@ public class TodoListPanelHandle extends GuiHandle { UniqueTagList tags = new UniqueTagList(tag1, tag2); return new Task(name, date, start, end, task_cat, overdue, isCompleted, tags); } + public List generateUncompleteList(int num, char cat) throws Exception { + TestDataHelper helper = new TestDataHelper(); + List wantedList = new ArrayList(); //wantedlist could be deadline todo or event + String des = ""; + for(int i =0; i persons, List deadlines, List todos) throws Exception{ - TaskBook addressBook = new TaskBook(); - addToAddressBook(addressBook, persons, deadlines, todos); - return addressBook; + TaskBook generateTaskBook(List persons, List deadlines, List todos) throws Exception{ + TaskBook TaskBook = new TaskBook(); + addToTaskBook(TaskBook, persons, deadlines, todos); + return TaskBook; } /** - * Adds auto-generated Task objects to the given AddressBook - * @param addressBook The AddressBook to which the Persons will be added + * Adds auto-generated Task objects to the given TaskBook + * @param TaskBook The TaskBook to which the Persons will be added */ - void addToAddressBook(TaskBook addressBook, int numGenerated, int numGenerated2, int numGenerated3) throws Exception{ - addToAddressBook(addressBook, generateEventsList(numGenerated), generateDeadlineList(numGenerated2), generateTodoList(numGenerated3)); + void addToTaskBook(TaskBook TaskBook, int numGenerated, int numGenerated2, int numGenerated3) throws Exception{ + addToTaskBook(TaskBook, generateEventsList(numGenerated), generateDeadlineList(numGenerated2), generateTodoList(numGenerated3)); } /** - * Adds the given list of Persons to the given AddressBook + * Adds the given list of Persons to the given TaskBook */ - void addToAddressBook(TaskBook addressBook, List personsToAdd, List deadlinesToAdd, List todoToAdd) throws Exception{ + void addToTaskBook(TaskBook TaskBook, List personsToAdd, List deadlinesToAdd, List todoToAdd) throws Exception{ for(Task p: personsToAdd){ - addressBook.addTask(p); + TaskBook.addTask(p); } for(Task p: deadlinesToAdd){ - addressBook.addTask(p); + TaskBook.addTask(p); } for(Task p: todoToAdd){ - addressBook.addTask(p); + TaskBook.addTask(p); } } @@ -1523,7 +1560,7 @@ public class TodoListPanelHandle extends GuiHandle { } } ``` -###### \java\seedu\address\model\ReadOnlyTaskTest.java +###### \java\seedu\simply\model\ReadOnlyTaskTest.java ``` java public class ReadOnlyTaskTest { @@ -1662,7 +1699,66 @@ public class ReadOnlyTaskTest { } ``` -###### \java\seedu\address\testutil\TaskBuilder.java +###### \java\seedu\simply\testutil\DeadlineBuilder.java +``` java + */ +public class DeadlineBuilder { + + private TestDeadline person; + + public DeadlineBuilder() { + this.person = new TestDeadline(); + } + + public DeadlineBuilder withName(String name) throws IllegalValueException { + this.person.setName(new Name(name)); + return this; + } + + public DeadlineBuilder withTags(String ... tags) throws IllegalValueException { + for (String tag: tags) { + person.getTags().add(new Tag(tag)); + } + return this; + } + + public DeadlineBuilder withEnd(String task) throws IllegalValueException { + this.person.setEnd(new End(task)); + return this; + } + + public DeadlineBuilder withDate(String phone) throws IllegalValueException { + this.person.setDate(new Date(phone)); + return this; + } + + public DeadlineBuilder withStart(String email) throws IllegalValueException { + this.person.setStart(new Start(email)); + return this; + } + + public DeadlineBuilder withTaskCat(int taskCat) throws IllegalValueException { + this.person.setTaskCategory(taskCat); + return this; + } + + public DeadlineBuilder withOverdue(int overdue) throws IllegalValueException { + this.person.setOverdue(overdue); + return this; + } + + public DeadlineBuilder withIsCompleted(boolean isCompleted) throws IllegalValueException { + this.person.setIsCompleted(isCompleted); + return this; + } + + public TestDeadline build() { + return this.person; + } + +} +``` +###### \java\seedu\simply\testutil\TaskBuilder.java ``` java */ public class TaskBuilder { @@ -1685,8 +1781,8 @@ public class TaskBuilder { return this; } - public TaskBuilder withEnd(String address) throws IllegalValueException { - this.person.setEnd(new End(address)); + public TaskBuilder withEnd(String task) throws IllegalValueException { + this.person.setEnd(new End(task)); return this; } @@ -1721,7 +1817,109 @@ public class TaskBuilder { } ``` -###### \java\seedu\address\testutil\TestTask.java +###### \java\seedu\simply\testutil\TestDeadline.java +``` java + * A mutable person object. For testing only. + */ +public class TestDeadline implements ReadOnlyTask { + + private Name name; + private End end; + private Start start; + private Date date; + private int task_cat; + private int overdue; + private UniqueTagList tags; + boolean isCompleted; + + public TestDeadline() { + tags = new UniqueTagList(); + } + + public void setName(Name name) { + this.name = name; + } + + public void setEnd(End task) { + this.end = task; + } + + public void setStart(Start email) { + this.start = email; + } + + public void setDate(Date phone) { + this.date = phone; + } + + public void setTaskCategory(int taskCat) { + this.task_cat = taskCat; + } + + public void setOverdue(int overdue) { + this.overdue = overdue; + } + + public void setIsCompleted(boolean isCompleted) { + this.isCompleted = isCompleted; + } + + @Override + public Name getName() { + return name; + } + + @Override + public Date getDate() { + return date; + } + + @Override + public Start getStart() { + return start; + } + + @Override + public End getEnd() { + return end; + } + + @Override + public int getTaskCategory() { + return task_cat; + } + + @Override + public int getOverdue(){ + return overdue; + } + + @Override + public boolean getIsCompleted() { + return isCompleted; + } + + @Override + public UniqueTagList getTags() { + return tags; + } + + @Override + public String toString() { + return getAsText(); + } + + public String getAddCommand() { + StringBuilder sb = new StringBuilder(); + sb.append("add " + this.getName().taskDetails + "; "); + sb.append(this.getDate().value + "; "); + sb.append(this.getEnd().value + " "); + this.getTags().getInternalList().stream().forEach(s -> sb.append("#" + s.tagName + " ")); + return sb.toString(); + } +} +``` +###### \java\seedu\simply\testutil\TestTask.java ``` java * A mutable person object. For testing only. */ @@ -1744,8 +1942,8 @@ public class TestTask implements ReadOnlyTask { this.name = name; } - public void setEnd(End address) { - this.end = address; + public void setEnd(End task) { + this.end = task; } public void setStart(Start email) { @@ -1819,18 +2017,237 @@ public class TestTask implements ReadOnlyTask { sb.append(this.getDate().value + "; "); sb.append(this.getStart().value + "; "); sb.append(this.getEnd().value + "] "); - this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " ")); + this.getTags().getInternalList().stream().forEach(s -> sb.append("#" + s.tagName + " ")); return sb.toString(); } } ``` -###### \java\seedu\address\testutil\TestUtil.java +###### \java\seedu\simply\testutil\TestTodo.java +``` java + * A mutable person object. For testing only. + */ +public class TestTodo implements ReadOnlyTask { + + private Name name; + private End end; + private Start start; + private Date date; + private int task_cat; + private int overdue; + private UniqueTagList tags; + boolean isCompleted; + + public TestTodo() { + tags = new UniqueTagList(); + } + + public void setName(Name name) { + this.name = name; + } + + public void setEnd(End task) { + this.end = task; + } + + public void setStart(Start email) { + this.start = email; + } + + public void setDate(Date phone) { + this.date = phone; + } + + public void setTaskCategory(int taskCat) { + this.task_cat = taskCat; + } + + public void setOverdue(int overdue) { + this.overdue = overdue; + } + + public void setIsCompleted(boolean isCompleted) { + this.isCompleted = isCompleted; + } + + @Override + public Name getName() { + return name; + } + + @Override + public Date getDate() { + return date; + } + + @Override + public Start getStart() { + return start; + } + + @Override + public End getEnd() { + return end; + } + + @Override + public int getTaskCategory() { + return task_cat; + } + + @Override + public int getOverdue(){ + return overdue; + } + + @Override + public boolean getIsCompleted() { + return isCompleted; + } + + @Override + public UniqueTagList getTags() { + return tags; + } + + @Override + public String toString() { + return getAsText(); + } + + public String getAddCommand() { + StringBuilder sb = new StringBuilder(); + sb.append("add " + this.getName().taskDetails + " "); + this.getTags().getInternalList().stream().forEach(s -> sb.append("#" + s.tagName + " ")); + return sb.toString(); + } +} +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Removes a subset from the list of deadliness. + * @param deadlines The list of deadliness + * @param deadlinesToRemove The subset of deadlines. + * @return The modified deadlines after removal of the subset from deadlines. + */ + public static TestDeadline[] removeDeadlinesFromList(final TestDeadline[] persons, TestDeadline... personsToRemove) { + List listOfPersons = asList(persons); + listOfPersons.removeAll(asList(personsToRemove)); + return listOfPersons.toArray(new TestDeadline[listOfPersons.size()]); + } + + /** +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Removes a subset from the list of todo. + * @param todos The list of todos + * @param todosToRemove The subset of todos. + * @return The modified todos after removal of the subset from todos. + */ + public static TestTodo[] removeTodosFromList(final TestTodo[] persons, TestTodo... personsToRemove) { + List listOfPersons = asList(persons); + listOfPersons.removeAll(asList(personsToRemove)); + return listOfPersons.toArray(new TestTodo[listOfPersons.size()]); + } + + /** +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Returns a copy of the list with the deadline at specified index removed. + * @param list original list to copy from + * @param targetIndexInOneIndexedFormat e.g. if the first element to be removed, 1 should be given as index. + */ + public static TestDeadline[] removeDeadlinesFromList(final TestDeadline[] list, int targetIndexInOneIndexedFormat) { + return removeDeadlinesFromList(list, list[targetIndexInOneIndexedFormat-1]); + } + + /** +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Returns a copy of the list with the todo at specified index removed. + * @param list original list to copy from + * @param targetIndexInOneIndexedFormat e.g. if the first element to be removed, 1 should be given as index. + */ + public static TestTodo[] removeTodosFromList(final TestTodo[] list, int targetIndexInOneIndexedFormat) { + return removeTodosFromList(list, list[targetIndexInOneIndexedFormat-1]); + } + + /** + * Replaces persons[i] with a person. + * @param persons The array of persons. + * @param person The replacement person + * @param index The index of the person to be replaced. + * @return + */ + public static TestTask[] replacePersonFromList(TestTask[] persons, TestTask person, int index) { + persons[index] = person; + return persons; + } + + /** + * Appends persons to the array of persons. + * @param persons A array of persons. + * @param personsToAdd The persons that are to be appended behind the original array. + * @return The modified array of persons. + */ + public static TestTask[] addPersonsToList(final TestTask[] persons, TestTask... personsToAdd) { + List listOfPersons = asList(persons); + listOfPersons.addAll(asList(personsToAdd)); + return listOfPersons.toArray(new TestTask[listOfPersons.size()]); + } + + /** +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Appends deadlines to the array of deadlines. + * @param deadlines A array of deadlines. + * @param deadlinesToAdd The deadlines that are to be appended behind the original array. + * @return The modified array of deadlines. + */ + public static TestDeadline[] addDeadlinesToList(final TestDeadline[] persons, TestDeadline... personsToAdd) { + List listOfPersons = asList(persons); + listOfPersons.addAll(asList(personsToAdd)); + return listOfPersons.toArray(new TestDeadline[listOfPersons.size()]); + } + + /** +``` +###### \java\seedu\simply\testutil\TestUtil.java +``` java + * Appends todos to the array of todos. + * @param todos A array of todos. + * @param todosToAdd The todos that are to be appended behind the original array. + * @return The modified array of todos. + */ + public static TestTodo[] addTodosToList(final TestTodo[] persons, TestTodo... personsToAdd) { + List listOfPersons = asList(persons); + listOfPersons.addAll(asList(personsToAdd)); + return listOfPersons.toArray(new TestTodo[listOfPersons.size()]); + } + + private static List asList(T[] objs) { + List list = new ArrayList<>(); + for(T obj : objs) { + list.add(obj); + } + return list; + } + + public static boolean compareCardAndPerson(PersonCardHandle card, ReadOnlyTask person) { + return card.isSamePerson(person); + } +``` +###### \java\seedu\simply\testutil\TestUtil.java ``` java public static boolean compareCardAndDeadline(DeadlineCardHandle card, ReadOnlyTask person) { + //System.out.println(card + " " + person + "compareCardAndDeadline"); return card.isSamePerson(person); } ``` -###### \java\seedu\address\testutil\TestUtil.java +###### \java\seedu\simply\testutil\TestUtil.java ``` java public static boolean compareCardAndTodo(TodoCardHandle card, ReadOnlyTask person) { return card.isSamePerson(person); @@ -1859,44 +2276,148 @@ public class TestTask implements ReadOnlyTask { } ``` -###### \java\seedu\address\testutil\TypicalTestTasks.java +###### \java\seedu\simply\testutil\TodoBuilder.java +``` java + */ +public class TodoBuilder { + + private TestTodo person; + + public TodoBuilder() { + this.person = new TestTodo(); + } + + public TodoBuilder withName(String name) throws IllegalValueException { + this.person.setName(new Name(name)); + return this; + } + + public TodoBuilder withTags(String ... tags) throws IllegalValueException { + for (String tag: tags) { + person.getTags().add(new Tag(tag)); + } + return this; + } + + public TodoBuilder withEnd(String task) throws IllegalValueException { + this.person.setEnd(new End(task)); + return this; + } + + public TodoBuilder withDate(String phone) throws IllegalValueException { + this.person.setDate(new Date(phone)); + return this; + } + + public TodoBuilder withStart(String email) throws IllegalValueException { + this.person.setStart(new Start(email)); + return this; + } + + public TodoBuilder withTaskCat(int taskCat) throws IllegalValueException { + this.person.setTaskCategory(taskCat); + return this; + } + + public TodoBuilder withOverdue(int overdue) throws IllegalValueException { + this.person.setOverdue(overdue); + return this; + } + + public TodoBuilder withIsCompleted(boolean isCompleted) throws IllegalValueException { + this.person.setIsCompleted(isCompleted); + return this; + } + + public TestTodo build() { + return this.person; + } + +} +``` +###### \java\seedu\simply\testutil\TypicalTestTasks.java ``` java */ public class TypicalTestTasks { public static TestTask alice, benson, carl, daniel, elle, fiona, george, hoon, ida; + public static TestDeadline deadline1, deadline2, deadline3, deadline4, deadline5, deadline6, deadline7, deadline8, deadline9; + public static TestTodo todo1, todo2, todo3, todo4, todo5, todo6, todo7, todo8, todo9; public TypicalTestTasks() { try { - alice = new TaskBuilder().withName("Alice Pauline").withEnd("2359") - .withStart("1100").withDate("12.12.23").withTaskCat(1).withIsCompleted(false) - .withOverdue(0).withTags("friends").build(); - benson = new TaskBuilder().withName("Benson Meier").withEnd("6pm") - .withStart("2am").withDate("01.05.23").withTaskCat(1).withIsCompleted(false) - .withOverdue(0).withTags("owesMoney", "friends").build(); - carl = new TaskBuilder().withName("Carl Kurz").withDate("12/12/16").withStart("default").withEnd("2350") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - daniel = new TaskBuilder().withName("Daniel Meier").withDate("15.11.23").withStart("7am").withEnd("11pm") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - elle = new TaskBuilder().withName("Elle Meyer").withDate("29/05/36").withStart("0001").withEnd("1212") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - fiona = new TaskBuilder().withName("Fiona Kunz").withDate("12/12/16").withStart("1000").withEnd("1300") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - george = new TaskBuilder().withName("George Best").withDate("210223").withStart("1111").withEnd("1212") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - - //Manually added - hoon = new TaskBuilder().withName("Hoon Meier").withDate("010123").withStart("10am").withEnd("2pm") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); - ida = new TaskBuilder().withName("Ida Mueller").withDate("101023").withStart("2am").withEnd("4pm") - .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + //Events + alice = new TaskBuilder().withName("Alice Pauline").withEnd("2359") + .withStart("1100").withDate("12.12.23").withTaskCat(1).withIsCompleted(false) + .withOverdue(0).withTags("friends").build(); + benson = new TaskBuilder().withName("Benson Meier").withEnd("6pm") + .withStart("2am").withDate("13.12.23").withTaskCat(1).withIsCompleted(false) + .withOverdue(0).withTags("owesMoney", "friends").build(); + carl = new TaskBuilder().withName("Carl Kurz").withDate("14/12/23").withStart("10am").withEnd("2350") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + daniel = new TaskBuilder().withName("Daniel Meier").withDate("15.12.23").withStart("7am").withEnd("11pm") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + elle = new TaskBuilder().withName("Elle Meyer").withDate("16.12.23").withStart("3am").withEnd("4pm") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + fiona = new TaskBuilder().withName("Fiona Kunz").withDate("17/12/23").withStart("1000").withEnd("1300") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + george = new TaskBuilder().withName("George Best").withDate("181223").withStart("1111").withEnd("1212") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + //deadlines + deadline1 = new DeadlineBuilder().withName("Ali Pauline").withEnd("2359") + .withDate("12.12.23").withStart("no start").withTaskCat(2).withIsCompleted(false) + .withOverdue(0).withTags("friends").build(); + deadline2 = new DeadlineBuilder().withName("Ben Meier").withEnd("6pm") + .withDate("13.12.23").withStart("no start").withTaskCat(2).withIsCompleted(false) + .withOverdue(0).withTags("owesMoney", "friends").build(); + deadline3 = new DeadlineBuilder().withName("Car Kurz").withDate("14/12/23").withStart("no start").withEnd("2350") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + deadline4 = new DeadlineBuilder().withName("Dan Meier").withDate("15.12.23").withStart("no start").withEnd("11pm") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + deadline5 = new DeadlineBuilder().withName("Ellie Meyer").withDate("16.12.23").withStart("no start").withEnd("4pm") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + deadline6 = new DeadlineBuilder().withName("Fon Kunz").withDate("17/12/23").withStart("no start").withEnd("1300") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + deadline7 = new DeadlineBuilder().withName("Gorgc Best").withDate("181223").withStart("no start").withEnd("1212") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + //todos + todo1 = new TodoBuilder().withName("Alsi Pauline").withEnd("no end") + .withDate("no date").withStart("no start").withTaskCat(3).withIsCompleted(false) + .withOverdue(0).withTags("friends").build(); + todo2 = new TodoBuilder().withName("Beny Meier").withEnd("no end") + .withDate("no date").withStart("no start").withTaskCat(3).withIsCompleted(false) + .withOverdue(0).withTags("owesMoney", "friends").build(); + todo3 = new TodoBuilder().withName("CarC Kurz").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + todo4 = new TodoBuilder().withName("an Meier").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + todo5 = new TodoBuilder().withName("Elie Meyer").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + todo6 = new TodoBuilder().withName("Sin Kunz").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + todo7 = new TodoBuilder().withName("Gorgc Best").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + + //Manually added + hoon = new TaskBuilder().withName("Hoon Meier").withDate("191223").withStart("10am").withEnd("2pm") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + ida = new TaskBuilder().withName("Ida Mueller").withDate("201223").withStart("2am").withEnd("4pm") + .withTaskCat(1).withIsCompleted(false).withOverdue(0).build(); + deadline8 = new DeadlineBuilder().withName("Hoon Meier").withDate("191223").withStart("no start").withEnd("2pm") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + deadline9 = new DeadlineBuilder().withName("Id Mueller").withDate("201223").withStart("no start").withEnd("4pm") + .withTaskCat(2).withIsCompleted(false).withOverdue(0).build(); + todo8 = new TodoBuilder().withName("on Meier").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); + todo9 = new TodoBuilder().withName("Ijd Mueller").withDate("no date").withStart("no start").withEnd("no end") + .withTaskCat(3).withIsCompleted(false).withOverdue(0).build(); } catch (IllegalValueException e) { e.printStackTrace(); assert false : "not possible"; } } - public static void loadAddressBookWithSampleData(TaskBook ab) { + public static void loadTaskBookWithSampleData(TaskBook ab) { try { ab.addTask(new Task(alice)); @@ -1906,6 +2427,20 @@ public class TypicalTestTasks { ab.addTask(new Task(elle)); ab.addTask(new Task(fiona)); ab.addTask(new Task(george)); + ab.addTask(new Task(deadline1)); + ab.addTask(new Task(deadline2)); + ab.addTask(new Task(deadline3)); + ab.addTask(new Task(deadline4)); + ab.addTask(new Task(deadline5)); + ab.addTask(new Task(deadline6)); + ab.addTask(new Task(deadline7)); + ab.addTask(new Task(todo1)); + ab.addTask(new Task(todo2)); + ab.addTask(new Task(todo3)); + ab.addTask(new Task(todo4)); + ab.addTask(new Task(todo5)); + ab.addTask(new Task(todo6)); + ab.addTask(new Task(todo7)); } catch (DuplicateTaskException e) { assert false : "not possible"; } @@ -1915,9 +2450,33 @@ public class TypicalTestTasks { return new TestTask[]{alice, benson, carl, daniel, elle, fiona, george}; } + + public TestDeadline[] getTypicalDeadline() { + return new TestDeadline[]{deadline1, deadline2, deadline3, deadline4, deadline5, deadline6, deadline7}; + } + + public TestTodo[] getTypicalTodo() { + return new TestTodo[]{todo1, todo2, todo3, todo4, todo5, todo6, todo7}; + } + + public TestTask getSelectedPerson(int index) { + TestTask[] tasks = new TestTask[]{alice, benson, carl, daniel, elle, fiona, george}; + return tasks[index]; + } + + public TestDeadline getSelectedDeadline(int index) { + TestDeadline[] deadlines = new TestDeadline[]{deadline1, deadline2, deadline3, deadline4, deadline5, deadline6, deadline7}; + return deadlines[index]; + } + + public TestTodo getSelectedTodo(int index) { + TestTodo[] todos = new TestTodo[]{todo1, todo2, todo3, todo4, todo5, todo6, todo7}; + return todos[index]; + } + public TaskBook getTypicalTaskBook(){ TaskBook ab = new TaskBook(); - loadAddressBookWithSampleData(ab); + loadTaskBookWithSampleData(ab); return ab; } } diff --git a/collated/test/A0139430L.md b/collated/test/A0139430L.md new file mode 100644 index 000000000000..7e84426edca0 --- /dev/null +++ b/collated/test/A0139430L.md @@ -0,0 +1,678 @@ +# A0139430L +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_add_Event_successful() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.adam(); + TaskBook expectedAB = new TaskBook(); + expectedAB.addTask(toBeAdded); + + // execute command and verify result + assertCommandBehavior(helper.generateAddCommand(toBeAdded), + String.format(AddCommand.EVENT_SUCCESS, toBeAdded), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_add_Deadline_successful() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.beta(); + TaskBook expectedAB = new TaskBook(); + expectedAB.addTask(toBeAdded); + + assertCommandBehavior(helper.generateAddDeadlineCommand(toBeAdded), + String.format(AddCommand.DEADLINE_SUCCESS, toBeAdded), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_add_Todo_successful() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.charlie(); + TaskBook expectedAB = helper.generateTaskBook(1, 1, 1); + TaskBook undolist = new TaskBook(expectedAB); + helper.addToModel(model, 1, 1, 1); + expectedAB.addTask(toBeAdded); + + assertCommandBehavior(helper.generateAddTodoCommand(toBeAdded), + String.format(AddCommand.TODO_SUCCESS, toBeAdded), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_addDuplicateEvent_notAllowed() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.adam(); + TaskBook expectedAB = new TaskBook(); + expectedAB.addTask(toBeAdded); + + // setup starting state + model.addTask(toBeAdded); // person already in internal Task book + + // execute command and verify result + assertCommandBehavior( + helper.generateAddCommand(toBeAdded), + AddCommand.MESSAGE_DUPLICATE_TASK, + expectedAB, + expectedAB.getEventList(), + Collections.emptyList(), + Collections.emptyList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_addDuplicateDeadline_notAllowed() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.beta(); + TaskBook expectedAB = new TaskBook(); + expectedAB.addTask(toBeAdded); + + // setup starting state + model.addTask(toBeAdded); // person already in internal Task book + + // execute command and verify result + assertCommandBehavior( + helper.generateAddDeadlineCommand(toBeAdded), + AddCommand.MESSAGE_DUPLICATE_TASK, + expectedAB, + Collections.emptyList(), + expectedAB.getDeadlineList(), + Collections.emptyList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_addDuplicateTodo_notAllowed() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.charlie(); + TaskBook expectedAB = new TaskBook(); + expectedAB.addTask(toBeAdded); + + // setup starting state + model.addTask(toBeAdded); // person already in internal Task book + + // execute command and verify result + assertCommandBehavior( + helper.generateAddTodoCommand(toBeAdded), + AddCommand.MESSAGE_DUPLICATE_TASK, + expectedAB, + Collections.emptyList(), + Collections.emptyList(), + expectedAB.getTodoList()); + } + + @Test + public void execute_invalidListFormat() throws Exception { + assertCommandBehavior("list asdasd", + String.format(MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.MESSAGE_USAGE)); + } + +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_list_showsAllPersons() throws Exception { + // prepare expectations + TestDataHelper helper = new TestDataHelper(); + TaskBook expectedAB = helper.generateTaskBook(2, 2, 2); + List expectedList = expectedAB.getEventList(); + List expectedDeadlineList = expectedAB.getDeadlineList(); + List expectedTodoList = expectedAB.getTodoList(); + // prepare Task book state + helper.addToModel(model, 2, 2, 2); + + assertCommandBehavior("list", + ListCommand.MESSAGE_SUCCESS, + expectedAB, + expectedList, + expectedDeadlineList, + expectedTodoList); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_deleteInvalidArgsFormat_errorMessageShown() throws Exception { + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE); + assertIncorrectIndexFormatBehaviorForCommand("delete", expectedMessage); + } + + @Test + public void execute_deleteIndexNotFound_errorMessageShown() throws Exception { + assertIndexNotFoundBehaviorForCommand("delete E5"); + assertIndexNotFoundBehaviorForCommand("delete D5"); + assertIndexNotFoundBehaviorForCommand("delete T5"); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectEvent() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threePersons.get(2)); + + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete E3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[E3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectDeadline() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeDeadlines.get(1)); + + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete D2", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[D2]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectTodo() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeTodos.get(1)); + + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete T2", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[T2]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectPersonsEventMultiple() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threePersons.get(0)); + expectedAB.removeTask(threePersons.get(1)); + expectedAB.removeTask(threePersons.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete E1, E2, E3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[E1, E2, E3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectEventRange() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threePersons.get(0)); + expectedAB.removeTask(threePersons.get(1)); + expectedAB.removeTask(threePersons.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete E1-E3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[E1, E2, E3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectDeadlineRange() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeDeadlines.get(0)); + expectedAB.removeTask(threeDeadlines.get(1)); + expectedAB.removeTask(threeDeadlines.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete D1-D3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[D1, D2, D3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectDeadlineMultiple() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeDeadlines.get(0)); + expectedAB.removeTask(threeDeadlines.get(1)); + expectedAB.removeTask(threeDeadlines.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete D1, D2, D3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[D1, D2, D3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectTodoRange() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeTodos.get(0)); + expectedAB.removeTask(threeTodos.get(1)); + expectedAB.removeTask(threeTodos.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete T1-T3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[T1, T2, T3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_delete_removesCorrectTodoMultiple() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + expectedAB.removeTask(threeTodos.get(0)); + expectedAB.removeTask(threeTodos.get(1)); + expectedAB.removeTask(threeTodos.get(2)); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("delete T1, T2, T3", + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, /*threePersons.get(1)*/ new String("[T1, T2, T3]")), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_editInvalidArgsFormat_errorMessageShown() throws Exception { + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE); + assertIncorrectIndexFormatBehaviorForCommand("edit", expectedMessage); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_editIndexNotFound_errorMessageShown() throws Exception { + assertIndexNotFoundBehaviorForCommand("edit E5 des sadas"); + assertIndexNotFoundBehaviorForCommand("edit E5 date 121222"); + assertIndexNotFoundBehaviorForCommand("edit E5 start 1234"); + assertIndexNotFoundBehaviorForCommand("edit E5 end 2359"); + assertIndexNotFoundBehaviorForCommand("edit E5 tag love"); + assertIndexNotFoundBehaviorForCommand("edit E5 tag love>this"); + + assertIndexNotFoundBehaviorForCommand("edit D5 des sadas"); + assertIndexNotFoundBehaviorForCommand("edit D5 date 121222"); + assertIndexNotFoundBehaviorForCommand("edit D5 start 1234"); + assertIndexNotFoundBehaviorForCommand("edit D5 end 2359"); + assertIndexNotFoundBehaviorForCommand("edit D5 tag love"); + assertIndexNotFoundBehaviorForCommand("edit D5 tag love>this"); + + assertIndexNotFoundBehaviorForCommand("edit T5 des sadas"); + assertIndexNotFoundBehaviorForCommand("edit T5 date 121222"); + assertIndexNotFoundBehaviorForCommand("edit T5 start 1234"); + assertIndexNotFoundBehaviorForCommand("edit T5 end 2359"); + assertIndexNotFoundBehaviorForCommand("edit T5 tag love"); + assertIndexNotFoundBehaviorForCommand("edit T5 tag love>this"); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventName() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "des BEACH parTy" , 'E'); + + assertCommandBehavior("edit E1 des BEACH parTy", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "des BEACH parTy"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventDate() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "date 12-12-17" , 'E'); + + assertCommandBehavior("edit E1 date 12-12-17", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "date 12-12-17"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } + +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventStart() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "start 1.00am" , 'E'); + + assertCommandBehavior("edit E1 start 1.00am", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "start 1.00am"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventEnd() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "end 5.00pm" , 'E'); + + assertCommandBehavior("edit E1 end 5.00pm", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "end 5.00pm"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventSpecificTag() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "tag tag1>anything" , 'E'); + + assertCommandBehavior("edit E1 tag tag1>anything", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "tag tag1>anything"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectEventTag() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "tag anything" , 'E'); + + assertCommandBehavior("edit E1 tag anything", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "tag anything"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_add_invalidTagFormat() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + assertCommandBehavior("add T1 #.", Tag.MESSAGE_TAG_CONSTRAINTS, + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } + +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_addTagSingle() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "add anything" , 'E'); + + assertCommandBehavior("add E1 #anything", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "add #anything"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_addTagMultiple() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredEventList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "add anything something" , 'E'); + + assertCommandBehavior("add E1 #anything #something", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "E", "1", "add #anything #something"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectDeadlineName() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredDeadlineList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "des BEACH parTy" , 'D'); + + assertCommandBehavior("edit D1 des BEACH parTy", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "D", "1", "des BEACH parTy"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_edit_editCorrectTodoName() throws Exception { + TestDataHelper helper = new TestDataHelper(); + List threePersons = helper.generateEventsList(3); + List threeDeadlines = helper.generateDeadlineList(3); + List threeTodos = helper.generateTodoList(3); + + TaskBook expectedAB = helper.generateTaskBook(threePersons, threeDeadlines, threeTodos); + helper.addToModel(model, threePersons, threeDeadlines, threeTodos); + + UnmodifiableObservableList lastShownEventList = model.getFilteredTodoList(); + ReadOnlyTask eventToEdit = lastShownEventList.get(1-1); + expectedAB.changeTask(eventToEdit, "des BEACH parTy" , 'T'); + + assertCommandBehavior("edit T1 des BEACH parTy", + String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, "T", "1", "des BEACH parTy"), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } + + + @Test + public void execute_find_invalidArgsFormat() throws Exception { + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE); + assertCommandBehavior("find ", expectedMessage); + } +``` diff --git a/collated/test/A0147890U.md b/collated/test/A0147890U.md new file mode 100644 index 000000000000..56a8ea89a503 --- /dev/null +++ b/collated/test/A0147890U.md @@ -0,0 +1,59 @@ +# A0147890U +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_undo_successful() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.charlie(); + TaskBook expectedAB = helper.generateTaskBook(1, 1, 1); + TaskBook undolist = new TaskBook(expectedAB); + helper.addToModel(model, 1, 1, 1); + expectedAB.addTask(toBeAdded); + + assertCommandBehavior(helper.generateAddTodoCommand(toBeAdded), + String.format(AddCommand.TODO_SUCCESS, toBeAdded), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + + assertCommandBehavior("undo 1", UndoCommand.MESSAGE_UNDO_TASK_SUCCESS, + undolist, + undolist.getEventList(), + undolist.getDeadlineList(), + undolist.getTodoList()); + } +``` +###### \java\seedu\simply\logic\LogicManagerTest.java +``` java + @Test + public void execute_redo_successful() throws Exception { + // setup expectations + TestDataHelper helper = new TestDataHelper(); + Task toBeAdded = helper.charlie(); + TaskBook expectedAB = helper.generateTaskBook(1, 1, 1); + TaskBook undolist = new TaskBook(expectedAB); + helper.addToModel(model, 1, 1, 1); + expectedAB.addTask(toBeAdded); + + assertCommandBehavior(helper.generateAddTodoCommand(toBeAdded), + String.format(AddCommand.TODO_SUCCESS, toBeAdded), + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + + assertCommandBehavior("undo 1", UndoCommand.MESSAGE_UNDO_TASK_SUCCESS, + undolist, + undolist.getEventList(), + undolist.getDeadlineList(), + undolist.getTodoList()); + assertCommandBehavior("redo 1", RedoCommand.MESSAGE_REDO_TASK_SUCCESS, + expectedAB, + expectedAB.getEventList(), + expectedAB.getDeadlineList(), + expectedAB.getTodoList()); + } + +``` diff --git a/src/main/java/seedu/simply/ui/HelpWindow.java b/src/main/java/seedu/simply/ui/HelpWindow.java index a1c477f7f0cc..e2984a2eef21 100644 --- a/src/main/java/seedu/simply/ui/HelpWindow.java +++ b/src/main/java/seedu/simply/ui/HelpWindow.java @@ -49,7 +49,7 @@ private void configure(){ dialogStage = createDialogStage(TITLE, null, scene); setIcon(dialogStage, ICON); - ImageView summary = new ImageView( new Image ("/images/commandSummary_real.PNG")); + ImageView summary = new ImageView( new Image ("/images/command.PNG")); FxViewUtil.applyAnchorBoundaryParameters(summary, 0.0, 0.0, 0.0, 0.0); mainPane.getChildren().add(summary);