Skip to content

[wahkia] iP#99

Open
wahkia wants to merge 39 commits into
nus-cs2113-AY2425S1:masterfrom
wahkia:master
Open

[wahkia] iP#99
wahkia wants to merge 39 commits into
nus-cs2113-AY2425S1:masterfrom
wahkia:master

Conversation

@wahkia

@wahkia wahkia commented Sep 3, 2024

Copy link
Copy Markdown

No description provided.

wahkia added 9 commits August 27, 2024 22:13
This is the first entry of the project. It contains a Java program
that outputs a simple chatbot greeting and farewell message.
This commit adds functionality for echoing user commands and exiting
on 'bye'. The chatbot now features a customizable personality, with
random fun responses for unknown commands and special handling for
recognized commands like 'list'.
This update enables Lia to store tasks entered by the user and
display them upon request with the 'list' command. The chatbot
now also acknowledges each added task and continues to offer
a personalized farewell when 'bye' is entered.
This commit introduces the ability to mark tasks as done or not done
using the 'mark' and 'unmark' commands. A new Task class has been
added to represent tasks, encapsulating the task description and
status. The 'list' command now shows the status of each task.
This commit refactors both the chatbot and Task class to comply
with Java coding standards. Javadoc comments have been added for
all methods and classes. The code layout, including indentation,
brace placement, and line length, has been adjusted.
This commit introduces three types of tasks—ToDo, Deadline, and Event—
to the Lia chatbot. Users can now add tasks with or without specific
dates and times. The tasks are displayed with their respective types
and details when listed. The code has been refactored to handle these
task types using inheritance, with each type represented by its own
class.
Changed input.txt and updated the output
with the expected results in EXPECTED.TXT.
This commit refactors the Duke chatbot by extracting the repetitive
task addition and confirmation printing logic into a new method
`addTaskAndPrint()`. This change improves code maintainability and
readability by reducing redundancy in handling "todo", "deadline",
and "event" commands.

@kennethSty kennethSty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your code is well-structured and functional. I’ve added a few comments about coding standards and quality improvements. Specifically, I suggest:

Indentation: Instead of manually inserting whitespace for formatting, consider defining an INDENTATION constant to maintain consistency and readability across your code.

Error Handling: To enhance system stability, especially when dealing with potential user input errors, consider wrapping your return values in an Optional object. This will provide a safer way to handle nulls and unexpected inputs.

Comment thread src/main/java/Lia.java Outdated

public static void main(String[] args) {
// Customizing the chatbot with the name Lia
String logo =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Coding Standard: Logo is constant. Use LOGO

Comment thread src/main/java/Lia.java Outdated
Comment on lines +30 to +31
System.out.println(" Hello! I'm \n" + logo);
System.out.println(" What can I do for you?");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of leaving whitespaces use a constant String with the amount of whitespace and add them as INCIDENTION. This way UI bugs of not using enough whitespace can be avoided.

Comment thread src/main/java/Task.java Outdated
Comment on lines +58 to +132
class ToDo extends Task {

/**
* Creates a new ToDo task with the given description.
*
* @param description A description of the ToDo task.
*/
public ToDo(String description) {
super(description);
}

/**
* Returns a string representation of the ToDo task.
*
* @return A string representing the ToDo task.
*/
@Override
public String toString() {
return "[T]" + super.toString();
}
}

/**
* Represents a Deadline task, which is a task that needs to be done
* before a specific date/time.
*/
class Deadline extends Task {
protected String by;

/**
* Creates a new Deadline task with the given description and deadline.
*
* @param description A description of the task.
* @param by The deadline by which the task must be completed.
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
}

/**
* Returns a string representation of the Deadline task.
*
* @return A string representing the Deadline task.
*/
@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}

/**
* Represents an Event task, which is a task that starts and ends
* at specific dates/times.
*/
class Event extends Task {
protected String start;
protected String end;

/**
* Creates a new Event task with the given description, start, and end times.
*
* @param description A description of the event.
* @param start The start time of the event.
* @param end The end time of the event.
*/
public Event(String description, String start, String end) {
super(description);
this.start = start;
this.end = end;
}

/**
* Returns a string representation of the Event task.
*

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider creating new files for each class.

Comment thread text-ui-test/input.txt
list
deadline return book /by Sunday
list
event project meeting /from Mon 2pm /to 4pm

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

consider adding "wrong user input" to test whether the application breaks if e.g. deadline is used without /by.

Comment thread src/main/java/Lia.java Outdated
printLine();
System.out.println(" Got it. I've added this task:");
System.out.println(" " + task.toString());
System.out.println(" Now you have " + taskCount + " tasks in the list.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done. The feedback to the user is helpful.

wahkia added 16 commits September 9, 2024 16:00
This commit introduces the following changes to comply with Java
coding standards:
- Added a constant 'INDENTATION' for consistent indentation in output.
- Updated the 'LOGO' variable to uppercase as a constant.
- Refactored the code layout for improved readability and maintainability.
This commit restructures the Task class into three specific subclasses.
This change improves code organization and provides clearer modeling
of different task types.
Defined a class LiaException to represent exceptions specific to Lia.
This commit introduces custom error handling for the Lia chatbot
using a LiaException class. Errors such as missing descriptions for
todo tasks and invalid input for deadlines and events are now
handled with user-friendly error messages. Unrecognized commands
also trigger an error response.
This commit ensures that the task class and its subclasses can be packaged
in the future.
This commit organizes the code into two packages:
- `task` package for task-related classes: Task, ToDo, Deadline, Event.
- `exception` package for Lia-specific exceptions: LiaException.

This improves code modularity and structure, making it easier to maintain and extend.
This commit refines how taskCount is handled in the Lia chatbot.
Previously, taskCount was incremented globally after each command,
leading to incorrect task counts for non-task-adding commands like
'list'. Now, taskCount is only incremented when tasks are actually
added ('todo', 'deadline', 'event'), preventing issues like
NullPointerExceptions during subsequent list commands.
This commit updates support for marking and unmarking tasks in the Lia
chatbot with error handling.
This commit replaces the static Task[] array with an ArrayList<Task>
to dynamically handle task creation and management. This change
enhances flexibility in task operations like adding, listing, and
marking tasks, and ensures scalability without the limitations of a
fixed-size array.
This commit introduces support for deleting tasks from the task list.
Users can now enter 'delete <task number>' to remove a specific task.
The remaining tasks are updated, and the user is notified of the
task removal and the current number of tasks.
This commit introduces file persistence to the Lia chatbot, enabling
tasks to be saved to and loaded from a file (./data/lia.txt). Tasks
are automatically saved whenever the task list is modified and loaded
at startup. The system also handles missing files or directories.
This commit enhances the Lia chatbot's ability to handle corrupted or
invalid data in the task file. The system now detects wrong task
entries, skips them, and prints warnings while continuing to load valid
tasks from the file.
# Conflicts:
#	src/main/java/Lia.java

@okkhoy okkhoy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are quite a few opportunities to eliminate arrow-head code. Try to use guard clauses to remove these.

Comment thread src/main/java/Lia.java Outdated

public static void main(String[] args) {
// Customizing the chatbot with the name Lia
String LOGO =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

make it constant?

Comment thread src/main/java/Lia.java Outdated
String input;
ArrayList<Task> tasks = loadTasks(); // Load tasks from file

// Greet the user with enthusiasm

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this looks like a note-to-self comment or a redundant comment; can be removed

Comment thread src/main/java/Lia.java Outdated
saveTasks(tasks);

} catch (LiaException e) {
// Handle any Lia-specific exceptions

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

misleading comment since you are not doing anything specific apart from printing the message.

Comment thread src/main/java/Lia.java Outdated
Path filePath = Paths.get(FILE_PATH);

try {
if (!Files.exists(filePath)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

make this as a guard clause;
eliminate the following arrow-head code

wahkia and others added 3 commits October 10, 2024 18:03
- Extracted Ui, Storage, Parser, and TaskList classes for better organization.
- Implemented Command pattern with specific command classes (AddCommand, DeleteCommand, etc.).
- Enhanced maintainability and readability of the codebase.
Updated load method to parse dates using LocalDateTime.
Added a parseDateTime method for converting date strings to LocalDateTime objects.
Modified save method to ensure task dates are stored in the new format.
Ensured proper error handling for invalid date formats during loading.
Enhance chatBot to support date and time handling
wahkia and others added 11 commits October 10, 2024 19:07
Added FindCommand class to handle task searching.
Updated Parser class to recognize the find command.
Integrated find functionality into the existing command execution flow.
Enhanced UI to display matching tasks to the user.
Implement find command to search for tasks by keyword
Add Javadoc comments for improved code documentation
Add User Guide for Lia chatbot with usage instructions and features
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.

3 participants