-
Notifications
You must be signed in to change notification settings - Fork 479
[felibunnyy] iP #540
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
base: master
Are you sure you want to change the base?
[felibunnyy] iP #540
Changes from 7 commits
28ad2b8
ed6d4d2
6561147
a59cb5c
a02cf9f
c5cea7a
3d35347
62a9e52
a63d20f
4a80c47
ba7c244
8472674
df6fe03
79cd76e
2bc1353
671d520
ab1f79e
4ccc0d4
1dcfad7
977dd21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,4 @@ bin/ | |
|
|
||
| /text-ui-test/ACTUAL.TXT | ||
| text-ui-test/EXPECTED-UNIX.TXT | ||
| *.class | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| public class Deadline extends Task { | ||
| protected String by; | ||
|
|
||
| public Deadline(String description, String by) { | ||
| super(description); | ||
| this.by = by; | ||
| } | ||
| @Override | ||
| public String toString() { | ||
| return "[D]" + super.toString() + " (by: " + by + ")"; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,81 @@ | ||||||||||
| import java.util.Scanner; | ||||||||||
| import java.util.ArrayList; | ||||||||||
| public class Duke { | ||||||||||
| public static void main(String[] args) { | ||||||||||
| String logo = " ____ _ \n" | ||||||||||
| + "| _ \\ _ _| | _____ \n" | ||||||||||
| + "| | | | | | | |/ / _ \\\n" | ||||||||||
| + "| |_| | |_| | < __/\n" | ||||||||||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||||||||||
| System.out.println("Hello from\n" + logo); | ||||||||||
| Scanner scanner = new Scanner(System.in); | ||||||||||
| boolean isRunning = true; | ||||||||||
| int taskCount = 0; | ||||||||||
| ArrayList<Task> tasks = new ArrayList<>(); | ||||||||||
| // Task[] tasks = new Task[100]; | ||||||||||
| System.out.println("Hello! I'm Chatty\nWhat can I do for you?"); | ||||||||||
| System.out.println("____________________________________________________________"); | ||||||||||
| while (isRunning) { | ||||||||||
| try { | ||||||||||
| String userInput = scanner.nextLine(); | ||||||||||
| System.out.println("____________________________________________________________"); | ||||||||||
| if (userInput.equals("bye")) { | ||||||||||
| System.out.println("Bye. Hope to see you again soon!"); | ||||||||||
| isRunning = false; | ||||||||||
| } else if (userInput.equals("list")){ | ||||||||||
|
||||||||||
| } else if (userInput.equals("list")){ | |
| } else if (userInput.equals("list")) { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be issues if no /by parameter is specified? Perhaps a DukeException could be thrown in that case?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| String from = userInput.substring(userInput.indexOf("/from") + 6, userInput.indexOf("/to")).trim(); | |
| String from = userInput.substring( | |
| userInput.indexOf("/from") + 6, userInput.indexOf("/to") | |
| ).trim(); |
the original line is over 100 characters ;-;
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can put all these into another class, which makes it more simple and clear
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can add more Javadosc to the code
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class DukeException extends Exception { | ||
| public DukeException(String message) { | ||
| super(message); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| public class Event extends Task { | ||
| protected String from; | ||
| protected String to; | ||
|
|
||
| public Event(String description, String from, String to) { | ||
| super(description); | ||
| this.from = from; | ||
| this.to = to; | ||
| } | ||
| @Override | ||
| public String toString() { | ||
| return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.to + ")"; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 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 void switchCheck() { | ||
| this.isDone = !this.isDone; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[" + this.getStatusIcon() + "]" + " " + this.description; | ||
| } | ||
| } |
| 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(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that there are spaces around the brackets :D