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

[bryanongjx] iP #379

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
e2dc23c
first commit
bryanongjxairetec Jan 19, 2023
9db8e00
Revert "first commit"
bryanongjxairetec Jan 19, 2023
20ce1ef
Level 1 Commit
bryanongjxairetec Jan 19, 2023
e948091
second commit
bryanongjxairetec Jan 19, 2023
89bdac5
level 3 commit
bryanongjxairetec Jan 30, 2023
7b40056
Level 4 commit
bryanongjxairetec Jan 30, 2023
81c9a07
Level 5 Commit
bryanongjxairetec Jan 30, 2023
7214d96
Level 6 commit
bryanongjxairetec Jan 30, 2023
cf92c42
Level 7 Commit
bryanongjxairetec Feb 6, 2023
5a3100f
Revert "Level 7 Commit"
bryanongjx Feb 7, 2023
58a445a
added date feature
bryanongjx Feb 7, 2023
4f6015e
Merge branch 'branch-Level-8'
bryanongjx Feb 7, 2023
1b62400
Added classes Parser, Storage, TaskList and Ui
bryanongjx Feb 13, 2023
7f63b95
Moved classes to a single packed "duke"
bryanongjx Feb 13, 2023
a3e7ddd
Merge remote-tracking branch 'origin/add-gradle-support'
bryanongjx Feb 13, 2023
3b342e4
Add gradle files
bryanongjx Feb 13, 2023
66cf005
add JUnit Testing (for addition of todo, events and deadlines)
bryanongjx Feb 13, 2023
7304d67
Added java docs
bryanongjx Feb 13, 2023
8149068
Merge branch 'branch-A-JavaDoc'
bryanongjx Feb 13, 2023
a751546
Edit code to comply with java coding standard
bryanongjx Feb 14, 2023
a4305f5
add Find feature to locate tasks by keyword
bryanongjx Feb 14, 2023
75434c3
add image of tick for readme
bryanongjx Feb 14, 2023
d0ee74a
Update README.md
bryanongjx Feb 14, 2023
89cb4cb
add GUI using JavaFX
bryanongjx Feb 14, 2023
9a048bb
Merge branch 'master' of https://github.com/bryanongjx/ip
bryanongjx Feb 14, 2023
6b62d7c
add assertions to TaskList methods: getTaskList & findTask
bryanongjx Feb 14, 2023
281887a
Merge pull request #2 from bryanongjx/branch-A-Assertions
bryanongjx Feb 14, 2023
ec4f38b
amend storage methods for cleaner code quality
bryanongjx Feb 16, 2023
125a1ba
Improve code quality by abstracting out parser commands
bryanongjx Feb 16, 2023
54966ee
corrected bugs from previous commit of improving code quality
bryanongjx Feb 16, 2023
4c1d6c5
improve GUI
bryanongjx Feb 16, 2023
cb80e43
Revert "improve GUI"
bryanongjx Feb 16, 2023
9773ae4
Revert "Revert "improve GUI""
bryanongjx Feb 16, 2023
abc3980
add screenshot for user guide
bryanongjx Feb 16, 2023
61ba68b
update user guide
bryanongjx Feb 16, 2023
8ce8ade
minor fixes
bryanongjx Feb 20, 2023
ec6df17
add text ui test
bryanongjx Feb 20, 2023
56e199b
reset user guide
bryanongjx Feb 20, 2023
d0d6670
add user guide with set up instructions and feature usages
bryanongjx Feb 20, 2023
c10b1b7
edit readme
bryanongjx Feb 20, 2023
9625384
add image for user and duke
bryanongjx Feb 20, 2023
3a259b7
rename and move Ui screenshot
bryanongjx Feb 20, 2023
0d4c3b6
rename and move ui screenshot
bryanongjx Feb 20, 2023
5df8906
edit directory link of user guide screenshot
bryanongjx Feb 20, 2023
c490000
fix format of user guide
bryanongjx Feb 20, 2023
76ab484
fix format of user guide
bryanongjx Feb 20, 2023
2bdc84d
fixed format of userguide
bryanongjx Feb 20, 2023
9b15285
fixed format of user guide
bryanongjx Feb 20, 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
13 changes: 13 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Deadline extends Task{

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

@Override
public String toString() {
return "[D]" + super.toString() + " (" + this.dueDate + ')';
}
}
85 changes: 79 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,83 @@
import java.util.*;
Copy link

Choose a reason for hiding this comment

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

According to the coding standard, you may want to list all imports explicitly as they make the class easier to read 😀



public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

Scanner sc = new Scanner(System.in);
System.out.println("Hello! I'm Duke\n");
System.out.println("What can I do for you?\n");

List<Task> lst = new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

Nice naming, easy to understand in subsequent code 👍




while (true) {
try {
String input = sc.nextLine().toLowerCase();
String[] inputArr = input.split(" ", 2);
String action = inputArr[0];

if (action.equals("bye")) {
System.out.println("Bye. Hope to see you again soon!");
return;
} else if (action.equals("list")) { // list
System.out.println("Here are the tasks in your list:");
for (int i = 1; i <= lst.size(); i++) {
System.out.println(i + ". " + lst.get(i - 1));
}
} else if (action.equals("mark")) {
String details = inputArr[1];
int taskNum = Integer.parseInt(details);
Task currTask = lst.get(taskNum - 1);
currTask.mark();
System.out.println("Nice! I've marked this task as done" + '\n' + currTask);
} else if (action.equals("unmark")) {
String details = inputArr[1];
int taskNum = Integer.parseInt(details);
Task currTask = lst.get(taskNum - 1);
currTask.unMark();
System.out.println("Nice! I've marked this task as not done yet" + '\n' + currTask);
} else if (action.equals("todo")) {

Choose a reason for hiding this comment

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

Perhaps, using a switch-case statement would make it slightly more readable.

String[] actionAndDetails = input.split(" ", 2);
if (actionAndDetails.length == 1) {
throw new DukeException("OOPS!!! The description of a todo cannot be empty.");
}
String details = actionAndDetails[1];
Todo newTodo = new Todo(details);
lst.add(newTodo);
System.out.println("Got it. I've added this task:" + '\n' + newTodo + '\n' + "Now you have " + lst.size() + " tasks in the list");
Copy link

Choose a reason for hiding this comment

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

This line may be exceeding the 120 character limit, perhaps you would like to double check!

} else if (action.equals("deadline")) {
String[] detailsAndDate = inputArr[1].split(" /by ");
String details = detailsAndDate[0];
String date = detailsAndDate[1];
Deadline newDeadline = new Deadline(details, date);
lst.add(newDeadline);
System.out.println("Got it. I've added this task:" + '\n' + newDeadline + '\n' + "Now you have " + lst.size() + " tasks in the list");
} else if (action.equals("event")) {
String[] detailsAndTime = inputArr[1].split(" /from ");
String details = detailsAndTime[0];
String[] Time = detailsAndTime[1].split(" /to ");
String To = Time[0];
String From = Time[1];
Event newEvent = new Event(details, To, From);
lst.add(newEvent);
System.out.println("Got it. I've added this task:" + '\n' + newEvent + '\n' + "Now you have " + lst.size() + " tasks in the list");
} else if (action.equals("delete")) {
String details = inputArr[1];
int taskNum = Integer.parseInt(details);
Task currTask = lst.get(taskNum - 1);
lst.remove(taskNum - 1);
System.out.println("Noted. I've removed this task:" + '\n' + currTask + '\n' + "Now you have " + lst.size() + " tasks in the list");
}else {
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
Copy link

Choose a reason for hiding this comment

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

Cute emoji 😄

}
} catch (DukeException e) {
System.out.println(e.getMessage());
}

}
}

}

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

public DukeException(String message) {
super(message);
}

public String getMessage() {
return super.getMessage();
}

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

String From;
String To;
public Event(String description, String From, String To) {

Choose a reason for hiding this comment

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

Perhaps, the naming of the fields can follow the norm of the 'description' field with small letters instead of capitalised ones. I think as long as you are consistent, it should be fine

super(description);
this.From = From;
this.To = To;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + this.From + " to: " + this.To + ")";

}
}
32 changes: 32 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.*;

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 String getDescription() {
return this.description;
}

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

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

@Override
public String toString() {
return "[" + this.getStatusIcon() + "] " + this.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.toString();
}
}
18 changes: 11 additions & 7 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

Got it. I've added this task:
[T][ ] borrow book
Now you have 1 tasks in the list
Here are the tasks in your list:
1. [T][ ] borrow book
Got it. I've added this task:
[D][ ] return book (sunday)
Now you have 2 tasks in the list
Got it. I've added this task:
[E][ ] project meeting (from: mon 2pm to: 4pm)
Now you have 3 tasks in the list
5 changes: 5 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
todo borrow book
list
deadline return book /by Sunday
event project meeting /from Mon 2pm /to 4pm