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

[Barbaracwx] iP #67

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
999081b
Change name of bot
Barbaracwx Aug 31, 2023
c129070
commit echo
Barbaracwx Sep 4, 2023
23d1e0e
commit level 2: add, list
Barbaracwx Sep 4, 2023
182f0f5
commit level 3: mark as done
Barbaracwx Sep 4, 2023
69a4ae4
commit coding standard
Barbaracwx Sep 4, 2023
8842184
commint Level 4. ToDos, Events, Deadlines
Barbaracwx Sep 6, 2023
f824dfe
commit: improve code quality
Barbaracwx Sep 8, 2023
70ba578
add increment as a branch, level 5
Barbaracwx Sep 15, 2023
0894d39
Merge branch 'branch-Level-5'
Barbaracwx Sep 15, 2023
a0f798a
Organize classes into the 'duke' package
Barbaracwx Sep 15, 2023
2987979
Merge branch 'branch-A-Packages'
Barbaracwx Sep 15, 2023
9beff6f
Implement Level-6
Barbaracwx Sep 20, 2023
786c27b
Implement Level-7
Barbaracwx Sep 22, 2023
327d3d4
Merge branch 'branch-Level-6'
Barbaracwx Sep 22, 2023
5fe3f31
Implement Level-7
Barbaracwx Sep 22, 2023
9e14e1d
Added A-jar level
Barbaracwx Sep 22, 2023
d2ed96a
commit updated changes
Barbaracwx Sep 28, 2023
6425ae4
Implement A-Exceptions Tag
Barbaracwx Sep 28, 2023
2423d8a
level 5
Barbaracwx Sep 28, 2023
ef461a8
implemented A-Collections Tag
Barbaracwx Sep 28, 2023
36a4072
Merge branch 'branch-Level-7'
Barbaracwx Sep 28, 2023
36a6f2b
commit added parser,command, tasklist and ui class
Barbaracwx Oct 2, 2023
98a143a
Implement find
Barbaracwx Oct 2, 2023
87b9da0
Merge pull request #1 from Barbaracwx/branch-Level-9
Barbaracwx Oct 2, 2023
4df8bd3
Added JavaDoc comments
Barbaracwx Oct 3, 2023
6d2c93b
Merge pull request #2 from Barbaracwx/branch-A-JavaDoc
Barbaracwx Oct 3, 2023
139e288
Organised code
Barbaracwx Oct 3, 2023
dd53bc2
change name of file
Barbaracwx Oct 3, 2023
b073a6f
organised files
Barbaracwx Oct 3, 2023
b913271
Update README.md
Barbaracwx Oct 3, 2023
a58e292
Update README.md
Barbaracwx Oct 3, 2023
c03627a
Update README.md
Barbaracwx Oct 3, 2023
8b10039
Update README.md
Barbaracwx Oct 3, 2023
fc929e4
Update README.md
Barbaracwx Oct 3, 2023
2976ed5
Update README.md
Barbaracwx Oct 3, 2023
2bc67ee
Update README.md
Barbaracwx Oct 3, 2023
3f173b3
Update README.md
Barbaracwx Oct 3, 2023
7437537
Update README.md
Barbaracwx Oct 3, 2023
64ef5a1
Update README.md
Barbaracwx Oct 3, 2023
a1a8f04
Update README.md
Barbaracwx Oct 3, 2023
3f61c50
Update README.md
Barbaracwx Oct 3, 2023
f7d6c25
Added user guide
Barbaracwx Oct 5, 2023
b2c8537
Merge branch 'master' of https://github.com/Barbaracwx/ip
Barbaracwx Oct 5, 2023
a480276
Edited code
Barbaracwx Oct 6, 2023
db152b1
Updated code
Barbaracwx Oct 6, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Duke project template
# Duke project template :)

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.
This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it. :)

## Setting up in Intellij

Expand Down
Empty file added caraData.txt
Empty file.
123 changes: 110 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,126 @@
# User Guide
# User Guide of Cara
Cara: a fun and friendly task management bot that helps you to organise your task efficiently and easily :)

## Features
### Task Management
- **Add Tasks**: Easily add different task types to your to-do list, such as Todo, Deadline, and Event.
- **Mark Tasks as Done**: Mark tasks as completed when you've finished them.
- **Delete Tasks**: Remove tasks that you no longer need.
- **List Tasks**: View a list of all your tasks.
- **Find Tasks**: Search for specific tasks using keywords.

### Feature-ABC
## Features

Description of the feature.
### 1. Add Todo Task - `todo`

### Feature-XYZ
Add a todo task to the tasklist

Description of the feature.
Format: `todo DESCRIPTION`

## Usage
Example of usage:

```
todo buy book
todo return money
```

### `Keyword` - Describe action
### 2. Add Deadline Task - `deadline`

Describe the action and its outcome.
Add a deadline task to the tasklist, with a date to complete by

Format: `deadline DESCRIPTION /by DEADLINE`

Example of usage:

`keyword (optional arguments)`
```
Deadline do homework /by 8 nov 2023
```

### 3. Add Event Task - `event`

Expected outcome:
Add an event task to the tasklist, with a start and end time

Description of the outcome.
Format: `event DESCRIPTION /from STARTTIME /to ENDTIME`

Example of usage:

```
expected output
event concert /from 6pm /to 9pm
```

### 4. Delete Task - `delete`

Delete a task from the tasklist base on index

Format: `delete INDEX`

- The index refers to the index number shown in the tasklist
- the index **must be a positive integer** 1,2,3...

Example of usage:

```
delete 5
```

### 5. List Task - `list`

Shows a list of all tasks in the list

Format: `list`

Example of usage:

```
list
```

### 6. Find Task - `find`

Find tasks that contains any of the keywords

Format: `find KEYWORD`

- The search is case-insensitive, e.g `Book` will match `book`

Example of usage:

```
find book
```

### 7. Mark Task - `mark`

Mark a task as done based on their index

Format: `mark INDEX`

Example of usage:

```
mark 1
```

### 8. Unmark Task - `unmark`

Mark a task as not done based on their index

Format: `unmark INDEX`

Example of usage:

```
unmark 1
```

### 9. Ending the program - `bye`

Exits the program

Format: `bye`

Example of usage:

```
bye
```

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

import Commands.Command;
import Tasks.TaskList;

import java.io.IOException;

/**
* Duke is a task management program that allows users to manage their tasks.
* It provides functionality for adding, deleting, and listing tasks.
*/
public class Cara {
private Ui ui;
private TaskList tasks;
private Storage storage;

/**
* Constructs a Duke instance with the specified file path.
*
* @param filePath The path to the file used for task storage.
* @throws CaraException If there is an issue initializing Duke.
*/
public Cara(String filePath) throws CaraException {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.loadTasks());
} catch (CaraException | IOException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

/**
* Runs the Duke program, handling user input and executing commands.
*/
public void run() {
ui.printWelcomeMessage();
boolean isExit = false;

while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine();
Command c = Parser.parse(fullCommand);
c.execute(tasks.getTasks(), ui, storage);
isExit = c.isExit();
Storage.saveTasks(tasks.getTasks());
} catch (IOException | CaraException e) {
ui.showError(e.getMessage());
} finally {
ui.showLine();
}
}
}

/**
* The main entry point for running the Duke program.
*
* @param args The command-line arguments (not used in this program).
* @throws IOException If an I/O error occurs.
* @throws CaraException If there is an issue with Duke initialization.
*/
public static void main(String[] args) throws IOException, CaraException {
new Cara("data/tasks.txt").run();
}
}
16 changes: 16 additions & 0 deletions src/main/java/Cara/CaraException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package Cara;

/**
* DukeException is a custom exception class used to represent exceptions specific to the Duke program.
*/
public class CaraException extends Exception {

/**
* Constructs a DukeException with the specified error message.
*
* @param message The error message associated with the exception.
*/
public CaraException(String message) {
super(message);
}
}
43 changes: 43 additions & 0 deletions src/main/java/Cara/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package Cara;

import Commands.*;

/**
* The Parser class is responsible for parsing user input and generating corresponding commands.
*/
public class Parser {

/**
* Parses the user input and returns the corresponding command.
*
* @param input The user input to be parsed.
* @return A Command object based on the parsed input.
* @throws CaraException If there is an issue with parsing the input.
*/
public static Command parse(String input) throws CaraException {
// Split the input into words
String[] words = input.split(" ");
String command = words[0].toLowerCase(); // Extract the first word as the command

switch (command) {
case "bye":
return new ExitCommand(); // Create an ExitCommand
case "list":
return new ListCommand(); // Create a ListCommand
case "mark":
return new MarkCommand(input); // Create a MarkCommand with the input as a parameter
case "unmark":
return new UnmarkCommand(input); // Create an UnmarkCommand with the input as a parameter
case "delete":
return new DeleteCommand(input); // Create a DeleteCommand with the input as a parameter
case "find":
return new FindCommand(input); // Create a FindCommand with the input as a parameter
case "todo":
case "event":
case "deadline":
return new AddCommand(input); //Create a AddCommand with the input as a parameter
default:
throw new CaraException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}
}
44 changes: 44 additions & 0 deletions src/main/java/Cara/Storage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package Cara;

import Tasks.Task;
import Tasks.TasksHandler;

import java.io.*;
import java.util.ArrayList;

/**
* The Storage class is responsible for loading and saving tasks from/to a file.
*/
public class Storage {

/**
* Constructs a Storage instance with the specified file path (ignored).
*
* @param ignoredFilePath The path to the file (ignored).
*/
public Storage(String ignoredFilePath) {
}

/**
* Loads tasks from a file and returns them as an ArrayList.
*
* @return An ArrayList of tasks loaded from the file.
* @throws IOException If an I/O error occurs during file reading.
* @throws CaraException If there is an issue with Duke while reading the file.
*/
public ArrayList<Task> loadTasks() throws IOException, CaraException {
ArrayList<Task> tasks = new ArrayList<>();
TasksHandler.readFromFile(tasks); // Pass an ArrayList<Task> to the readFromFile() method
return tasks;
}

/**
* Saves tasks to a file.
*
* @param tasks The ArrayList of tasks to be saved to the file.
* @throws IOException If an I/O error occurs during file writing.
*/
public static void saveTasks(ArrayList<Task> tasks) throws IOException {
TasksHandler.writeToFile(tasks); // Pass the provided ArrayList<Task> to the writeToFile method
}
}
Loading