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

[Gavin Cho] iP #530

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
1c74c0b
Level 1 implemented
Gavzzz Aug 18, 2022
acab8ca
Level 2 implemented
Gavzzz Aug 18, 2022
495d75f
edited Level 2
Gavzzz Aug 18, 2022
cf2222b
Level 3 implemented
Gavzzz Aug 18, 2022
f7da0fc
Task class implemented
Gavzzz Aug 18, 2022
6efa017
Level 3 edited
Gavzzz Aug 19, 2022
f485a40
Level 4 implemented
Gavzzz Aug 19, 2022
9ea2336
Level 5 implemented
Gavzzz Aug 20, 2022
d1eeead
Level 6 implemented
Gavzzz Aug 20, 2022
1bc98d4
Level 7 implemented
Gavzzz Sep 3, 2022
d4c0930
Level-8 implemented
Gavzzz Sep 6, 2022
77784ad
More oop implemented
Gavzzz Sep 13, 2022
9f18cfa
Packages enabled
Gavzzz Sep 13, 2022
7e0f15e
Merge branch 'add-gradle-support'
Gavzzz Sep 13, 2022
11ed975
Level 9 implemented
Gavzzz Sep 13, 2022
9b80d78
updated level 8
Gavzzz Sep 13, 2022
6a229ea
updated level 9
Gavzzz Sep 13, 2022
577792e
Merge branch 'branch-Level-9'
Gavzzz Sep 13, 2022
9f8c006
updated level 8
Gavzzz Sep 13, 2022
6f73e7f
Merge branch 'branch-Level-8'
Gavzzz Sep 13, 2022
bb5a7ef
java docs implemented
Gavzzz Sep 15, 2022
84d9b6f
Coding standard implemented
Gavzzz Sep 15, 2022
6c36b7c
JUnit Tests implemented
Gavzzz Sep 15, 2022
aee7f8a
Jar file dependencies implemented
Gavzzz Sep 16, 2022
cd63ed5
Implemented GUI
Gavzzz Sep 18, 2022
ed5372d
Assertions implemented
Gavzzz Sep 18, 2022
4bf0b8c
implemented code quality checking
Gavzzz Sep 18, 2022
66485b3
Update README.md
Gavzzz Sep 18, 2022
ebdccba
Detect duplicates implemented
Gavzzz Sep 18, 2022
a8245a2
Merge branch 'branch-BCD-Extension'
Gavzzz Sep 18, 2022
b98175d
Fixing level 8 branch issue and detect duplicates
Gavzzz Sep 19, 2022
3301a16
GUI bug fixed
Gavzzz Sep 19, 2022
b51074a
User guide implemented
Gavzzz Sep 19, 2022
117aec7
Update README.md
Gavzzz Sep 20, 2022
76c94ea
Update README.md
Gavzzz Sep 21, 2022
4187f78
Update README.md
Gavzzz Sep 21, 2022
8c4e65a
Removed unnecessary imports
Gavzzz Sep 21, 2022
70e51df
Merge branch 'master' of https://github.com/Gavzzz/ip
Gavzzz Sep 21, 2022
9ee19c5
Fix Jar File unable to open issue and add new bcd tags extension
Gavzzz Oct 16, 2022
bc5e274
fix test file naming
Gavzzz Oct 17, 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 {

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.

I think it might be better if the String had a more descriptive name, perhaps something like "date" or "deadline"?


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

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
122 changes: 121 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,130 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
public static void main(String[] args) {

public Task[] tasks;


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

Choose a reason for hiding this comment

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

Perhaps the line break could be stored in a constant since it is used multiple times in the code

System.out.println("Hello! I'm Duke\n What can I do for you?");
System.out.println("___________________________________");

Task[] tasks = new Task[100];
int counter = 0;
ArrayList<Task> collection = new ArrayList<>();

Scanner sc = new Scanner(System.in);
String input = sc.nextLine();



Copy link

Choose a reason for hiding this comment

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

I think it might be better if there was only a single blank line here

while (!input.equals("bye")) {
if (input.equals("list")) {
System.out.println("___________________________________");
for (int i = 0; i < counter; i++) {
System.out.println( (i+1) + "."
Copy link

Choose a reason for hiding this comment

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

Seems like there's an extra whitespace on this line, might need to remove it to follow the coding standards

+ collection.get(i).toString());
}
System.out.println("___________________________________");
input = sc.next();

}

else if (input.equals("mark")) {
int number = sc.nextInt();
collection.get(number-1).mark();
Copy link

Choose a reason for hiding this comment

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

Similar issue on missing/extra whitespaces, noticed this issue in several other places too, might have to address these to follow the coding standards

System.out.println("___________________________________");
System.out.println("Nice! I've marked this task done: " + "\n"
+ "[" + collection.get(number-1).getStatusIcon() + "] " +
collection.get(number-1).description);
System.out.println("___________________________________");
input = sc.next();
}

else if (input.equals("unmark")) {
int number = sc.nextInt();
collection.get(number-1).unmark();
System.out.println("___________________________________");
System.out.println("OK, I've marked this task as not done yet: " + "\n"
+ "[" + collection.get(number-1).getStatusIcon() + "] " +
collection.get(number-1).description);
System.out.println("___________________________________");
input = sc.next();
}

else if (input.equals("deadline")) {
String what = sc.nextLine();
if (what.equals("")) throw new DukeException("☹ OOPS!!! The description of a deadline cannot be empty.");
String byWhen = sc.nextLine();
collection.add(new Deadline(what, byWhen));
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + collection.get(counter).toString() + "\n"
+ "Now you have " + (counter+1) + " tasks in the list.");
System.out.println("___________________________________");
counter++;
input = sc.nextLine();
}

else if (input.equals("todo")) {
String what = sc.nextLine();
if (what.equals("")) throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty.");
collection.add(new Todo(what));
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + collection.get(counter).toString() + "\n"
+ "Now you have " + (counter+1) + " tasks in the list.");
System.out.println("___________________________________");
counter++;
input = sc.nextLine();
}

else if (input.equals("event")) {
String what = sc.nextLine();
if (what.equals("")) throw new DukeException("☹ OOPS!!! The description of a event cannot be empty.");
String atWhen = sc.nextLine();
collection.add(new Event(what, atWhen));
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + collection.get(counter).toString() + "\n"
+ "Now you have " + (counter+1) + " tasks in the list.");
System.out.println("___________________________________");
counter++;
input = sc.nextLine();
}

else if (input.equals("delete")) {
int number = sc.nextInt();
Task temp = collection.get(number-1);
collection.remove(number-1);
counter--;
System.out.println("___________________________________");
System.out.println("Noted. I've removed this task:" + "\n"
+ " " + temp.toString() + "\n"
+ "Now you have " + counter + " tasks in the list.");
System.out.println("___________________________________");
input = sc.next();

}

else {
System.out.println("___________________________________");
throw new DukeException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");

}

}

System.out.println("___________________________________");
System.out.println("Bye. Hope to see you again soon!");
System.out.println("___________________________________");
}
}
6 changes: 6 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class DukeException extends Exception {

public DukeException(String message) {
super(message);
}
}
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 at;
Copy link

Choose a reason for hiding this comment

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

Maybe you can change the variable name from "at" to "eventTime" so that it sounds more meaningful?


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

@Override
public String toString() {
return "[E]" + super.toString() + " (at: " + at + ")";
}
}
27 changes: 27 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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.

Good job on following the coding standards for naming boolean variables👍


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

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}

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

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

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

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

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

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

}