Skip to content

Commit

Permalink
commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanG01 committed Sep 22, 2023
1 parent 2f33a41 commit 67d3db9
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 190 deletions.
22 changes: 1 addition & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ features.
- [Listing Tasks](#listing-tasks)
- [Marking a Task as Done](#marking-a-task-as-done)
- [Marking a Task as Not Done](#marking-a-task-as-not-done)

## Features

### Task Management
Expand All @@ -36,10 +36,6 @@ levels: High, Medium, and Low.

Easily find tasks by searching for keywords or dates. Axela will display tasks matching your search criteria.

### Error Handling

Axela is designed to handle errors gracefully. It provides clear feedback for incorrect commands and formats.

## Usage

### Adding a Task
Expand Down Expand Up @@ -148,21 +144,5 @@ Example:
unmark 1
```

### Error Handling

Axela will guide you if you make errors in commands or formats. For example, if you enter an invalid date format:

```
event Party /at 2022-35-10
```

Axela will respond:

```
Please enter the date in the correct format: YYYY-MM-DD.
```

---

This user guide provides a brief overview of Axela's key features and how to use them effectively. Feel free to explore
and make the most of your AI assistant!
28 changes: 4 additions & 24 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Axela User Guide

Welcome to Axela, your personal AI assistant! This guide will help you get started and make the most of Axela's
Welcome to Axela, your personal AI assistant! This guide will help you get started and make the most of Axela's
features.

## Table of Contents
Expand All @@ -20,7 +20,7 @@ features.

### Task Management

Axela can help you manage your tasks efficiently. You can add, delete, mark as done, mark as not done, and list
Axela can help you manage your tasks efficiently. You can add, delete, mark as done, mark as not done, and list
tasks. There are three types of tasks:

1. **Todo** - Simple tasks with specific dates indicating from when to when do we carry out the task.
Expand All @@ -29,17 +29,13 @@ tasks. There are three types of tasks:

### Priority Tracking

You can set priorities for your tasks, allowing you to focus on what's most important. Axela supports three priority
You can set priorities for your tasks, allowing you to focus on what's most important. Axela supports three priority
levels: High, Medium, and Low.

### Task Search

Easily find tasks by searching for keywords or dates. Axela will display tasks matching your search criteria.

### Error Handling

Axela is designed to handle errors gracefully. It provides clear feedback for incorrect commands and formats.

## Usage

### Adding a Task
Expand Down Expand Up @@ -148,21 +144,5 @@ Example:
unmark 1
```

### Error Handling

Axela will guide you if you make errors in commands or formats. For example, if you enter an invalid date format:

```
event Party /at 2022-35-10
```

Axela will respond:

```
Please enter the date in the correct format: YYYY-MM-DD.
```

---

This user guide provides a brief overview of Axela's key features and how to use them effectively. Feel free to explore
This user guide provides a brief overview of Axela's key features and how to use them effectively. Feel free to explore
and make the most of your AI assistant!
4 changes: 2 additions & 2 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package duke;

import java.util.Scanner;

import duke.command.Command;
import duke.command.DukeException;
import duke.task.TaskList;

import java.util.Scanner;

/**
* The Duke class represents a chatbot application that manages tasks.
* Users can add, mark as done, mark as not done, delete, list, and interact with different types of tasks.
Expand Down
206 changes: 110 additions & 96 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package duke;

import duke.command.*;
import duke.task.*;

import java.time.LocalDate;
import java.time.format.DateTimeParseException;

import duke.command.AddCommand;
import duke.command.ByeCommand;
import duke.command.Command;
import duke.command.DeleteCommand;
import duke.command.DukeException;
import duke.command.FindCommand;
import duke.command.HelpCommand;
import duke.command.HiCommand;
import duke.command.ListCommand;
import duke.command.MarkDoneCommand;
import duke.command.MarkNotDoneCommand;
import duke.task.DeadlineTask;
import duke.task.EventTask;
import duke.task.Task;
import duke.task.TaskPriority;
import duke.task.TaskType;
import duke.task.TodoTask;

/**
* The Parser class is responsible for parsing user input and converting it into
* executable commands and tasks for the Duke application.
Expand All @@ -24,45 +39,44 @@ public static Command parseCommand(String input) throws DukeException {
String commandType = parts[0].toLowerCase();

switch (commandType) {
case "bye":
return new ByeCommand();
case "list":
return new ListCommand();
case "hi":
return new HiCommand();
case "mark":
if (parts.length > 1) {
return new MarkDoneCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to mark as done.");
}
case "unmark":
if (parts.length > 1) {
return new MarkNotDoneCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to mark as not done.");
}
case "delete":
if (parts.length > 1) {
return new DeleteCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to delete.");
}
case "find":
if (parts.length > 1) {
return new FindCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a description to find.");
}
case "help":
return new HelpCommand();
case "todo":
case "deadline":
case "event":
// Handle adding tasks
return new AddCommand(input.toLowerCase());
default:
throw new DukeException("Unrecognized command: " + input);
case "bye":
return new ByeCommand();
case "list":
return new ListCommand();
case "hi":
return new HiCommand();
case "mark":
if (parts.length > 1) {
return new MarkDoneCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to mark as done.");
}
case "unmark":
if (parts.length > 1) {
return new MarkNotDoneCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to mark as not done.");
}
case "delete":
if (parts.length > 1) {
return new DeleteCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a task number to delete.");
}
case "find":
if (parts.length > 1) {
return new FindCommand(input.toLowerCase());
} else {
throw new DukeException("Please provide a description to find.");
}
case "help":
return new HelpCommand();
case "todo":
case "deadline":
case "event":
return new AddCommand(input.toLowerCase());
default:
throw new DukeException("Unrecognized command: " + input);
}
}

Expand Down Expand Up @@ -124,29 +138,29 @@ public static Task parseTask(String command) throws DukeException {
TaskType taskType = TaskType.valueOf(parts[0].toUpperCase());

switch (taskType) {
case TODO:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! TODO tasks must have a description.");
}
description = parts[1].trim();
task = parseTodoTask(description, priority);
break;
case DEADLINE:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! DEADLINE tasks must have a description.");
}
description = parts[1].trim();
task = parseDeadlineTask(description, priority);
break;
case EVENT:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! EVENT tasks must have a description.");
}
description = parts[1].trim();
task = parseEventTask(description, priority);
break;
default:
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
case TODO:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! TODO tasks must have a description.");
}
description = parts[1].trim();
task = parseTodoTask(description, priority);
break;
case DEADLINE:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! DEADLINE tasks must have a description.");
}
description = parts[1].trim();
task = parseDeadlineTask(description, priority);
break;
case EVENT:
if (parts.length == 1 || parts[1].trim().isEmpty()) {
throw new DukeException("OOPS!!! EVENT tasks must have a description.");
}
description = parts[1].trim();
task = parseEventTask(description, priority);
break;
default:
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
} catch (IllegalArgumentException e) {
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
Expand Down Expand Up @@ -281,42 +295,42 @@ public static Task parseFileLine(String line) throws DukeException {


switch (taskType) {
case "T":
// Check if the description contains date information
String[] todoParts = description.split(" \\(from: | to: ", 3);

if (todoParts.length == 3) {
LocalDate fromDate = LocalDate.parse(todoParts[1]);
LocalDate toDate = LocalDate.parse(todoParts[2].substring(0, todoParts[2].length() - 1));
return new TodoTask(todoParts[0], fromDate, toDate, isDone, priority);
} else {
throw new DukeException("Invalid todo task format in the file.");
}
case "T":
// Check if the description contains date information
String[] todoParts = description.split(" \\(from: | to: ", 3);

if (todoParts.length == 3) {
LocalDate fromDate = LocalDate.parse(todoParts[1]);
LocalDate toDate = LocalDate.parse(todoParts[2].substring(0, todoParts[2].length() - 1));
return new TodoTask(todoParts[0], fromDate, toDate, isDone, priority);
} else {
throw new DukeException("Invalid todo task format in the file.");
}

case "D":
// Check if the description contains date information
String[] deadlineParts = description.split(" \\(by: ", 2);
case "D":
// Check if the description contains date information
String[] deadlineParts = description.split(" \\(by: ", 2);

if (deadlineParts.length == 2) {
LocalDate byDate = LocalDate.parse(deadlineParts[1].substring(0, deadlineParts[1].length() - 1));
return new DeadlineTask(deadlineParts[0], byDate, isDone, priority);
} else {
throw new DukeException("Invalid deadline task format in the file.");
}
if (deadlineParts.length == 2) {
LocalDate byDate = LocalDate.parse(deadlineParts[1].substring(0, deadlineParts[1].length() - 1));
return new DeadlineTask(deadlineParts[0], byDate, isDone, priority);
} else {
throw new DukeException("Invalid deadline task format in the file.");
}

case "E":
// Check if the description contains date information
String[] eventParts = description.split(" \\(at: ", 2);
case "E":
// Check if the description contains date information
String[] eventParts = description.split(" \\(at: ", 2);

if (eventParts.length == 2) {
LocalDate atDate = LocalDate.parse(eventParts[1].substring(0, eventParts[1].length() - 1));
return new EventTask(eventParts[0], atDate, isDone, priority);
} else {
throw new DukeException("Invalid event task format in the file.");
}
if (eventParts.length == 2) {
LocalDate atDate = LocalDate.parse(eventParts[1].substring(0, eventParts[1].length() - 1));
return new EventTask(eventParts[0], atDate, isDone, priority);
} else {
throw new DukeException("Invalid event task format in the file.");
}

default:
throw new DukeException("Unknown task type in file.");
default:
throw new DukeException("Unknown task type in file.");
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package duke;

import duke.command.DukeException;
import duke.task.Task;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import duke.command.DukeException;
import duke.task.Task;

/**
* The Storage class is responsible for loading and saving tasks to/from a file.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package duke;

import duke.task.Task;

import java.util.ArrayList;

import duke.task.Task;

/**
* The Ui class provides user interface functionality for interacting with the Duke application.
* It displays messages to the user, such as welcome messages, task lists, and error messages.
Expand Down
Loading

0 comments on commit 67d3db9

Please sign in to comment.