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

[Tan Hong Liang] iP #501

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
0d13617
Added Week 2 Level-1 Level-2 and Level-3
tanhl2000 Aug 28, 2022
e176f21
finished ToDo of Level-4 and cleaned up code
tanhl2000 Aug 28, 2022
ff600bd
Finished up Level-4, Event and Deadline task types added
tanhl2000 Aug 28, 2022
04c50e0
Level-5, did more cleanup of code
tanhl2000 Sep 2, 2022
cf80052
Level-6 done, ArrayList used from start, delete command implemented
tanhl2000 Sep 2, 2022
14fbfe9
Did small part of Level-9
tanhl2000 Sep 8, 2022
5442e79
Finished Level-7 with saving and loading done
tanhl2000 Sep 8, 2022
de18707
Level-8 done in parallel branch
tanhl2000 Sep 8, 2022
bd191ca
Merge tag 'Level-7'
tanhl2000 Sep 9, 2022
32a4edb
Merge tag 'Level-8'
tanhl2000 Sep 9, 2022
812a5f8
fix conflicts from merge
tanhl2000 Sep 9, 2022
d42fd1f
fixed merge errors and updated enums with strings
tanhl2000 Sep 9, 2022
cc19d6b
Level-A-MoreOOP, split into packages
tanhl2000 Sep 9, 2022
a3a39b8
Level-A-MoreOOP, fully split out the different packages and classes, …
tanhl2000 Sep 10, 2022
7408a38
Level-A-MoreOOP, fixed functionalities for non task producing commands
tanhl2000 Sep 10, 2022
c1cb522
Level-5, made a main exception class where all exceptions will extend…
tanhl2000 Sep 11, 2022
7718dc5
Level-A-MoreOOP and Level-Packages: Finished abtracting and implement…
tanhl2000 Sep 16, 2022
ba58ab6
Level-A-Gradle: Added gradle support and converted to Gradle project
tanhl2000 Sep 16, 2022
c85360a
Level-A-Gradle, fixed package and import declarations in all files.
tanhl2000 Sep 17, 2022
9e9dcd7
Level-A-JUnit: set up Junit, created 1 test file to test it out
tanhl2000 Sep 18, 2022
b248eee
Level-A-JUnitv2: Added Testing for TaskList
tanhl2000 Sep 18, 2022
1d8b29d
Level-A-Jar
tanhl2000 Sep 18, 2022
bde3039
Level-A-Javadoc: Added documentation for all classes except the tasks…
tanhl2000 Sep 18, 2022
174ec22
Level-A-CodingStandardsv1: Added comments for logical blocks, did a c…
tanhl2000 Sep 18, 2022
92b2745
Merge commit Level-9: Added find command
tanhl2000 Sep 18, 2022
76b923c
Merge tag 'Level-A-JavaDoc'
tanhl2000 Sep 18, 2022
632ab49
Merge commit: commit some untracked files, to ensure merge commited e…
tanhl2000 Sep 18, 2022
fc92a48
Merge branch 'Level-A-CodingStandards'
tanhl2000 Sep 18, 2022
fd15136
Level-7: updated saving and loading such that user may specify an add…
tanhl2000 Sep 19, 2022
c49356d
Level-10: Added JavaFX support and GUI, changed program flow to fit i…
tanhl2000 Sep 19, 2022
53c523e
Level-10: Added personalisation and cursory editing with FXML builder
tanhl2000 Sep 19, 2022
e2959fd
Level-10 and Level-Assertion: Finished Level-10 and added assertions
tanhl2000 Sep 19, 2022
13377a1
Merge commit Level-10: Merged Level-10 and Level-A-Assertions
tanhl2000 Sep 19, 2022
f48f75f
Level-10: fixed errors from previous merge deconflicting
tanhl2000 Sep 19, 2022
1ff9775
Level-A-Jar: Created jar file
tanhl2000 Sep 19, 2022
41ea42d
Level-10: added personalisation
tanhl2000 Sep 19, 2022
0957668
Level-A-CodeQuality: added more comprehensive javadocs, putting under…
tanhl2000 Sep 19, 2022
7c80298
Level-A-CodeQuality: changed most magic literals to constants
tanhl2000 Sep 19, 2022
0d7c9c1
Level-A-CodingQuality: added more comments in to improve readability
tanhl2000 Sep 19, 2022
21f3c2f
Merge pull request #2 from tanhl2000/Branch-Level-A-CodeQuality
tanhl2000 Sep 20, 2022
52c8f42
Level-C-Archive: Adding archive functionality, saving progress
tanhl2000 Sep 20, 2022
4e05947
Currently, users who want to save their current configuration of task…
tanhl2000 Sep 22, 2022
7963072
Update user guide
tanhl2000 Sep 22, 2022
636d061
General bug fixes and adding the Ui.png
tanhl2000 Sep 22, 2022
909bc1c
Merge the User guide
tanhl2000 Sep 22, 2022
c59219f
Bug fixes and improvements to code quality
tanhl2000 Sep 22, 2022
7d75648
Removed UI from storage as its never used
tanhl2000 Sep 22, 2022
0356d41
Final touches and adding clear archive functionality
tanhl2000 Sep 22, 2022
3a7811c
Update with clear command
tanhl2000 Sep 22, 2022
fe7c2af
Delete Ui.PNG
tanhl2000 Sep 23, 2022
ebf81e5
Add Ui.png
tanhl2000 Sep 23, 2022
b696e2a
Delete Ui.png.png
tanhl2000 Sep 23, 2022
02e1d24
Add files via upload
tanhl2000 Sep 23, 2022
63a9b27
Updated the UI background graphics opacity to be less distracting
tanhl2000 Sep 25, 2022
a01d243
Merge branch 'master' of https://github.com/tanhl2000/ip
tanhl2000 Sep 25, 2022
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

Choose a reason for hiding this comment

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

Similar to Event class, I think you might need a white space before the curly brace according to the code standard.


protected String dateTime;

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

@Override
public String toString() {
return String.format("[D]%s (by:%s)", super.toString(), this.dateTime);
}
}
120 changes: 114 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,118 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
private static ArrayList<Task> tasks = new ArrayList<Task>();
Copy link

Choose a reason for hiding this comment

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

can consider making this a private static final variable

private static boolean isEnd = false;

private static final String UI_LINE_SPACING = "----------------------------------------\n";

private static final String COMMAND_LIST = "list";
private static final String COMMAND_BYE = "bye";
private static final String COMMAND_TODO = "todo";
private static final String COMMAND_DEADLINE = "deadline";
private static final String COMMAND_EVENT = "event";
private static final String COMMAND_MARK = "mark";
private static final String COMMAND_UNMARK = "unmark";

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

Choose a reason for hiding this comment

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

I love the design of code, but it would be great if the main "command execution" part could be extracted out to another class (which is required in Week 3 ip task [A-MoreOOP], so it might be easier if we change the code earlier)

String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String greeting = "Hello! I'm Duke \n" + "What can I do for you?\n";
Scanner userInput = new Scanner(System.in);
chat(greeting);
while (!isEnd) {
String userStatement = userInput.nextLine();
String splitUserStatement[] = userStatement.split(" ", 2);
String command = splitUserStatement[0];
String userArgs = "";
if (splitUserStatement.length > 1) {
userArgs = splitUserStatement[1];
}
/*String[] splitUserArgs = userArgs.split("/by", 2);
String dateTime = "";
String description = splitUserArgs[0];
if (splitUserArgs.length > 1) {
dateTime = splitUserArgs[1];
} */
switch(command) {
case COMMAND_LIST:
chat("Here are the tasks in your list: \n" + list());
break;
case COMMAND_BYE:
chat("Bye! Hope to see you again!\n");
isEnd = true;
break;
case COMMAND_TODO:
ToDo toDoToAdd = new ToDo(userArgs);
tasks.add(toDoToAdd);
chat("Got it, I've added this task:\n " + toDoToAdd + "\n" + outputNumOfTasks());
break;
case COMMAND_DEADLINE:
String[] splitUserArgs = userArgs.split("/by", 2);
String dateTime = "";
String description = splitUserArgs[0];
if (splitUserArgs.length > 1) {
dateTime = splitUserArgs[1];
}
Deadline deadlineToAdd = new Deadline(description, dateTime);
tasks.add(deadlineToAdd);
chat("Got it, I've added this task:\n " + deadlineToAdd + "\n" + outputNumOfTasks());
break;
case COMMAND_EVENT:
String[] splitUserArgs2 = userArgs.split("/at", 2);
String dateTime2 = "";
String description2 = splitUserArgs2[0];
if (splitUserArgs2.length > 1) {
dateTime2 = splitUserArgs2[1];
}
Event eventToAdd = new Event(description2, dateTime2);
tasks.add(eventToAdd);
chat("Got it, I've added this task:\n " + eventToAdd + "\n" + outputNumOfTasks());
break;
case COMMAND_MARK:
mark(Integer.parseInt(userArgs));
break;
case COMMAND_UNMARK:
unmark(Integer.parseInt(userArgs));
break;
default:
chat("Not a command, just wanna chat?");
}
}
}

public static String list() {
String output = "";
int count = 1;
for (Task task : tasks) {
output += String.valueOf(count) + ". " + task + "\n";
count += 1;
}
return output;
}

public static void mark(int taskNum) {
Task targetTask = tasks.get(taskNum-1);
targetTask.mark();
System.out.println(UI_LINE_SPACING + "Nice! I've marked this task as done:\n" + targetTask + "\n" + UI_LINE_SPACING);

}

public static void unmark(int taskNum) {
Task targetTask = tasks.get(taskNum-1);
targetTask.unmark();
System.out.println(UI_LINE_SPACING + "OK, I've marked this task as not done yet:\n" + targetTask + "\n" + UI_LINE_SPACING);
}

public static String outputNumOfTasks() {
return String.format("Now you have %d tasks in the list \n", tasks.size());
}

public static void chat(String message) {
Copy link

Choose a reason for hiding this comment

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

It would be great if JavaDoc could be added (but I highly understand that you might want to add comments once for all when the variables/func names are confirmed.

System.out.println(UI_LINE_SPACING + message + UI_LINE_SPACING);
}

public static void end() {
System.out.println(UI_LINE_SPACING + "Bye! Hope to see you again!" + UI_LINE_SPACING);
isEnd = true;
Copy link

Choose a reason for hiding this comment

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

Overall code is clear and the logic flows and should have no problem completing the IP

}
}
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{
Copy link

Choose a reason for hiding this comment

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

I think you might need a white space before the curly brace according to the code standard.


protected String duration;

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

@Override
public String toString() {
return String.format("[E]%s (at:%s)", super.toString(), this.duration);
}
}
36 changes: 36 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class Task {
protected String description;
protected boolean isDone;
Copy link

Choose a reason for hiding this comment

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

Seems that there is an extra white space followed by "protected" according to coding standard.

Copy link

Choose a reason for hiding this comment

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

Yes this violates the coding standard


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

public String getDescription() {
return this.description;
}

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

public void unmark() {
this.isDone = false;
}

@Override
public String toString() {
char mark;
if (this.isDone) {
mark = 'X';
} else {
mark = ' ';
}
return ("[" + mark + "] " + this.getDescription());
}
}
5 changes: 5 additions & 0 deletions src/main/java/TaskType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum TaskType {
TODO,
DEADLINE,
EVENT
}
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 String.format("[T]%s", super.toString());
}
}