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

[lckjosh] iP #74

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9af57b0
add greeting feature and exit
lckjosh Aug 30, 2023
f35e5e1
rename bot to BotBuddy
lckjosh Aug 30, 2023
c4e3f6e
add echo feature
lckjosh Sep 5, 2023
d219a1f
add ability to add items and list them
lckjosh Sep 5, 2023
2d8c682
create Task class
lckjosh Sep 5, 2023
663cf7c
add ability to mark and unmark tasks as done
lckjosh Sep 5, 2023
87a3330
follow coding standard
lckjosh Sep 5, 2023
e4200c5
categorise tasks into Todo, Event, and Deadline
lckjosh Sep 12, 2023
2a749bc
create methods for each command and call the methods in switch statement
lckjosh Sep 12, 2023
8060406
use do-while loop
lckjosh Sep 12, 2023
bd0006b
add input and output testing
lckjosh Sep 12, 2023
1d647e3
handle unrecognised commands
lckjosh Sep 13, 2023
9e488c2
create BotBuddyException exception
lckjosh Sep 13, 2023
e2e415d
add error handling
lckjosh Sep 13, 2023
704093c
Merge branch 'branch-Level-5'
lckjosh Sep 13, 2023
00bb9a7
put classes in BotBuddy package
lckjosh Sep 13, 2023
a18d4c0
Merge branch 'branch-A-Packages'
lckjosh Sep 13, 2023
3223c2a
rename Duke.java to BotBuddy.java
lckjosh Sep 19, 2023
5637b71
use ArrayList<Task> to store Tasks instead of an array
lckjosh Sep 19, 2023
e1dee36
add ability to delete tasks
lckjosh Sep 19, 2023
713b1a3
Merge branch 'branch-Level-6'
lckjosh Sep 19, 2023
8254280
add ability to save and read from file
lckjosh Sep 19, 2023
995547b
auto create task file and directory if not found
lckjosh Sep 19, 2023
8e41dc0
Merge branch 'branch-Level-7'
lckjosh Sep 19, 2023
722041b
remove duplicate check if directory is created
lckjosh Sep 19, 2023
a9e8f7d
update gitignore
lckjosh Sep 19, 2023
a2c02d8
refactor code to make it more OOP
lckjosh Oct 2, 2023
f95d5a1
add ability to find tasks
lckjosh Oct 4, 2023
3957ae9
Merge pull request #1 from lckjosh/branch-Level-9
lckjosh Oct 4, 2023
2868ee6
updated list of supported commands
lckjosh Oct 4, 2023
1ec406b
update README
lckjosh Oct 4, 2023
ff1c2ca
fix READMEs
lckjosh Oct 4, 2023
51145c6
add javadocs
lckjosh Oct 6, 2023
690e241
edit javadoc
lckjosh Oct 6, 2023
59e9b5e
Merge pull request #2 from lckjosh/A-JavaDoc
lckjosh Oct 6, 2023
54dd0f9
edit javadocs
lckjosh Oct 6, 2023
63a2454
Merge pull request #3 from lckjosh/branch-A-JavaDoc
lckjosh Oct 6, 2023
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
Prev Previous commit
Next Next commit
categorise tasks into Todo, Event, and Deadline
lckjosh committed Sep 12, 2023
commit e4200c5476d64a228206c6572516de62caaae824
14 changes: 14 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Deadline extends Task {

protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
49 changes: 42 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -22,6 +22,44 @@ public static void main(String[] args) {
}

switch (command) {
case "todo":
// add todo
tasks[noOfTasks] = new Todo(parameters);
System.out.println("____________________________________________________________");
System.out.println("Got it, I've added this task:");
System.out.println(tasks[noOfTasks]);
System.out.println("____________________________________________________________");
noOfTasks++;
break;

case "event":
// add event
String[] eventDetails = parameters.split("/from");
String eventName = eventDetails[0].trim();
eventDetails = eventDetails[1].split("/to");
String eventFrom = eventDetails[0].trim();
String eventTo = eventDetails[1].trim();
tasks[noOfTasks] = new Event(eventName, eventFrom, eventTo);
System.out.println("____________________________________________________________");
System.out.println("Got it, I've added this task:");
System.out.println(tasks[noOfTasks]);
System.out.println("____________________________________________________________");
noOfTasks++;
break;

case "deadline":
// add deadline
String[] deadlineDetails = parameters.split("/by");
String deadlineName = deadlineDetails[0].trim();
String deadlineBy = deadlineDetails[1].trim();
tasks[noOfTasks] = new Deadline(deadlineName, deadlineBy);
System.out.println("____________________________________________________________");
System.out.println("Got it, I've added this task:");
System.out.println(tasks[noOfTasks]);
System.out.println("____________________________________________________________");
noOfTasks++;
break;

case "list":
if (noOfTasks == 0) {
System.out.println("____________________________________________________________");

Choose a reason for hiding this comment

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

Consider using a constant / final variable to represent the line divider

@@ -32,7 +70,7 @@ public static void main(String[] args) {
// print out tasks
System.out.println("____________________________________________________________");
for (int i = 0; i < noOfTasks; i++) {
System.out.println(i + 1 + ". " + tasks[i].getStatusIcon() + " " + tasks[i].getDescription());
System.out.println(i + 1 + ". " + tasks[i]);
}
System.out.println("____________________________________________________________");
break;
@@ -42,7 +80,7 @@ public static void main(String[] args) {
tasks[taskToMark].markAsDone();
System.out.println("____________________________________________________________");
System.out.println("I've marked this task as done:");
System.out.println(tasks[taskToMark].getStatusIcon() + " " + tasks[taskToMark].getDescription());
System.out.println(tasks[taskToMark]);
System.out.println("____________________________________________________________");
break;

@@ -51,7 +89,7 @@ public static void main(String[] args) {
tasks[taskToUnmark].markAsUndone();
System.out.println("____________________________________________________________");
System.out.println("I've unmarked this task:");
System.out.println(tasks[taskToUnmark].getStatusIcon() + " " + tasks[taskToUnmark].getDescription());
System.out.println(tasks[taskToUnmark]);
System.out.println("____________________________________________________________");
break;

@@ -63,11 +101,8 @@ public static void main(String[] args) {
return;

default:
// add task
tasks[noOfTasks] = new Task(input);
noOfTasks++;
System.out.println("____________________________________________________________");
System.out.println("added: " + tasks[noOfTasks - 1].getDescription());
System.out.println("Invalid command!");
System.out.println("____________________________________________________________");
break;
}
16 changes: 16 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Event extends Task {

protected String from;
protected String by;

public Event(String description, String from, String by) {
super(description);
this.from = from;
this.by = by;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + from + " to: " + by + ")";
}
}
7 changes: 6 additions & 1 deletion src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Task {
public abstract class Task {
protected String description;
protected boolean isDone;

@@ -26,4 +26,9 @@ public void markAsDone() {
public void markAsUndone() {
isDone = false;
}

@Override
public String toString() {
return getStatusIcon() + " " + getDescription();
}
}
10 changes: 10 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Todo extends Task {
public Todo(String description) {
super(description);
}

@Override
public String toString() {
return "[T]" + super.toString();
}
}