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

[chashaobao] iP #640

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 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
60e495d
ip_wk2_level-0
Aug 26, 2024
fddb9e9
ip wk2 level-1
Aug 26, 2024
48f9b91
ip wk2 level-2
Aug 26, 2024
064c6c3
wk2 ip level-3
Aug 31, 2024
97639d6
wk2 level-4
Aug 31, 2024
4f01857
wk2 ip level-5
Aug 31, 2024
1df1350
wk2 ip level-6
Aug 31, 2024
55989ae
add automated-text-ui-testing
Aug 31, 2024
957bf55
add Level-7 changes
Sep 3, 2024
dfae243
update reading and writing of saved tasks
Sep 4, 2024
0dea61f
add date and time for deadline and event
Sep 4, 2024
cd8b26e
abstract more classes
Sep 5, 2024
421974d
abstract out classes
Sep 5, 2024
08746c5
Merge remote-tracking branch 'origin/add-gradle-support'
Sep 5, 2024
ba6a7ef
correct packages
Sep 5, 2024
91afd9e
correctly add packages
Sep 5, 2024
3da8d0b
add JUnit: TaskListTest and UiTest
Sep 5, 2024
fb664fa
add headers
Sep 6, 2024
991b22f
add search function
Sep 6, 2024
6df0184
resolve merge conflicts
Sep 6, 2024
c7862f4
merge branches
Sep 6, 2024
1ee7602
add gui
Sep 6, 2024
5f50efb
add gui
Sep 6, 2024
e73a476
Add assertions
Sep 14, 2024
b01a403
Update packages to follow convention
Sep 14, 2024
5656a9d
Update packages
Sep 14, 2024
620f3de
Merge pull request #2 from chashaobao123/branch-A-Assertions
chashaobao123 Sep 14, 2024
20e7261
Resolve import errors
Sep 14, 2024
e543672
Merge with master
Sep 14, 2024
668af35
Merge pull request #3 from chashaobao123/branch-A-CodeQuality
chashaobao123 Sep 14, 2024
c088340
Add assertions
Sep 14, 2024
78d3987
Merge branch 'master' of github.com:chashaobao123/ip
Sep 14, 2024
1c02284
Merge Level-8 to master
Sep 17, 2024
ac340f4
Merge pull request #4 from chashaobao123/branch-Level-8
chashaobao123 Sep 17, 2024
55d7ca0
Resolved merge conflicts from pull-request
Sep 17, 2024
cd35b95
Add proper headings
Sep 17, 2024
b6f266c
Edit error messages to fit personality
Sep 17, 2024
a0b1e69
Add JUnit tests
Sep 17, 2024
6bf7a93
Update README
Sep 17, 2024
6f02cc0
Update README
Sep 17, 2024
e4dc31b
Add Ui.png to docs folder
Sep 22, 2024
dabdb0b
Update README
Sep 22, 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
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file added .vs/ip/v17/.wsuo
Binary file not shown.
12 changes: 12 additions & 0 deletions .vs/ip/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\65814\\OneDrive\\NUSY2S1\\CS2103T\\IP\\ip\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
3 changes: 3 additions & 0 deletions src/main/java/.vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
6 changes: 6 additions & 0 deletions src/main/java/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file added src/main/java/.vs/java/v17/.wsuo
Binary file not shown.
12 changes: 12 additions & 0 deletions src/main/java/.vs/java/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\65814\\OneDrive\\NUSY2S1\\CS2103T\\IP\\ip\\src\\main\\java\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
Binary file added src/main/java/.vs/slnx.sqlite
Binary file not shown.
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

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

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Task.Deadline;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

Choose a reason for hiding this comment

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

The header comment for the class might be missed out, will be good if it could be added in

public class AddDeadlineCommand extends Command {
private String description;
private String byString;

public AddDeadlineCommand(String description, String byString) {
this.description = description;
this.byString = byString;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
LocalDateTime by;
try {
if (byString.equalsIgnoreCase("today")) {
// Use current date and set time to 23:59
by = LocalDateTime.now().withHour(23).withMinute(59);
} else {
// Try parsing by LocalDateTime
by = LocalDateTime.parse(byString);
}
} catch (DateTimeParseException e) {
// If parsing fails, try parsing as LocalDate and set time to 23:59
try {
LocalDate deadlineDate = LocalDate.parse(byString);
by = deadlineDate.atTime(23, 59);
} catch (DateTimeParseException ex) {
throw new InvalidCommandException("Invalid date format for deadline. Please use 'yyyy-MM-ddTHH:mm' or 'yyyy-MM-dd'.");
}
}

Deadline deadline = new Deadline(this.description, by);
tasks.add(deadline);
ui.showAddedNewTask(deadline, tasks);
storage.save(tasks.getTasks());
}

@Override
public boolean isExit() {
return false;
}
}
70 changes: 70 additions & 0 deletions src/main/java/LittleMissHelpful/Command/AddEventCommand.java

Choose a reason for hiding this comment

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

The header comment for the class and the public methods is also missed out here, would be nice to add in!

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package main.LittleMissHelpful.Command;

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

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Task.Event;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

Choose a reason for hiding this comment

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

The commands naming is named well! Easy to understand what the class is handling!

public class AddEventCommand extends Command {
private final String description;
private final String fromString;
private final String toString;

public AddEventCommand(String description, String fromString, String toString) {
this.description = description;
this.fromString = fromString;
this.toString = toString;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
LocalDateTime from;
LocalDateTime to;

try {
from = parseDateTime(fromString);
to = parseDateTime(toString);

Event event = new Event(description, from, to);
tasks.add(event);
ui.showAddedNewTask(event, tasks);
storage.save(tasks.getTasks());

} catch (DateTimeParseException e) {
throw new InvalidCommandException("Invalid date format. Please use 'yyyy-MM-ddTHH:mm' or 'yyyy-MM-dd'.");
}
}

@Override
public boolean isExit() {
return false;
}

private LocalDateTime parseDateTime(String dateTimeString) throws DateTimeParseException {
/**
* Parses string into LocalDateTime
*/

if (dateTimeString.equalsIgnoreCase("today")) {
// Use current date and set time to 00:00 (start of the day)
return LocalDateTime.now().withHour(00).withMinute(00);
}

Choose a reason for hiding this comment

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

line breaks could be added here to seperate the section and make the code more readabel : )

try {
// Try parsing as LocalDateTime
return LocalDateTime.parse(dateTimeString);
} catch (DateTimeParseException e) {
try {
// If LocalDateTime parsing fails, try parsing as LocalDate
LocalDate date = LocalDate.parse(dateTimeString);
return date.atTime(00, 00);
} catch (DateTimeParseException ex) {
throw ex;
}
}
}
}
28 changes: 28 additions & 0 deletions src/main/java/LittleMissHelpful/Command/AddTodoCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Task.Todo;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class AddTodoCommand extends Command {
private String description;

public AddTodoCommand(String description) {
this.description = description;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
Todo todo = new Todo(description);
tasks.add(todo);
ui.showAddedNewTask(todo, tasks);
storage.save(tasks.getTasks());
}

@Override
public boolean isExit() {
return false;
}
}
11 changes: 11 additions & 0 deletions src/main/java/LittleMissHelpful/Command/Command.java

Choose a reason for hiding this comment

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

missing header comment for the class too

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public abstract class Command {
public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException;
public abstract boolean isExit();
}
34 changes: 34 additions & 0 deletions src/main/java/LittleMissHelpful/Command/DeleteTaskCommand.java

Choose a reason for hiding this comment

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

same as above

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Exception.InvalidTaskFormatException;
import main.LittleMissHelpful.Task.Task;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class DeleteTaskCommand extends Command {
private final int taskIndex;

public DeleteTaskCommand(int taskIndex) {
this.taskIndex = taskIndex;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
try {
Task task = tasks.get(taskIndex);
tasks.delete(taskIndex);
ui.showDeletedTask(task, tasks);
storage.save(tasks.getTasks());

} catch (InvalidTaskFormatException e) {
throw new InvalidCommandException("Task number out of range. Please provide a valid task number.");
}
}

@Override
public boolean isExit() {
return false;
}
}
19 changes: 19 additions & 0 deletions src/main/java/LittleMissHelpful/Command/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class ExitCommand extends Command {
@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
ui.showExit();
storage.save(tasks.getTasks());
}

@Override
public boolean isExit() {
return true;
}
}
22 changes: 22 additions & 0 deletions src/main/java/LittleMissHelpful/Command/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class ListCommand extends Command {
@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
if (tasks.size() == 0) {
ui.showNoTasks();
} else {
ui.showAllTasks(tasks.getTasks());
}
}

@Override
public boolean isExit() {
return false;
}
}
33 changes: 33 additions & 0 deletions src/main/java/LittleMissHelpful/Command/MarkTaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Exception.InvalidTaskFormatException;
import main.LittleMissHelpful.Task.Task;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class MarkTaskCommand extends Command {
private final int taskIndex;

public MarkTaskCommand(int i) {
this.taskIndex = i - 1;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
try {
Task task = tasks.get(this.taskIndex);
tasks.markTask(this.taskIndex);
ui.showMarkedTask(task);
storage.save(tasks.getTasks());
} catch (InvalidTaskFormatException e) {
throw new InvalidCommandException("Task number out of range. Please provide a valid task number.");
}
}

@Override
public boolean isExit() {
return false;
}
}
33 changes: 33 additions & 0 deletions src/main/java/LittleMissHelpful/Command/UnmarkTaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main.LittleMissHelpful.Command;

import main.LittleMissHelpful.Exception.InvalidCommandException;
import main.LittleMissHelpful.Exception.InvalidTaskFormatException;
import main.LittleMissHelpful.Task.Task;
import main.LittleMissHelpful.TaskList;
import main.LittleMissHelpful.Ui;
import main.LittleMissHelpful.Storage;

public class UnmarkTaskCommand extends Command {
private final int taskIndex;

public UnmarkTaskCommand(int i) {
this.taskIndex = i - 1;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws InvalidCommandException {
try {
Task task = tasks.get(this.taskIndex);
tasks.unmarkTask(this.taskIndex);
ui.showUnmarkedTask(task);
storage.save(tasks.getTasks());
} catch (InvalidTaskFormatException e) {
throw new InvalidCommandException("Task number out of range. Please provide a valid task number.");
}
}

@Override
public boolean isExit() {
return false;
}
}

Choose a reason for hiding this comment

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

The exceptions class name is named well to let developer understand what exception it is handling too! Well done!

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main.LittleMissHelpful.Exception;
public class InvalidCommandException extends Exception {
public InvalidCommandException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main.LittleMissHelpful.Exception;
public class InvalidTaskFormatException extends Exception {
public InvalidTaskFormatException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main.LittleMissHelpful.Exception;
public class TaskNotFoundException extends Exception {
public TaskNotFoundException(String message) {
super(message);
}
}
Loading