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

[SaiChaitanya13] ip #203

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
cbe03ba
Added Increment - Level 0
Jan 28, 2023
f2d0bfe
Added Increment - Level 1
Jan 28, 2023
e5f9282
Added Increment - Level 2
Jan 28, 2023
c0efa6e
Added Increment - Level 3
Jan 31, 2023
eae4525
Coding Standards --> Used camelCase throughout
Jan 31, 2023
7435c1a
Added Increment - Level 4
Jan 31, 2023
8c9d925
Cleaned up code + Added increment - Code Quality
Feb 9, 2023
4a3350e
Cleaned up code + Added increment - Code Quality
Feb 9, 2023
8bf9626
Improved code quality
Feb 9, 2023
8e63c8d
Added Level 5 for two exceptions + reformatted code
Feb 10, 2023
63a70ee
Added exceptions for Level 5
Feb 10, 2023
7d9c743
Merge branch 'branch-Level-5'
Feb 10, 2023
cc2f69d
add delete command
Feb 17, 2023
1f72f15
add delete command
Feb 17, 2023
6d07cfd
Changed to array list + Added Level 6
Feb 19, 2023
8c7e7a7
refactored code
Feb 20, 2023
a969961
added Storage
Feb 28, 2023
f8c9289
resolve merge conflicts
Feb 28, 2023
5fe1586
add delete command
Feb 17, 2023
9c94db0
add delete command
Feb 17, 2023
cca8512
Changed to array list + Added Level 6
Feb 19, 2023
8d246b7
refactored code
Feb 20, 2023
a9ef0bd
Merge branch 'branch-Level-6'
Feb 28, 2023
678f733
delete branch 7 to make it easier
Feb 28, 2023
154b006
Done till Level 6
Feb 28, 2023
a6e5092
Testing
Mar 1, 2023
9fb485f
Merge branch 'master' of https://github.com/SaiChaitanya13/ip
Mar 1, 2023
34f8b0d
SAVE FINALLY WORKS WOHOO
Mar 2, 2023
5d87d90
Merge branch 'branch-Level-7'
Mar 2, 2023
91858cb
Working JAR File
Mar 2, 2023
b7593c6
Working JAR File
Mar 2, 2023
5c84e0b
FIND function implemented
Mar 2, 2023
d69ac7a
Merge branch 'branch-Level-9'
Mar 2, 2023
999cf72
Added Task List Class which works!!
Mar 2, 2023
8a086b7
Added the different Task Command Classes
Mar 2, 2023
df06edd
Added ALL Command classes - Task and Action
Mar 2, 2023
511e48c
Added Parser Class and works
Mar 2, 2023
4c43b1e
Added Messages Class
Mar 2, 2023
8f0a3e8
Added Help Command and Help Message
Mar 2, 2023
5c3cb49
Added Greeting
Mar 2, 2023
5bebd19
Add Date Time Formatter for Deadline
Mar 2, 2023
de0616c
changing just to merge
Mar 2, 2023
1dd986b
Merge branch 'branch-Level-8'
Mar 2, 2023
bb101ad
Added exceptions to code
Mar 2, 2023
7b4656e
merge conflicts resolved
Mar 2, 2023
e45aba2
Added Testing
Mar 2, 2023
8ca8fd8
All works, adding UI
Mar 3, 2023
3ffea71
Added MoreOOP everything works
Mar 3, 2023
2675b55
added to main, debugging issues
Mar 3, 2023
39a3bfb
file works WITHOUT directory
Mar 3, 2023
856052c
imported packages without * so better coding standard
Mar 3, 2023
e444e1b
LETS GO Storage Path changed with directory AND IT WORKS!
Mar 3, 2023
acc7aea
minor reformatting of code
Mar 3, 2023
beb0c51
Made minor documentation
Mar 3, 2023
8cc346b
Added ALL Documentation in the right format
Mar 3, 2023
a3f035e
Merge branch 'branch-A-JavaDoc'
Mar 3, 2023
c2fc057
Reformatted code and added in some additional checks
Mar 3, 2023
9aff198
Fixed many bugs
Mar 3, 2023
15e388b
Added User Guide
Mar 3, 2023
cb8a6f0
FINAL CHANGES FINALISED BUDDY YAY
Mar 3, 2023
0a0118e
slight change
Mar 3, 2023
57d9fcb
small change for merge
Mar 3, 2023
3be8a94
Merge pull request #1 from SaiChaitanya13/mergepr
SaiChaitanya13 Mar 3, 2023
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
3. After that, locate the `src/buddy.main/java/Duke.java` file, right-click it, and choose `Run Duke.buddy.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
101 changes: 88 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,104 @@
# User Guide

Buddy is a very helpful tool in helping you manage your daily tasks
and helping you be more organised. It also helps you improve your day to day productivity!
Get immersed in this cli-optimised application!

## Features

### Feature-ABC
### Add tasks to your task list
Add various types of tasks - todo, deadline and event.

Description of the feature.
### Delete tasks from your task list
Delete tasks from the list.

### Feature-XYZ
### Keep track of the progress of your tasks
Mark/Unmark tasks from the list to keep track of what you have completed.

Description of the feature.
### Find tasks in your task list
Find tasks that match a keyword

## Usage

### `Keyword` - Describe action
### `todo` - Adds a Todo task

Format: `todo <TASK_DESCRIPTION>`

- Adds a todo with `<TASK_DESCRIPTION>`
- `<TASK_DESCRIPTION>` should not be empty

Examples of usage:
- `todo cs2113 project`
- `todo cs2102 assignment`

### `deadline` - Adds a Deadline task
Format: `deadline <TASK_DESCRIPTION> /by <deadlinedate>`

- Adds a task with a `<TASK_DESCRIPTION>` to be completed by `<deadlinedate>`
- Deadline date should be in `<YYYY-MM-DD>` format
- Deadline date cannot be before today's date
- Deadline date should not be empty

Examples of usage:
- `deadline cs2113 ip /by 2023-03-03`
- `deadline cs1010 assignment /by 2024-04-04`

### `event` - Adds a Event task
Format: `event <TASK_DESCRIPTION> /from <Start> /to <End>`

- Adds a task with a `<TASK_DESCRIPTION>` with a start `<Start>` to end `<End>`
- `<TASK_DESCRIPTION>` should not be empty
- `<Start>` and `<End>` should not be empty

Examples of usage:
- `event cs2113 exam /from 4pm /to 6pm`
- `event NUS Open House /from 24 Dec 2023 6am /to 6pm`

### `mark` - Marks a task as done
Format: `mark <INDEX_OF_TASK>`

- Marks a task as done
- `<INDEX_OF_TASK>` should be within the task list

Examples of usage:
- `mark 2`
- `mark 1`

### `unmark` - Marks a task as not done
Format: `unmark <INDEX_OF_TASK>`

- Marks a task as not done
- `<INDEX_OF_TASK>` should be within the task list

Examples of usage:
- `unmark 2`
- `unmark 4`

### `delete` - Deletes a task from the task list
Format: `delete <INDEX_OF_TASK>`

- Deletes a task
- `<INDEX_OF_TASK>` should be within the task list

Examples of usage:
- `delete 2`
- `delete 1`

### `find` - Finds a task by keyword
Format: `find <keyword>`

Describe the action and its outcome.
- Finds matching tasks
- `<keyword>` should be one word

Example of usage:
Examples of usage:
- `find cs2113`
- `find todo`

`keyword (optional arguments)`
### `bye` - Exits the program
Format: `bye`

Expected outcome:
- Exits the program.

Description of the outcome.
### HOW DO I SAVE MY TASK LIST?

```
expected output
```
- The program auto saves your task list and loads it when you run the program!
8 changes: 8 additions & 0 deletions src/main/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/main/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/main/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/main/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: buddy.Buddy

52 changes: 52 additions & 0 deletions src/main/java/buddy/Buddy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package buddy;

import java.util.Scanner;

import buddy.parser.Parser;
import buddy.storage.Storage;
import buddy.tasks.TaskList;
import buddy.ui.Ui;

/**
* The part which executes the entire program
*/
public class Buddy {
private final Storage storage;
private static TaskList taskList;
private final Ui ui;
public static int taskCount = 0;

/**
* Constructor for Buddy class
*
* @param filePath The filepath of the file
*/
public Buddy(String filePath) {
taskList = new TaskList();
storage = new Storage(filePath);
ui = new Ui();
}

/**
* This function runs the program till completion (till a "bye" is inputted)
*/
public void run() {
ui.loadFileOrCreateFile(taskList, storage);
ui.greetUser();
String input;
Scanner in = new Scanner(System.in);
input = in.nextLine();
Parser processAllCommands = new Parser();

while (!processAllCommands.isExit(input)) {
processAllCommands.executeInput(taskList, input, storage);
input = in.nextLine();
}
ui.sayByeToUser();
}


public static void main(String[] args) {
new Buddy("./Data").run();
}
}
17 changes: 17 additions & 0 deletions src/main/java/buddy/commands/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package buddy.commands;

import buddy.exceptions.InvalidCommandException;
import buddy.tasks.TaskList;

/**
* Constructor for Command class
*/
public abstract class Command {
/**
* Executes the commands by the user for all the different types of commands - actionCommands and addTaskCommands
*
* @param taskList List of tasks
* @param input Command inputted by the user
*/
public abstract void executeCommand(TaskList taskList, String input) throws InvalidCommandException;
}
29 changes: 29 additions & 0 deletions src/main/java/buddy/commands/actionCommands/DeleteTaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package buddy.commands.actionCommands;

import buddy.commands.Command;
import buddy.messages.Messages;
import buddy.tasks.TaskList;


public class DeleteTaskCommand extends Command {

/**
* Process DeleteTaskCommand by user and deletes task from task list
*
* @param taskList List of tasks
* @param input Command inputted by user
*/
@Override
public void executeCommand(TaskList taskList, String input) {
try {
String[] deleteSplit = input.split(" ", 2);
int taskNumberToBeDeleted = Integer.parseInt(deleteSplit[1]);
int indexOfTaskInTaskList = taskNumberToBeDeleted - 1;
taskList.deleteTask(indexOfTaskInTaskList);

} catch (IndexOutOfBoundsException e) {
System.out.println("That is not a valid task to delete! Please check your list again and input a valid task");
System.out.println(Messages.DIVIDER);
}
}
}
43 changes: 43 additions & 0 deletions src/main/java/buddy/commands/actionCommands/FindTaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package buddy.commands.actionCommands;

import buddy.exceptions.InvalidCommandException;
import buddy.messages.Messages;
import buddy.commands.Command;
import buddy.tasks.TaskList;
import buddy.tasks.Task;

import java.util.ArrayList;

import static java.util.stream.Collectors.toList;

public class FindTaskCommand extends Command {

/**
* Process FindTaskCommand by user and finds and outputs the matching task to keyword
* If there are no matching tasks, tells user that there are none
*
* @param taskList List of tasks
* @param input Command inputted by user
*/
@Override
public void executeCommand(TaskList taskList, String input) throws InvalidCommandException {
if (input.equals("find")){
throw new InvalidCommandException();
}
String keyword = input.split(" ")[1].trim().toLowerCase();
ArrayList<Task> matchedTasks;
matchedTasks = (ArrayList<Task>) taskList.stream() // casts list to ArrayList
.filter(t -> t.getTaskName().trim().toLowerCase().contains(keyword)).collect(toList());
System.out.println(Messages.DIVIDER);
if (!matchedTasks.isEmpty()) {
System.out.println("Well, here is the list of tasks matching your keyword!");
}
for (Task task : matchedTasks) {
System.out.println(task);
}
if (matchedTasks.isEmpty()) {
System.out.println("Oops, there are no tasks matching the keyword! Try again with another keyword");
}
System.out.println(Messages.DIVIDER);
}
}
21 changes: 21 additions & 0 deletions src/main/java/buddy/commands/actionCommands/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package buddy.commands.actionCommands;

import buddy.messages.Messages;
import buddy.ui.Ui;
import buddy.commands.Command;
import buddy.tasks.TaskList;

public class HelpCommand extends Command {
/**
* Process HelpCommand by user and prints help message
*
* @param taskList List of tasks
* @param input Command inputted by user
*/
@Override
public void executeCommand(TaskList taskList, String input) {
System.out.println(Messages.DIVIDER);
Ui.displayHelpMessage();
System.out.println(Messages.DIVIDER);
}
}
32 changes: 32 additions & 0 deletions src/main/java/buddy/commands/actionCommands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package buddy.commands.actionCommands;

import buddy.Buddy;
import buddy.messages.Messages;
import buddy.commands.Command;
import buddy.tasks.TaskList;

public class ListCommand extends Command {

/**
* Process ListCommand by user and prints out the list of tasks
*
* @param taskList List of tasks
* @param input Command inputted by user
*/
@Override
public void executeCommand(TaskList taskList, String input) {
System.out.println(Messages.DIVIDER);
if (!taskList.isEmpty()) {
System.out.println("Here is the list of tasks you have remaining! Come on Buddy!");
}
int index = 1; // index which shows numbers the task
for (int i = 0; i < Buddy.taskCount; i++) {
System.out.println(index + "." + taskList.get(i));
index++; // increment the number on the task
}
if (taskList.isEmpty()) {
System.out.println("There is nothing in the list! Please enter a new command");
}
System.out.println(Messages.DIVIDER);
}
}
Loading