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

[Jacob-109] iP #234

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
271e2f4
Level 1.Greet,Echo,Exit
Jacob-109 Jan 21, 2021
9522d74
Level 2.Add,List
Jacob-109 Jan 21, 2021
082e99c
Level 3.Mark as Done
Jacob-109 Jan 21, 2021
56d2f18
Level 4. ToDos, Events, Deadlines
Jacob-109 Jan 21, 2021
5b6adf0
Level 4. ToDos, Events, Deadlines
Jacob-109 Jan 21, 2021
0e6d2c7
Revert "Level 4. ToDos, Events, Deadlines"
Jacob-109 Jan 21, 2021
b4d0ca6
Revert "Revert "Level 4. ToDos, Events, Deadlines""
Jacob-109 Jan 21, 2021
91ba5b7
Level4.ToDos, Events, Deadlines
Jacob-109 Jan 21, 2021
28f54b8
Level4.ToDos, Events, Deadlines
Jacob-109 Jan 21, 2021
44c3b6d
Level5.Handle Errors
Jacob-109 Jan 21, 2021
81367c5
Level6.Delete
Jacob-109 Jan 21, 2021
7e03915
A-TextUiTesting
Jacob-109 Jan 21, 2021
3166da9
Level-7
Jacob-109 Feb 9, 2021
436656a
Level-8
Jacob-109 Feb 10, 2021
5a03f8f
Merged branch 'branch-Level-7'
Jacob-109 Feb 10, 2021
5220f22
Merged Branch-level-8 into master branch
Jacob-109 Feb 15, 2021
14de94b
Fixed bug that caused Task to not be load properly
Jacob-109 Feb 15, 2021
0305fd6
add oop
Jacob-109 Feb 21, 2021
9d38c53
add JUnit test for Deadline and TaskList
Jacob-109 Feb 21, 2021
76fb6d6
add Level-9.Find command
Jacob-109 Feb 23, 2021
9337ccb
add JavaDocs
Jacob-109 Feb 23, 2021
7301499
add CodingStandard
Jacob-109 Feb 23, 2021
d7889df
add A-Gradle and Assertions
Jacob-109 Feb 24, 2021
bf4797e
add A-CodeQuality
Jacob-109 Feb 24, 2021
05a3f62
added C-Tagging for ToDo
Jacob-109 Feb 24, 2021
c2d76ad
added Assertions
Jacob-109 Feb 28, 2021
7d82d76
Added GUI
Jacob-109 Feb 28, 2021
04b7f4d
Added UserGuide
Jacob-109 Feb 28, 2021
f8c8bea
Fixed bugs in Gradle and Duke
Jacob-109 Feb 28, 2021
876e9ec
Fixed Bugs and Checkstyle
Jacob-109 Mar 4, 2021
08f29a1
Added Ui.png
Jacob-109 Mar 4, 2021
a82c13b
Modifications to Project to Structure
Jacob-109 Mar 21, 2021
6cbdfba
Modifications to Class Files and GUI
Jacob-109 Mar 21, 2021
4211cd9
Updated MANIFEST and README
Jacob-109 Mar 21, 2021
afe7462
Cleaned up .class files and fixed Parser.java
Jacob-109 Mar 28, 2021
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
Binary file added src/main/java/Deadline.class
Binary file not shown.
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

Choose a reason for hiding this comment

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

Should the class be added or grouped inside a package? This applies to other classes as well.


protected String by;
Copy link

Choose a reason for hiding this comment

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

You could have a better convention such as dateTime. "by" alone doesn't have any meaning.

Copy link

Choose a reason for hiding this comment

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

so sorry I thought this was my iP, please ignore my replies if any:)


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

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
67 changes: 66 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,75 @@
import java.lang.reflect.Array;
Copy link

Choose a reason for hiding this comment

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

Can I check if this import is being used? Because Array should be present by default in Java.

import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
Copy link

Choose a reason for hiding this comment

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

Will it be better to add javadoc to all public classes and methods? The same applies to all other public classes and methods.

public static void main(String[] args) {
public static void main(String[] args) throws DukeException{
Copy link

Choose a reason for hiding this comment

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

You should catch the DukeException, if not your program would stop running due to the exception.

String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
Scanner sc = new Scanner(System.in);
ArrayList<Task> list = new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

Should be lists instead of list. Also, the naming convention could have been better, perhaps using tasks is better? After all, your code is being read by many people with different backgrounds. So it would be better if your naming convention is clearer.


while(sc.hasNext()) {
Copy link

Choose a reason for hiding this comment

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

Will it be better to abstract and break this method into many smaller units? It will help in the future also.

String word = sc.nextLine();
if (word.equals("bye")) {
Copy link

Choose a reason for hiding this comment

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

You can change the if-else to switch case for better readability.

System.out.println("Bye, hope to see you again!");
break;
} else if (word.equals("list")) {
int size = list.size();
System.out.println("Here are the tasks in your list:");
for (int i = 1; i <= size; i++) {
Copy link

Choose a reason for hiding this comment

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

Could have just do for (int i = 1; i <= list.size(); i++)

System.out.println(i + ". " + list.get(i - 1).toString());
}
} else if (word.contains("done")) {
String strArray[] = word.split(" ");
int value = Integer.parseInt(strArray[1]);
Task complete = list.get(value - 1);
complete.markAsDone();
System.out.println(" Nice! I've marked this task as done: ");
System.out.println(complete.toString());
} else if (word.contains("delete")) {
String arr[] = word.split(" ");
int value = Integer.parseInt(arr[1]);
Task remove = list.get(value - 1);
list.remove(value - 1);
System.out.println("Noted. I've removed this task: ");
System.out.println(remove.toString());
System.out.println("Now you have " + list.size() + " tasks in the list");
} else if ((word.contains("todo")) || (word.contains("event")) || (word.contains("deadline"))) {
if (word.contains("todo")) {
String save = word.replaceAll("todo","");
ToDo t = new ToDo(save);
if (save.equals("")) {
Thread.setDefaultUncaughtExceptionHandler((u, e) -> System.err.println(e.getMessage()));
throw new DukeException("OOPS!!! The description of a todo cannot be empty.");
}
list.add(t);
System.out.println("Got it. I've added this task: ");
System.out.println(t.toString());
} else if (word.contains("event")) {
String[] info = word.split("/at");
info[0] = info[0].replaceAll("event","");
Event e = new Event(info[0],info[1]);
list.add(e);
System.out.println("Got it. I've added this task: ");
System.out.println(e.toString());
} else if (word.contains("deadline")) {
String[] input = word.split("/by");
input[0] = input[0].replaceAll("deadline", "");
Deadline d = new Deadline(input[0], input[1]);
list.add(d);
System.out.println("Got it. I've added this task: ");
System.out.println(d.toString());
}
System.out.println("Now you have " + list.size() + " tasks in the list");
} else {
Thread.setDefaultUncaughtExceptionHandler((u, e) -> System.err.println(e.getMessage()));
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}
}
}
Binary file added src/main/java/DukeException.class
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class DukeException extends Exception {
public DukeException(String message) {
super(message);
}
}
Binary file added src/main/java/Event.class
Binary file not shown.
14 changes: 14 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Event extends Task {

protected String datetime;
Copy link

Choose a reason for hiding this comment

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

Your deadline by naming convention should have followed this format as well.


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

@Override
public String toString() {
return "[E]" + super.toString() + " (at: " + datetime + ")";
}
}
Binary file added src/main/java/Task.class
Binary file not shown.
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() {
Copy link

Choose a reason for hiding this comment

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

It seems like getStatusIcon() is used in this task class only, hence you can change public to private.

if (isDone) {
return "Done";
} else {
return "Incompleted";// unsure why tick and cross did not show as intended
// hence the change to Done and Incompleted.
}
}

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

public String toString() {
return "[" + this.getStatusIcon() + "] " + this.description;
}
}
Binary file added src/main/java/ToDo.class
Binary file not shown.
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.toString();
}
}