Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update user guide features section #110

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Step 3. The method will then find the travel activity with the corresponding tra
of that travel activity.

The sequence diagram below shows how an update operation goes through the parser component:
![img.png](img.png)
![img_1.png](img_1.png)

#[Proposed] Total Expense feature

Expand Down
48 changes: 47 additions & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Introduction

{Give a product intro}
OmniTravel is a software that **allows travellers to store their travel plans and expenses in a
list via a Command Line Interface**.

## Quick Start

Expand All @@ -12,6 +13,14 @@
1. Down the latest version of `Duke` from [here](http://link.to/duke).

## Features
> 📒 Notes about the command format :
> * The words that are in `UPPER_CASE` represents the parameters that the users are required to input
> e.g. `delete INDEX`, `INDEX` is a parameter which can be used as `delete 1`.
> * Commands such as `help`, `list` and `bye` do not require additional parameters. Hence, any extra parameters will be ignored.
> e.g. `help 123` will just be intepreted as `help`.
> * Words that are in square brackets such as `[/tag TAG]` indicates that it is
> optional to include in the command.


{Give detailed description of each feature}

Expand All @@ -24,6 +33,39 @@ Example of usage:

`help`

### Adding a general travel activity : `add`
Adds a general travel activity into the travel activity list

Format: `add DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`

Examples of usage:
* `add Go to Japan /date 2024-03-14 /duration 7 hours`
* `add Go to Hong Kong /date 2024-08-25 /duration 6 hours /tag with family`

### Deleting a travel activity : `delete`
Deletes a travel activity from the travel activity list

Format: `delete INDEX`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

* `INDEX` has to be a number that is shown in the list of travel activities

Examples of usage: `delete 1`

### Listing all the travel activities : `list`
Shows all the travel activities including their tags and expenses

Format: `list`

Examples of usage: `list`

### Updating a travel activity : `update`
Updates the date, duration and tag of a travel activity

Format: `update INDEX /date YYYY-MM-DD /duration DURATION [/tag TAG]`
* `INDEX` has to be a number that is shown in the list of travel activities

Examples of usage:
* `update 1 /date 2019-12-14 /duration 2 hours`
* `update 2 /date 2018-12-12 /duration 3 hours /tag Important`

### Adding a tag: `tag`
Adds a new tag to an existing travel activity.
Expand Down Expand Up @@ -82,6 +124,10 @@ Example of usage:
{Give a 'cheat sheet' of commands here}

* Get commands `help`
* Add general travel activity `add DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`
* Delete travel activity `delete INDEX`
* List travel activities `list`
* Update travel activity `update INDEX /date YYYY-MM-DD /duration DURATION [/tag TAG]`
* Add tag `tag n/ACTIVITY_NUMBER d/TAG_NAME`
* Remove tag `untag n/ACTIVITY_NUMBER`
* Add expense `expense n/ACTIVITY_NUMBER d/EXPENSE_AMOUNT`
Expand Down
2 changes: 1 addition & 1 deletion omni.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
general / 0 / germany / 2023-12-12 / 1 week /
general / 1 / germany / 2019-12-12 / now /
food / 0 / mala / 2023-12-12 / now /
accommodation / 0 / hotel / 2023-12-12 / now /
landmark / 0 / statue of liberty / 2023-12-12 / now /
54 changes: 29 additions & 25 deletions src/main/java/seedu/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,22 @@ public static void activityCommand(String line, TravelActivityList list) throws
String[] command = line.split(" ");
String delimiter = command[0] + "| /date | /duration | /tag ";
String[] input = line.split(delimiter);
String description = input[1].trim();
LocalDate date = LocalDate.parse(input[2]);
String duration = input[3].trim();
String tag = (input.length > 4 && !input[4].isBlank()) ? input[4].trim() : "";
if (input[1].isBlank()) {
//String tag = (input.length > 4 && !input[4].isBlank()) ? input[4].trim() : "";
if (input.length >= 4 && input[1].isBlank()) {
throw new OmniException("The description of accommodation cannot be empty!");
} else if (input[2].isBlank()) {
} else if (input.length >= 4 && input[2].isBlank()) {
throw new OmniException("The date cannot be empty!");
} else if (input[3].isBlank()) {
} else if (input.length >= 4 && input[3].isBlank()) {
throw new OmniException("The duration cannot be empty!");
} else if (input.length >= 5 && input[4].isBlank()) {
throw new OmniException("The tag cannot be empty!");
} else if (input.length < 4 || input[3].contains("/tag")){
throw new OmniException("Wrong format");
}
String description = input[1].trim();
LocalDate date = LocalDate.parse(input[2]);
String duration = input[3].trim();
String tag = (line.contains("/tag") && input.length == 5) ? input[4].trim() : "";
TravelActivity activity;
switch (command[0]) {
case "accommodation":
Expand Down Expand Up @@ -94,23 +97,26 @@ public static void activityCommand(String line, TravelActivityList list) throws
public static void addCommand(String line, TravelActivityList list) throws OmniException{
Ui.printLine();
String[] command = line.split("add | /date | /duration | /tag ");
String description = command[1].trim();
LocalDate date = LocalDate.parse(command[2]);
String duration = command[3].trim();
String tag = (command.length > 4 && !command[4].isBlank()) ? command[4].trim() : "";
//String tag = (command.length > 4 && !command[4].isBlank()) ? command[4].trim() : "";
logger.log(Level.INFO, command[0] + " // " + command[1]);
if (command[1].isBlank()) {
if (command.length >= 4 && command[1].isBlank()) {
throw new OmniException("The description of add cannot be empty!");
} else if(command[2].isBlank()){
} else if(command.length >= 4 && command[2].isBlank()){
throw new OmniException("The date cannot be empty!");
} else if (command[3].isBlank()){
} else if (command.length >= 4 && command[3].isBlank()){
throw new OmniException("The duration cannot be empty!");
} else if (command.length >= 4 && !command[3].contains("/tag")){
String description = command[1].trim();
LocalDate date = LocalDate.parse(command[2]);
String duration = command[3].trim();
String tag = (line.contains("/tag") && command.length == 5) ? command[4].trim() : "";
TravelActivity newActivity = new TravelActivity(description, date, duration, tag);
list.addTravelActivity(newActivity);
System.out.println("I added a new travel activity");
System.out.println(newActivity);
} else {
throw new OmniException("Wrong format");
}
TravelActivity newActivity = new TravelActivity(description, date, duration, tag);
list.addTravelActivity(newActivity);
System.out.println("I added a new travel activity");
System.out.println(newActivity);

Ui.printLine();
}

Expand Down Expand Up @@ -216,12 +222,10 @@ public static void updateCommand(String line, TravelActivityList list) throws Om
throw new OmniException("The duration cannot be empty!");
} else if(command.length >= 5 && command[4].isBlank()){
throw new OmniException("The tag cannot be empty!");
} else if (command.length >= 5 && line.contains("/tag")) {
list.updateTravelActivity(Integer.parseInt(command[1]), LocalDate.parse(command[2]), command[3],
command[4]);
} else if (command.length >= 4 && !line.contains("/tag")){
list.updateTravelActivity(Integer.parseInt(command[1]), LocalDate.parse(command[2]), command[3],
"");
} else if (command.length >= 4 && !command[3].contains("/tag")) {
String tag = (line.contains("/tag") && command.length == 5)? command[4].trim() : "";
list.updateTravelActivity(Integer.parseInt(command[1]), LocalDate.parse(command[2]), command[3].trim(),
tag);
} else {
throw new OmniException("Please check that your update command is in this format: update INDEX " +
"/date YYYY-MM-DD /duration DURATION"
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/seedu/duke/TravelActivityList.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public int getNoOfTravelActivities(){
*/
public void removeTravelActivity(int activityNumber) throws OmniException{
assert activityNumber != 0 :"There is not activities in the list";
if(activityNumber > travelActivities.size()){
if(activityNumber > travelActivities.size() || (activityNumber <= 0)){
throw new OmniException("Travel activity cannot be found!");
}
int indexOfActivity = activityNumber - 1;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void searchKeyword (String activityName) {
public void checkTravelActivity(int activityNumber) throws OmniException{

assert activityNumber != 0 : "There is not activities in the list";
if (activityNumber > travelActivities.size()) {
if (activityNumber > travelActivities.size() || (activityNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfActivity = activityNumber - 1;
Expand All @@ -150,7 +150,7 @@ public void checkTravelActivity(int activityNumber) throws OmniException{
*/
public void uncheckTravelActivity(int activityNumber) throws OmniException{
assert activityNumber != 0 : "There is not activities in the list";
if (activityNumber > travelActivities.size()) {
if (activityNumber > travelActivities.size() || (activityNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfActivity = activityNumber - 1;
Expand All @@ -168,7 +168,7 @@ public void uncheckTravelActivity(int activityNumber) throws OmniException{
*/
public void tagActivity(int taskNumber, String tag) throws OmniException {
assert taskNumber != 0 : "There is no tasks in the list";
if (taskNumber > travelActivities.size()) {
if (taskNumber > travelActivities.size() || (taskNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfTask = taskNumber - 1;
Expand All @@ -184,7 +184,7 @@ public void tagActivity(int taskNumber, String tag) throws OmniException {
*/
public void removeTag(int taskNumber) throws OmniException {
assert taskNumber != 0 : "There is no task in the list";
if (taskNumber > travelActivities.size()) {
if (taskNumber > travelActivities.size() || (taskNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfTask = taskNumber - 1;
Expand All @@ -204,8 +204,7 @@ public void removeTag(int taskNumber) throws OmniException {
*/
public void updateTravelActivity(int travelActivityNumber, LocalDate date, String duration, String tag)
throws OmniException{
if (travelActivityNumber > travelActivities.size() || (travelActivityNumber==0 && travelActivities.isEmpty())
|| travelActivityNumber < 0){
if (travelActivityNumber > travelActivities.size() || (travelActivityNumber <= 0)){
throw new OmniException("Travel activity cannot be found");
}
int indexOfTravelActivity = travelActivityNumber-1;
Expand Down Expand Up @@ -318,7 +317,7 @@ public void findType(String type){
*/
public void expenseActivity(int taskNumber, String expense) throws OmniException {
assert taskNumber != 0 : "There is no tasks in the list";
if (taskNumber > travelActivities.size()) {
if (taskNumber > travelActivities.size() || (taskNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfTask = taskNumber - 1;
Expand All @@ -334,7 +333,7 @@ public void expenseActivity(int taskNumber, String expense) throws OmniException
*/
public void removeExpense(int taskNumber) throws OmniException {
assert taskNumber != 0 : "There is no task in the list";
if (taskNumber > travelActivities.size()) {
if (taskNumber > travelActivities.size() || (taskNumber <= 0)) {
throw new OmniException("Travel activity cannot be found");
}
int indexOfTask = taskNumber - 1;
Expand Down
Loading