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

[rithanisk] iP #628

Open
wants to merge 146 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
68c58c1
Add Gradle support
May 24, 2020
03523ec
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
81a9c53
build.gradle: Prevent generating a second JAR file
aureliony Jul 16, 2024
cbdfbef
Implement chatbot greeting and goodbye functions
rithanisk Aug 21, 2024
f5d0ce4
Add Level 1
rithanisk Aug 22, 2024
6337950
Add Task class
rithanisk Aug 23, 2024
385c024
Add TaskList class
rithanisk Aug 23, 2024
e0259a6
Add getTaskListLength() method
rithanisk Aug 23, 2024
57d0f52
Add displayList() method
rithanisk Aug 23, 2024
aaa66e6
Add addTask() method to add a new task to the taskList
rithanisk Aug 23, 2024
88a4cc0
Add Level 2
rithanisk Aug 23, 2024
02ca5a8
Add isDone() method to Task
rithanisk Aug 23, 2024
8198949
Add markTask method to mark a task in the task list
rithanisk Aug 23, 2024
942f9dd
Add unmarkTask to unmark a task from the task list
rithanisk Aug 23, 2024
c9cc960
Modify comments for all public methods
rithanisk Aug 23, 2024
ed638cd
Refactor code that displays newly added task
rithanisk Aug 23, 2024
d147984
Add Todo class
rithanisk Aug 23, 2024
85169c3
Add Deadline class
rithanisk Aug 23, 2024
b82909a
Add Event class
rithanisk Aug 23, 2024
372acbc
Add toString method to Task class
rithanisk Aug 23, 2024
5ec62b2
Add toString() method to subclasses of Task class
rithanisk Aug 23, 2024
1df07c6
Handle Todo task command
rithanisk Aug 23, 2024
371d156
Handle Deadline task command
rithanisk Aug 23, 2024
7102fb8
Modify string in displayList() method
rithanisk Aug 23, 2024
d82a6df
Handle Event task command
rithanisk Aug 23, 2024
6ac738f
Add comments for all public methods
rithanisk Aug 24, 2024
ae44114
Change expected output from Duke's output to Nebula's output
rithanisk Aug 30, 2024
37590d3
Update EXPECTED.TXT with expected output
rithanisk Aug 31, 2024
4c846fd
Update input.txt with input commands
rithanisk Aug 31, 2024
031de66
Update runtest.sh for testing
rithanisk Aug 31, 2024
23c3b7c
Add NebulaException class
rithanisk Aug 31, 2024
4c10cf4
Add validateCommand() method to handle incorrect user input
rithanisk Sep 1, 2024
14df377
Update TaskList class to store tasks in ArrayList
rithanisk Sep 1, 2024
afc1c44
Refactor text UI testing code
rithanisk Sep 1, 2024
87c6085
Add deleteTask() method to TaskList
rithanisk Sep 1, 2024
53225a6
Add displayDeletedTask() method to Ui class
rithanisk Sep 1, 2024
2dd1625
Add TaskType Enum
rithanisk Sep 1, 2024
22b2545
Update Nebula class to use TaskType enum
rithanisk Sep 1, 2024
ac61409
Add javadoc comments to Nebula and NebulaException methods
rithanisk Sep 2, 2024
364473c
Add comment for TaskType enum
rithanisk Sep 13, 2024
5cc28dc
Add getSymbol() method to all TaskTypes
rithanisk Sep 14, 2024
e0191a5
Update getTaskSymbol methods in Task subclasses
rithanisk Sep 14, 2024
3de59c4
Add saveTaskListToTextFile method
rithanisk Sep 14, 2024
7986baa
Add getter methods for Deadline and Event class
rithanisk Sep 14, 2024
42c8bb6
Complete saveTaskListToTextFile method
rithanisk Sep 14, 2024
d966dfd
Update main to save tasks to text file
rithanisk Sep 14, 2024
6d1e44f
Add constructor to TaskList class
rithanisk Sep 14, 2024
1e8ac52
Update main to check whether taskList file exists in data folder
rithanisk Sep 14, 2024
292415c
Add space in Deadline toString method
rithanisk Sep 14, 2024
5b58896
Add textFileToArrayList method to read from existing taskList
rithanisk Sep 14, 2024
8adff34
Merge branch-Level-7 with merge commit
rithanisk Sep 14, 2024
a727c43
Add javadoc comments to Level-7 methods
rithanisk Sep 14, 2024
ebeac23
Add parseDateTimeOrDate method and format deadline as LocalDateTime
rithanisk Sep 14, 2024
0d87cc6
Update getDeadline method to output deadline in specific format
rithanisk Sep 14, 2024
a81eaec
Add parseDateTimeOrDate method and format start and end as LocalDateTime
rithanisk Sep 14, 2024
aa54427
Update getStart and getEnd to output start and end in specific format
rithanisk Sep 14, 2024
907b121
Define format for user inputted date and generated output date
rithanisk Sep 14, 2024
a22041e
Update validateCommand to handle when date is entered with wrong format
rithanisk Sep 14, 2024
9656fdb
Add convertDate method to parse the dates from taskList txt file
rithanisk Sep 14, 2024
cdf8123
Add javadoc comments to Level-8 methods
rithanisk Sep 14, 2024
8be7a20
Merge branch-Level-8 with merge commit
rithanisk Sep 14, 2024
b5175de
Add Storage class
rithanisk Sep 14, 2024
6e1250c
Update TaskList constructor
rithanisk Sep 14, 2024
3881d59
Update Nebula class to follow OOP
rithanisk Sep 14, 2024
fe065fc
Add Command abstract class and subclasses
rithanisk Sep 14, 2024
125b1fc
Add new Command subclasses
rithanisk Sep 14, 2024
29e0933
Add AddDeadlineCommand class
rithanisk Sep 14, 2024
9207521
Add AddEventCommand class
rithanisk Sep 14, 2024
a0edf47
Add AddTodoCommand class
rithanisk Sep 14, 2024
d3bd7f7
Add ByeCommand class
rithanisk Sep 14, 2024
f4d751c
Update Command abstract class
rithanisk Sep 14, 2024
1d59c3d
Add DeleteCommand class
rithanisk Sep 14, 2024
8c213cc
Add ListCommand class
rithanisk Sep 14, 2024
51b805f
Add MarkCommand class
rithanisk Sep 14, 2024
bb48a6c
Add UnmarkCommand class
rithanisk Sep 14, 2024
7d128d1
Update Ui class methods to remove divider
rithanisk Sep 14, 2024
5e1033a
Add Parser class
rithanisk Sep 14, 2024
60c19a6
Refactor code in Neubla class
rithanisk Sep 14, 2024
44cc1e0
Merge branch-A-MoreOOP with merge commit
rithanisk Sep 14, 2024
b78f02b
Organize classes into suitable java packages
rithanisk Sep 14, 2024
d316c2c
Merge branch-A-Packages with merge commit
rithanisk Sep 14, 2024
907af5c
Merge add-gradle-support with merge commit
rithanisk Sep 14, 2024
c9ff9e2
Add EventTest file to test Event class methods
rithanisk Sep 15, 2024
07e8a3d
Add createEvent_success method to EventTest
rithanisk Sep 15, 2024
a2bfd7e
Add assertEquals to test event without time in createEvent_success
rithanisk Sep 15, 2024
4945fdb
Add createEvent_failure method to EventTest
rithanisk Sep 15, 2024
cd33e2f
Add assertEquals to test event with only end time in EventTest
rithanisk Sep 15, 2024
cb06003
Add AddTodoCommandTest class to test AddTodoCommand class methods
rithanisk Sep 15, 2024
cbc0da1
Add addTodo_success method to AddTodoCommandTest class
rithanisk Sep 15, 2024
4b5ce1b
Add ParserTest class to test parse method
rithanisk Sep 15, 2024
28fea11
Merge branch-A-JUnit with merge commit
rithanisk Sep 15, 2024
a77f817
Update dependencies in build.gradle file
rithanisk Sep 15, 2024
30e2ab3
Merge branch-A-Jar with merge commit
rithanisk Sep 15, 2024
eb5747a
Add JavaDoc comments for Ui Parser and Nebula classes
rithanisk Sep 15, 2024
50fee28
Add JavaDoc comments for TaskList class
rithanisk Sep 15, 2024
030fd98
Add JavaDoc comments for Storage class
rithanisk Sep 15, 2024
96be4ec
Add JavaDoc comments to all the Command classes
rithanisk Sep 15, 2024
313f97b
Added whitespace between lines in Command classes
rithanisk Sep 15, 2024
5f3747f
Reduce code line length to be less than 100 characters
rithanisk Sep 15, 2024
74a4e00
Add FindCommand class
rithanisk Sep 16, 2024
a7830a2
Update getTask method to return Task
rithanisk Sep 16, 2024
72bda1d
Update validateCommand method to handle find command
rithanisk Sep 16, 2024
2604679
Update Ui class with methods to print find command output
rithanisk Sep 16, 2024
b79bf08
Merge pull request #2 from rithanisk/branch-A-JavaDoc
rithanisk Sep 16, 2024
f92948d
Merge branch 'master' into branch-A-CodingStandard
rithanisk Sep 16, 2024
2df5036
Merge branch 'master' into branch-Level-9
rithanisk Sep 16, 2024
5ddc219
Merge pull request #3 from rithanisk/branch-A-CodingStandard
rithanisk Sep 16, 2024
6803d36
Merge branch 'master' into branch-Level-9
rithanisk Sep 16, 2024
06e8d99
Merge pull request #4 from rithanisk/branch-Level-9
rithanisk Sep 16, 2024
9b68d4e
Add basic Hello World GUI with JavaFX
rithanisk Sep 16, 2024
bb9e0e7
Add user input functionality in GUI
rithanisk Sep 16, 2024
a7aae71
Create basic GUI for Nebula chatbot
rithanisk Sep 16, 2024
f409bd2
Add automatic reize elements functionality to GUI
rithanisk Sep 17, 2024
556523d
Add css style to JavaFX files
rithanisk Sep 17, 2024
269c838
Add margins and padding to text message
rithanisk Sep 17, 2024
6e23335
Remove divider from GUI
rithanisk Sep 18, 2024
32eba93
Add assertions to Nebula class
rithanisk Sep 22, 2024
b5cb65e
Add assert statements to Parser class
rithanisk Sep 22, 2024
cbaf565
Add assertion statements to classes in task package
rithanisk Sep 22, 2024
243f1da
Fix spacing in Ui class
rithanisk Sep 23, 2024
e4c31d9
Refactor validateCommand method in Parser class
rithanisk Sep 23, 2024
d2218fb
Delete comment in MainWindow
rithanisk Sep 23, 2024
3a9d438
Storage class: refactor task creation logic into separate methods
rithanisk Sep 23, 2024
af6adf7
Remove comments in FindCommand execute method
rithanisk Sep 23, 2024
d71f6fd
Delete whitespace in Parser class
rithanisk Sep 23, 2024
4157321
Add semicolon to assert statement
rithanisk Sep 23, 2024
5e9dbed
Merge pull request #5 from rithanisk/branch-A-Assertions
rithanisk Sep 23, 2024
b39d2aa
Merge branch 'master' into branch-A-CodeQuality
rithanisk Sep 23, 2024
2fb065c
Merge pull request #6 from rithanisk/branch-A-CodeQuality
rithanisk Sep 23, 2024
d8aaf7c
Add HelpCommand class
rithanisk Sep 23, 2024
0dd1d21
Update Parser to handle help command
rithanisk Sep 23, 2024
6d8ccf5
Add displayCommands method to Ui class for help command execution
rithanisk Sep 23, 2024
a144c16
Change profile pictures of Nebula and user
rithanisk Sep 23, 2024
97e1e1b
Change color scheme of chatbot
rithanisk Sep 23, 2024
8e43074
Update ui for displayCommands method
rithanisk Sep 23, 2024
bf82caf
Add error handling logic for empty task description
rithanisk Sep 23, 2024
052aee3
Improve code quality in Nebula and Parser classes
rithanisk Sep 23, 2024
940e0b6
Add JavaDoc comments to Ui class
rithanisk Sep 23, 2024
cbbb28e
Add JavaDoc comments to Parser class
rithanisk Sep 23, 2024
6b571cc
Add JavaDoc comments for Ui classes
rithanisk Sep 23, 2024
8f2e0aa
Storage class: Add Javadoc comments to methods
rithanisk Sep 23, 2024
eb08763
Replace 'Duke' with 'Nebula'
rithanisk Sep 23, 2024
d4a7a47
Add JavaDoc comments to FindCommand and HelpCommand classes
rithanisk Sep 23, 2024
8d6cf46
Add screenshot of chatbot GUI to docs folder
rithanisk Sep 23, 2024
2df71b8
Add user guide for Nebula chatbot
rithanisk Sep 23, 2024
6c09883
Update product screenshot path
rithanisk Sep 23, 2024
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
25 changes: 25 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class Deadline extends Task {
/**
* Constructs a Deadline task with the specified description and deadline
*
* @param description The description of the task provided by the user
* @param deadline The deadline of the task provided by the user
*/
private String deadline;
public Deadline(String description, String deadline) {
super(description);
this.deadline = deadline;
}

/**
* Returns a string representation of the Deadline object.
* The string includes a "[D]" prefix to indicate that this is a Deadline task,

Choose a reason for hiding this comment

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

Good that you have included a javadoc for the modified toString() method even though it is not required to. According to coding standards maybe you could consider to remove the @return line and only provide additional details about your modification

* followed by the string representation provided by the Task superclass.
*
* @return A string in the format: "[D] <super.toString()>"
*/
@Override
public String toString() {
return "[D] " + super.toString() + "(by: " + this.deadline + ")";
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

29 changes: 29 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class Event extends Task {
private String start;
private String end;

/**
* Constructs an Event task with the specified description, start time, and end time
*
* @param description The description of the task provided by the user
* @param start The start time of the task provided by the user
* @param end The end time of the task provided by the user
*/
public Event(String description, String start, String end) {
super(description);
this.start = start;
this.end = end;
}

/**
* Returns a string representation of the Event object.
* The string includes a "[E]" prefix to indicate that this is an Event task,
* followed by the string representation provided by the Task superclass.
*
* @return A string in the format: "[E] <super.toString()>"
*/
@Override
public String toString() {
return "[E] " + super.toString() + " (from: " + start + " to: " + end + ")";
}
}
189 changes: 189 additions & 0 deletions src/main/java/Nebula.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import java.util.Scanner;

public class Nebula {
/**
* Entry point of the application. Initializes the UI, task list, and parser,
* then processes user commands in a loop until "bye" is entered
*
* @param args command-line arguments (not used)
*/
public static void main(String[] args) {
Ui ui = new Ui();
TaskList taskList = new TaskList();
Parser parser = new Parser();

System.out.println(ui.greeting());

Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
String command = sc.nextLine();

if(command.equals("bye")) {
System.out.println(ui.goodbye());
break;
}

else if(command.equals("list")) {
System.out.println(ui.displayList());
}

else if(command.startsWith("mark")) {
try {
validateCommand(command, taskList);
} catch (NebulaException e) {
System.out.println(e.getMessage());
continue;
}
int taskNum = parser.splitCommandAndTaskNumber(command);
System.out.println(taskList.markTask(taskNum));
}

else if(command.startsWith("unmark")) {
try {
validateCommand(command, taskList);
} catch (NebulaException e) {
System.out.println(e.getMessage());
continue;
}
int taskNum = parser.splitCommandAndTaskNumber(command);
System.out.println(taskList.unmarkTask(taskNum));
}

else if(command.startsWith("delete")) {
try {
validateCommand(command, taskList);
} catch (NebulaException e) {
System.out.println(e.getMessage());
continue;
}
int taskNum = parser.splitCommandAndTaskNumber(command);
System.out.println(taskList.deleteTask(taskNum));
}

else {
try {
validateCommand(command, taskList);
} catch (NebulaException e) {
System.out.println(e.getMessage());
continue;
}

TaskType taskType = parseTaskType(command);

switch (taskType) {

Choose a reason for hiding this comment

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

Good us of switch and case. But the indentation level of switch and case should be the same according to the coding standard that we adhere to.

case TODO:
String taskDescription = parser.splitCommandAndTaskDescription(command);
Task newTodo = new Todo(taskDescription);
String addedTodo = taskList.addTask(newTodo);
System.out.println(addedTodo);
break;

case DEADLINE:
String taskInformation = parser.splitCommandAndTaskDescription(command);
String taskDescriptionDeadline = parser.splitDeadlineCommand(taskInformation)[0];
String taskDeadline = parser.splitDeadlineCommand(taskInformation)[1];
Task newDeadline = new Deadline(taskDescriptionDeadline, taskDeadline);
String addedDeadline = taskList.addTask(newDeadline);
System.out.println(addedDeadline);
break;

case EVENT:
String taskInfo = parser.splitCommandAndTaskDescription(command);
String taskDescriptionEvent = parser.splitEventCommand(taskInfo)[0];
String startInfo = parser.splitEventCommand(taskInfo)[1];
String endInfo = parser.splitEventCommand(taskInfo)[2];

String taskStart = parser.splitCommandAndTaskDescription(startInfo);
String taskEnd = parser.splitCommandAndTaskDescription(endInfo);

Task newEvent = new Event(taskDescriptionEvent, taskStart, taskEnd);
String addedEvent = taskList.addTask(newEvent);
System.out.println(addedEvent);
break;

case UNKNOWN:
System.out.println("Unknown command type.");
break;
}

}

}


}

/**
* Validates the user's input for the correct format and content
*
* @param command the user input command
* @param taskList the current list of tasks
* @throws NebulaException if the command is invalid or improperly formatted
*/
public static void validateCommand(String command, TaskList taskList) throws NebulaException {

Choose a reason for hiding this comment

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

Used verb for method. Good.

Parser parser = new Parser();
Ui ui = new Ui();

if (command.isEmpty()) {
throw new NebulaException("Please enter a command!");
} else if (!(command.startsWith("todo") || command.startsWith("deadline")
|| command.startsWith("event") || command.startsWith("mark")
|| command.startsWith("unmark") || command.startsWith("delete")
|| command.startsWith("list") || command.startsWith("bye"))) {
throw new NebulaException(ui.displayUnknownCommandException());
} else if (command.startsWith("mark") || command.startsWith("unmark") || command.startsWith("delete")) {
String[] parts = command.split(" ", 2);
if (parts.length < 2 || parts[1].trim().isEmpty()) {
throw new NebulaException(ui.displayUnknownTaskNumberException());
}
try {
int taskIndex = Integer.parseInt(parts[1].trim()) - 1; // Convert to 0-based index
if (taskIndex < 0 || taskIndex >= TaskList.getTaskListLength()) {
throw new NebulaException(ui.displayNonexistentTaskNumberException());
}
} catch (NumberFormatException e) {
throw new NebulaException(ui.displayUnknownTaskNumberException());
}
} else {
String[] parts = command.split(" ", 2);
if (parts.length < 2 || parts[1].trim().isEmpty()) {
throw new NebulaException(ui.displayUnknownMessageException());
}

String description = parts[1].trim();

if (command.startsWith("deadline")) {
if (!description.contains("/by")) {
throw new NebulaException(ui.displayUnknownDeadlineException());
}
} else if (command.startsWith("event")) {
if (!description.contains("/from") || !description.contains("/to")) {
throw new NebulaException(ui.displayUnknownEventTimingException());
}
}
}
}

/**
* Determines the TaskType based on the command prefix
*
* @param command the input command string
* @return the corresponding TaskType, or unknown TaskType if unrecognized
*/
public static TaskType parseTaskType(String command) {
if (command.startsWith("todo")) {
return TaskType.TODO;
} else if (command.startsWith("deadline")) {
return TaskType.DEADLINE;
} else if (command.startsWith("event")) {
return TaskType.EVENT;
} else {
return TaskType.UNKNOWN;
}
}





}
10 changes: 10 additions & 0 deletions src/main/java/NebulaException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class NebulaException extends Exception {
/**
* Constructs a NebulaException with the specified error message
*
* @param error The String description of the error message
*/
public NebulaException(String error) {
super(error);
}
}
43 changes: 43 additions & 0 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public class Parser {

Choose a reason for hiding this comment

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

Used noun for class. Good.

/**
* Splits the command string to extract the task number
*
* @param command The command string containing the command and task number
* @return The task number as an integer
*/
public int splitCommandAndTaskNumber(String command) {
String taskNum = command.split(" ", 2)[1];
return Integer.parseInt(taskNum);
}

/**
*
* @param command The command string containing the command and task description
* @return The task description as a String
*/
public String splitCommandAndTaskDescription(String command) {

Choose a reason for hiding this comment

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

Good naming convention followed


return command.split(" ", 2)[1];
}

/**
*
* @param command The command string containing the command, task description, and deadline
* @return The task deadline as a String
*/
public String[] splitDeadlineCommand(String command) {

return command.split("/by ", 2);
}

/**
*
* @param command The command string containing the command, task description,
* event start time, and event end time
* @return The event start and end time as a String
*/
public String[] splitEventCommand(String command) {

return command.split(" /", 3);
}
}
62 changes: 62 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
public class Task {
private final String description;
private boolean isDone;

/**
* Constructs a Task with the specified description
* The task is initialized with the given description and is marked as not done
*
* @param description The description of the task provided by the user
*/
public Task (String description) {
this.description = description;
this.isDone = false;
}

/**
* Returns the description of this task
*
* @return The description of the task
*/
public String getDescription() {
return this.description;
}

/**
* Checks if the task has been completed
*
* @return true if the task is completed, false otherwise
*/
public boolean isDone() {
return this.isDone;
}

/**
* Sets the completion status of the task
*
* @param isDone true to mark the task as completed, false to mark it as not completed
*/
public void setDone(boolean isDone) {
this.isDone = isDone;
}

/**
* Returns the status icon representing the completion state of the task
* Returns "X" if the task is completed, otherwise returns " "
*
* @return A string representing the status icon of the task
*/
public String getStatusIcon() {
return isDone ? "X" : " ";
}

/**
* Returns a string representation of the object which includes the
* status icon and the description of the object
*
* @return A string in the format: "[<statusIcon>] <description>"
*/
public String toString() {
return "[" + getStatusIcon() + "] " + getDescription();
}
}
Loading