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

[Caleb Cherng Kai Zhe] iP #468

Open
wants to merge 61 commits into
base: master
Choose a base branch
from

Conversation

Ditzchann
Copy link

@Ditzchann Ditzchann commented Feb 6, 2025

Angela

Hello X. I am Angela, your advisor and secretary.

Based on Project Moon's Lobotomy Corporation, Angela is an advanced human AI whose role is to guide you through your tasks just as she did in LC.

With the chat bot, you can enjoy

  • the ability to organize your tasks your tasks in one place
  • your tasks all saved in your local storage to come back to anytime
  • customized dialogue with the head AI of Lobotomy Corp, tailored for any LC fan to enjoy

Features:

  • Saving your tasks into your local storage
  • Searching for tasks
  • Deleting tasks

Todo (with priority!)

  1. Command class to simplify functions
  2. GUI

If you want to contribute, open a pull request to help improve my code! (My poor processDb function needs help 😭)

public Task processDb(String line) throws AngelaException {
        Task t;
        String[] lineArr = line.split("\\|\\|"); //no way malicious injection is real
        t = switch (lineArr[0]) { //as we all know nothing bad ever happens when we save data as text
            case "T" -> new ToDoTask(lineArr[2]);
            case "D" -> new DeadlineTask(lineArr[2], lineArr[3]);
            case "E" -> new EventTask(lineArr[2], lineArr[3], lineArr[4]);
            default -> throw new AngelaException("");
        };
        if (lineArr[1].equals("1")) t.doTask();
        return t;
    }

damithc and others added 12 commits July 11, 2024 16:52
In build.gradle, the dependencies on distZip and/or distTar causes
the shadowJar task to generate a second JAR file for which the
mainClass.set("seedu.duke.Duke") does not take effect.
Hence, this additional JAR file cannot be run.
For this product, there is no need to generate a second JAR file
to begin with.

Let's remove this dependency from the build.gradle to prevent the
shadowJar task from generating the extra JAR file.
Added default greet function
Added exit function
Added echo function to repeat user input
Added Processor.java to assist in text processing
Added functionality to store inputs as a list and output them accumulatively
Created initialization for Task class
Added toString() method for Task class
Added ability to set tasks as done
Updated Task.java to be able to mark tasks as done
Added markDone() and markUndone() to Processor.java
Added EventTask.java
Fixed some formatting errors
Added processing for DeadlineTask, TodoTask and EventTask
Copy link

@RT0118 RT0118 left a comment

Choose a reason for hiding this comment

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

Other than a few nits, LGTM!


@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
Copy link

Choose a reason for hiding this comment

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

I like the use of newlines to keep char count below 120

import java.util.regex.Pattern;

public class Processor {
private List<Task> store = new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

Suggested change
private List<Task> store = new ArrayList<>();
private List<Task> store = new ArrayList<>();

Should this be named more specific?

Comment on lines 1 to 2
import java.util.Scanner;
import java.util.List;
Copy link

Choose a reason for hiding this comment

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

Suggested change
import java.util.Scanner;
import java.util.List;
import java.util.List;
import java.util.Scanner;

Perhaps your imports could be ordered lexicographically?

Copy link

@nikingoda nikingoda left a comment

Choose a reason for hiding this comment

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

Overall, your code is easy to read and understand. However, there are still spaces to improve.
Good job!

String input;
do {
input = textIn.nextLine();
if (input.equalsIgnoreCase("list")) {

Choose a reason for hiding this comment

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

Maybe you can use switch-case style to improve readability and maintainability in future

output(out.trim(), true);
}

public void addTask(String input) {

Choose a reason for hiding this comment

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

maybe addTask(Task task) be better instead of 3 versions of addTask() for Event, Deadline and Todo, to avoid misusing

input = textIn.nextLine();
if (input.equalsIgnoreCase("list")) {
printList();
} else if (input.length() >= 4 && input.substring(0, 4).equalsIgnoreCase("mark")) { //probably move this in the future

Choose a reason for hiding this comment

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

you may use split(" ") to make an array String[] for convenience

Copy link

@SomneelSaha2004 SomneelSaha2004 left a comment

Choose a reason for hiding this comment

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

LGTM!
There a are a few minor refactorings that are non essential.

Choose a reason for hiding this comment

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

The order of imports could be lexicographical?

Choose a reason for hiding this comment

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

A switch case would be easier to follow in term of logic inside the start() function.
We can use .split() to get the different parts of the input?
Then once we get the command we continue to process based off of expected format.
Since the list of tasks is of type Task we can modify addTask to have signature addTask(Task t) as then we can add all 3 types without having to write 3 different methods.

Choose a reason for hiding this comment

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

We can use the java string package to more efficiently process input?
The .trim() and .split() method could remove the need for the trimInput functions

Choose a reason for hiding this comment

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

We can make this class abstract, as we wont be instantiating any objects of type Task and we can prevent misuse of this class and enforce usage of the actual 3 types we expect.

Output messages can be concatenated into a class and called using its static methods to prevent code duplication
Cleaned up command processing by adding new function to split command input
Used switch-case instead of if-else to polish code
More abstraction in the Processor class
Add testcases to input.txt and EXPECTED.TXT
Modify runtest.bat
Add several Exceptions to handle cases of invalid input
Add ability to delete tasks that are made
Add getArguments method to ensure correct argument flags are passed in
Storage.java manages the storage of the tasks into local files.
Edit Processor.java to integrate changes from Storage.java
Add Command.java class to act as data structure for commands
Add Parser.java and TaskManager.java to handle command parsing and editing the task list
Add method to find tasks by keyword
Add lastFunction local variable to Angela.java

Let's create a variable that stores the last inputted command that
was called by the user for use in the undo function.

This allows for the undo method to recall the last function used
and act accordingly in the future.

Add new undo() method to Angela.java

The method will recall the last function, calling an undo method in
the manager if the last function made changes to the database.

In the event of a bad undo (undoing a list, find command), the
method will give an error message.
Task class modifications

Task class and its subclasses are not effectively final.

This caused problems when archiving the previous iteration
of the task list.

Let's change do/undo task methods to return a new copy
of the task, allowing for easier archiving for the tasks.

Add support for archiving task list in TaskManager

Lets let TaskManager save a copy of the previous iteration
of tasks before any changes to the tasklist such that
it can be easily retrieved to undo the change.
Add assertions to Angela.java and Storage.java
Event Tasks were saved in the wrong format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants