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

[shawnpong] iP #178

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
55f9f9f
docs/README.md: Tweak document template
Jan 7, 2024
f837ddb
Add Gradle support
May 24, 2020
a6f7324
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
acf8fdf
Added name for my chatbot
shawnpong Feb 1, 2024
623f216
Added echo functionality for George
shawnpong Feb 1, 2024
46afd35
Added list tracking functionality
shawnpong Feb 2, 2024
66efd52
Added mark, unmark functionality
shawnpong Feb 2, 2024
8cb1b88
Changed bot name, abide by coding standard
shawnpong Feb 2, 2024
a37a35f
Add Task class
shawnpong Feb 8, 2024
5195542
Add Task,ToDo, Deadline class
shawnpong Feb 8, 2024
118c2de
Follow coding standard
shawnpong Feb 8, 2024
0e1e695
Add methods to handle different tasks
shawnpong Feb 14, 2024
ea1adcb
Add exception handling
shawnpong Feb 15, 2024
2d89f52
Fix bugs
shawnpong Feb 15, 2024
190535f
Merge remote-tracking branch 'origin/add-gradle-support' into branch-…
shawnpong Feb 15, 2024
14cbebb
Revert "Bump gradle and lib version"
shawnpong Feb 15, 2024
f6e276f
Merge remote-tracking branch 'origin/add-gradle-support'
shawnpong Feb 15, 2024
a2c95c2
Revert "Bump gradle and lib version"
shawnpong Feb 15, 2024
3fd63f3
Merge branch 'master' into branch-Level-5
shawnpong Feb 15, 2024
52ab77b
Remove files
shawnpong Feb 15, 2024
4894ef2
Level-5
shawnpong Feb 16, 2024
3992ded
Merge branch 'branch-Level-5'
shawnpong Feb 16, 2024
4293c01
Add more exception handling
shawnpong Feb 20, 2024
a67bf9b
Implement ArrayList for dynamic array handling
shawnpong Feb 20, 2024
46d6cc1
Add save functionality, gitignore list data
shawnpong Feb 21, 2024
d3003ef
Add gitignore
shawnpong Feb 21, 2024
0c702d7
Merge branch 'branch-Level-7'
shawnpong Feb 21, 2024
aa38640
Merge branch 'branch-Level-6'
shawnpong Feb 21, 2024
2288a85
Fix bugs with regard to using ArrayList
shawnpong Feb 21, 2024
db336b4
Add Parser, Storage, TaskList, Ui classes
shawnpong Feb 29, 2024
c8b6a97
Add Find functionality
shawnpong Feb 29, 2024
c6a0097
Merge branch 'branch-Level-9'
shawnpong Feb 29, 2024
e7bc46d
Add JavaDoc to code
shawnpong Feb 29, 2024
19e3ebf
Add branch
shawnpong Mar 4, 2024
f45955d
Merge branch 'master' into branch-Level-9
shawnpong Mar 4, 2024
02ec784
Merge pull request #1 from shawnpong/branch-Level-9
shawnpong Mar 4, 2024
6f0f9e7
Testing README
shawnpong Mar 5, 2024
00aadd0
Testing README
shawnpong Mar 5, 2024
8d5f63a
Add README user guide
shawnpong Mar 5, 2024
c7abf86
Update README with colours!
shawnpong Mar 5, 2024
bb716bf
Change README colours
shawnpong Mar 5, 2024
8dc40dc
Add javadoc for ToDo
shawnpong Mar 7, 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 {

protected String by;

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

@Override

Choose a reason for hiding this comment

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

Great use of Override annotation to signal method overriding

public String toString() {
return "[D] " + super.getStatusIcon() + " " + super.toString() + " (by: " + by + ")";
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/java/Events.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Events extends Task {

protected String from;
protected String to;

public Events(String description, String from, String to) {
super(description);
this.from = from;
this.to = to;
}

@Override
public String toString() {
return "[E] " + super.getStatusIcon() + " " + super.toString() + " (from: " + from + " to: " + to + ")";
}
}
83 changes: 83 additions & 0 deletions src/main/java/Floda.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import java.util.Scanner;

Choose a reason for hiding this comment

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

I like how you specified java.util.Scanner instead of java.util.* , this complies with coding standards, well done !


public class Floda {
public static void main(String[] args) {
shawnpong marked this conversation as resolved.
Show resolved Hide resolved
String name = "Floda";

Choose a reason for hiding this comment

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

Redundant code as it can be combined with the next line
eg. System.out.println("Hello! I'm Floda");

Choose a reason for hiding this comment

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

Should this be a constant? And if it was then perhaps you could have used (public static final string) and capitalised the variable name (NAME) to follow the coding standards.

System.out.println("Hello! I'm " + name);
Task[] list = new Task[100];
int taskCounter = 0;
Scanner scanner = new Scanner(System.in);
String line;
System.out.println("I can keep track of a to-do list for you! Just type what you want to add to the list.");
while (!"bye".equals((line = scanner.nextLine()))) {

Choose a reason for hiding this comment

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

It would improve readability if you directly assigned String line = scanner.nextLine() in the previous line instead of assigning it inside the conditional for the while loop. Then you could read in a new line of input at the end of every if else block.

if ("list".equals(line)) {
System.out.println("List so far: ");
for (int i = 0; i < taskCounter; i++) {
System.out.println((i + 1) + "." + list[i]);
}
} else if (line.startsWith("mark")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
if (taskScanner.hasNextInt()) {
int taskNumber = taskScanner.nextInt() - 1;
if (taskNumber >= 0 && taskNumber < taskCounter) {
list[taskNumber].setDone(true);
System.out.println("I have marked this task as done:\n" + list[taskNumber]);
} else {
System.out.println("Invalid task number! Please check with 'list'.");

Choose a reason for hiding this comment

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

Perhaps you could refactor the code into smaller methods that handle the logic without having to have so many levels of nesting, this would make the code more readable.

}
} else {

Choose a reason for hiding this comment

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

Avoid arrowhead style code

System.out.println("Invalid input! Please check with 'list'.");
}
} else if (line.startsWith("unmark")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
if (taskScanner.hasNextInt()) {
int taskNumber = taskScanner.nextInt() - 1;
if (taskNumber >= 0 && taskNumber < taskCounter) {
list[taskNumber].setDone(false);
System.out.println("I have marked this task as not done:\n" + list[taskNumber]);
} else {
System.out.println("Invalid task number! Please check with 'list'.");
}
} else {
System.out.println("Invalid input! Please check with 'list'.");
}
} else if (line.startsWith("deadline")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
String remaining = taskScanner.nextLine().trim();
String[] parts = remaining.split("/by");
String description = parts[0].trim();
String by = parts[1].trim();
list[taskCounter] = new Deadline(description, by);
taskCounter++;
System.out.println("Added: " + list[taskCounter - 1] + "\nNow you have " + (taskCounter) + " items in the list!");
} else if (line.startsWith("todo")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
String remaining = taskScanner.nextLine().trim();
list[taskCounter] = new ToDo(remaining);
taskCounter++;
System.out.println("Added: " + list[taskCounter - 1] + "\nNow you have " + (taskCounter) + " items in the list!");
} else if (line.startsWith("event")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
String remaining = taskScanner.nextLine().trim();
remaining = remaining.replace("/to", "/from");
String[] parts = remaining.split("/from");
String description = parts[0].trim();
String from = parts[1].trim();
String to = parts[2].trim();
list[taskCounter] = new Events(description, from, to);
taskCounter++;
System.out.println("Added: " + list[taskCounter - 1] + "\nNow you have " + (taskCounter) + " items in the list!");
} else {
list[taskCounter] = new Task(line);
taskCounter++;
System.out.println("Added: " + line + "\nNow you have " + (taskCounter) + " items in the list!");
}
}
System.out.println("Bye. Hope to see you again soon!");
}
}
34 changes: 34 additions & 0 deletions src/main/java/Task.java

Choose a reason for hiding this comment

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

Could consider refactoring to use separate methods to handle individual command types. For example, if the command is "event" you could use a handleEventInput() method to parse the string and add the object to the list. This will improve readability considerably.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
public class Task {
protected String description;
protected boolean isDone;

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public boolean isDone() {

Choose a reason for hiding this comment

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

I like how the boolean method isDone is namd to sound like a boolean!

return isDone;
}

public void setDone(boolean done) {
isDone = done;
}

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

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

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

public ToDo(String description) {
super(description);
}

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