Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cfe27b7
Add chatbot skeleton
yuhengr Jan 26, 2024
6db6312
Add level 1
yuhengr Feb 2, 2024
efcec81
Add level 2
yuhengr Feb 9, 2024
3440622
Add level 3
yuhengr Feb 9, 2024
cec49c2
Add level 4
yuhengr Feb 9, 2024
55b6be6
Add level 5
yuhengr Feb 22, 2024
a23e514
Add level 5 in branch-Level-5
yuhengr Feb 22, 2024
98de3d5
Add error handling for mark and unmark
yuhengr Feb 22, 2024
b04d05d
Rename variables
yuhengr Feb 22, 2024
43028d3
Change error messages for mark and unmark
yuhengr Feb 22, 2024
c504b93
Merge branch 'branch-Level-5'
yuhengr Feb 22, 2024
894d758
Add skeleton for delete
yuhengr Feb 22, 2024
17b2bac
Add delete feature
yuhengr Feb 22, 2024
f28f0ce
Add level 7 write to file
yuhengr Feb 22, 2024
eb7ebe6
Disable opening logo
yuhengr Feb 22, 2024
0af291b
Merge branch 'branch-Level-6'
yuhengr Feb 22, 2024
ab8d095
Add level 7 read from file
yuhengr Feb 23, 2024
1bb8666
Merge branch-Level-7
yuhengr Mar 6, 2024
2032036
Refactor read from file functionality to a method
yuhengr Mar 6, 2024
e46f8a7
Refactor to remove magic numbers
yuhengr Mar 6, 2024
68e709b
Add storage package skeleton
yuhengr Mar 6, 2024
5a43cbc
Refactor tasks-related classes to package
yuhengr Mar 6, 2024
1e5b368
Modify classes in package task
yuhengr Mar 6, 2024
ff6ffbf
Import package task
yuhengr Mar 6, 2024
accdf6f
Add imports for class Storage
yuhengr Mar 6, 2024
b9139c0
Add class TaskList
yuhengr Mar 6, 2024
616a5d4
Add addTodo method in class TaskList
yuhengr Mar 6, 2024
7622977
Abstract commands into class TaskList
yuhengr Mar 6, 2024
5aa8ebe
Refactor file management into class Storage
yuhengr Mar 7, 2024
3a67fa2
Add package ui
yuhengr Mar 7, 2024
dc65e62
Add messages to class UI
yuhengr Mar 7, 2024
101a9a0
Fix bug that appends additional ) when loading tasks
yuhengr Mar 7, 2024
86e95f3
Refactor ui messages
yuhengr Mar 7, 2024
2e41c85
Modify to handle both upper and lower cases
yuhengr Mar 7, 2024
6af42f4
Add class Parser skeleton
yuhengr Mar 7, 2024
400cc86
Add parseTodo method to class Parser
yuhengr Mar 7, 2024
6738b93
Add methods to parse Deadline and Event to class Parser
yuhengr Mar 7, 2024
6fd592c
Fix bug. Empty Todo description will now be caught.
yuhengr Mar 7, 2024
4c0e67f
Trim user input before adding to tasks
yuhengr Mar 7, 2024
a702714
Refactor error messages
yuhengr Mar 7, 2024
b4baa94
Add Level-9 in branch-Level-9
yuhengr Mar 7, 2024
449d6ca
Merge pull request #1 from yuhengr/branch-Level-9
yuhengr Mar 7, 2024
ea0b2b4
Refactor code
yuhengr Mar 7, 2024
2b97a19
Add A-JavaDoc
yuhengr Mar 7, 2024
6152c52
Merge pull request #2 from yuhengr/branch-A-JavaDoc
yuhengr Mar 8, 2024
f7ab8bc
Add more comments
yuhengr Mar 8, 2024
0428822
Add initial edit for A-UserGuide
yuhengr Mar 8, 2024
ea631e8
Add more JavaDoc comments
yuhengr Mar 8, 2024
ff8bf1e
Edit README.md
yuhengr Mar 8, 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
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{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formatting error with the curly brace!


protected String by;

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

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
69 changes: 69 additions & 0 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.Scanner;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ditto with the comment by your peer. Remove code that is commented out!

Expand All @@ -6,5 +8,72 @@ public static void main(String[] args) {
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";

@webtjs webtjs Feb 9, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should the logo variable be deleted since it's not used?

System.out.println("Hello from\n" + logo);
System.out.println("I'm Ekud! What can I do for you?");

String userInput;
Scanner in = new Scanner(System.in);
Task[] tasks = new Task[100];

Copy link
Copy Markdown

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 plural form to indicate multiple tasks

int taskCount = 0;
userInput = in.nextLine();

while(!userInput.equals("bye")){
String[] words = userInput.split(" ");
if(userInput.equals("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.

This if-else chain is nested and very long. This usually hints that there can be room for improvement for making your code SLAP more.

To aid you in achieving SLAP, here are some guiding questions...

  1. What parts of the code is repetitive? i.e. virtually the same for each if/else block you have
  2. What part of the code does a particular function that can be isolated into a function?

System.out.println("Here are the tasks in your list:");
for(int i = 0; i < taskCount; i++){
System.out.println((i + 1) + "." + tasks[i]);
}
}
else if(words[0].equals("mark")){
int taskIndex = Integer.parseInt(words[1]) - 1;
tasks[taskIndex].markAsDone();
System.out.println("Nice! I've marked this task as done:");
System.out.println(tasks[taskIndex]);
}
else if(words[0].equals("unmark")){
int taskIndex = Integer.parseInt(words[1]) - 1;
tasks[taskIndex].markAsNotDone();
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(tasks[taskIndex]);
}
else if(words[0].equals("todo")){
int dividerPosition = userInput.indexOf(" ");
tasks[taskCount] = new Todo(userInput.substring(dividerPosition + 1));
System.out.println("Got it. I've added this task:");
System.out.println(tasks[taskCount]);
taskCount++;
System.out.println("Now you have " + taskCount + " tasks in the list.");
}
else if(words[0].equals("deadline")){
int dividerPosition = userInput.indexOf(" ");
int slashPosition = userInput.indexOf("/by");
tasks[taskCount] = new Deadline(userInput.substring(dividerPosition + 1, slashPosition - 1), userInput.substring(slashPosition + 4));

@webtjs webtjs Feb 9, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can consider line wrapping for this line also?

System.out.println("Got it. I've added this task:");
System.out.println(tasks[taskCount]);
taskCount++;
System.out.println("Now you have " + taskCount + " tasks in the list.");
}
else if(words[0].equals("event")){
int dividerPosition = userInput.indexOf(" ");
int fromPosition = userInput.indexOf("/from");
int toPosition = userInput.indexOf("/to");

tasks[taskCount] = new Event(userInput.substring(dividerPosition + 1, fromPosition - 1), userInput.substring(fromPosition + 6, toPosition - 1), userInput.substring(toPosition + 4));

@webtjs webtjs Feb 9, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can consider line wrapping? This line seems quite long.

System.out.println("Got it. I've added this task:");
System.out.println(tasks[taskCount]);
taskCount++;
System.out.println("Now you have " + taskCount + " tasks in the list.");
}
else{
tasks[taskCount] = new Todo(userInput);
System.out.println("Got it. I've added this task.");
System.out.println(tasks[taskCount]);
taskCount++;
System.out.println("Now you have " + taskCount + " tasks in the list.");
}
userInput = in.nextLine();
}

System.out.println("Bye. Hope to see you again soon.");
}
}
15 changes: 15 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends 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.

Formatting error with the curly brace!


protected String startTime;
protected String endTime;

public Event(String description, String startTime, String endTime) {
super(description);
this.startTime = startTime;
this.endTime = endTime;
}

public String toString() {
return "[E]" + super.toString() + " (from: " + this.startTime + " to: " + this.endTime + ")";
}
}
26 changes: 26 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getStatusIcon() {
return (isDone ? "X" : " ");
}

public void markAsDone() {
this.isDone = true;
}

public void markAsNotDone() {
this.isDone = false;
}
Comment on lines +10 to +

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Method names are good as they sound like verbs


@Override
public String toString() {
return String.format("[%s] %s", this.getStatusIcon(), this.description);
}
}
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);
}

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