-
Notifications
You must be signed in to change notification settings - Fork 73
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
[Siti Nadiah] iP #48
base: master
Are you sure you want to change the base?
[Siti Nadiah] iP #48
Changes from 12 commits
e7ddeaf
9b36508
7dbafe5
61e8429
50eaba3
bde2274
ec8b25f
76c925a
92bd1da
c0b1feb
19bfb8e
2f66be2
d5666fa
04d0c6e
0cb741a
3a90e6c
e785bea
4ecd16b
7976315
1646488
0955a30
eeef120
381f0db
f416108
f6967be
805d350
2736fb6
9aec6d7
f1bdc46
246787c
830107d
cd2a67d
d669224
a887a50
fd6f233
c9b40ec
56230c0
e5e77a6
f305d30
10b4634
cea5534
0aeb205
eeb0a39
adca7ed
3d3001a
d882c6f
08bec3c
a23257e
76037ed
ddefeb2
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class Deadline extends Task { | ||
protected String by; | ||
|
||
public Deadline(String description, String by) { | ||
super(description); | ||
this.by = by; | ||
} | ||
|
||
public String getBy() { | ||
return by; | ||
} | ||
|
||
public void setBy(String by) { | ||
this.by = by; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[D]" + super.toString() + "(by: " + this.by + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,138 @@ | ||
import java.util.Scanner; | ||
|
||
public class Duke { | ||
|
||
private static int NUM_OF_TASK = 0; | ||
private static String LINE = "____________________________________________________________\n"; | ||
private static final String BYE_COMMAND = "bye"; | ||
private static final String LIST_COMMAND = "list"; | ||
private static final String DONE_COMMAND = "done"; | ||
private static final String TODO_COMMAND = "todo"; | ||
private static final String EVENT_COMMAND = "event"; | ||
private static final String DEADLINE_COMMAND = "deadline"; | ||
|
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
printWelcomeMessage(); | ||
runChatbot(); | ||
} | ||
|
||
private static void runChatbot() { | ||
Task[] Tasks = new Task[100]; | ||
|
||
Scanner in = new Scanner(System.in); | ||
String arr[] = getCommand(in); | ||
|
||
while (true) { | ||
runCommand(arr, Tasks, in); | ||
arr = getCommand(in); | ||
} | ||
} | ||
|
||
private static String[] getCommand(Scanner in) { | ||
String s = in.nextLine(); | ||
String arr[] = s.split(" ", 2); | ||
return arr; | ||
} | ||
|
||
private static void runCommand(String[] arr, Task[] Tasks, Scanner in) { | ||
switch (arr[0]) { | ||
case (BYE_COMMAND): | ||
printExitMessage(); | ||
case (LIST_COMMAND): | ||
printList(Tasks); | ||
break; | ||
case (DONE_COMMAND): | ||
int taskNum = Integer.parseInt(arr[1]); | ||
taskNum--; | ||
Tasks[taskNum].setDone(true); | ||
printDone(Tasks[taskNum]); | ||
break; | ||
case (TODO_COMMAND): | ||
Tasks[NUM_OF_TASK] = new Todo(arr[1]); | ||
printConfirm(Tasks[NUM_OF_TASK]); | ||
break; | ||
case (DEADLINE_COMMAND): | ||
String arr2[] = arr[1].split("/by ", 2); | ||
Tasks[NUM_OF_TASK] = new Deadline(arr2[0], arr2[1]); | ||
printConfirm(Tasks[NUM_OF_TASK]); | ||
break; | ||
case (EVENT_COMMAND): | ||
arr2 = arr[1].split("/at ", 2); | ||
Tasks[NUM_OF_TASK] = new Event(arr2[0], arr2[1]); | ||
printConfirm(Tasks[NUM_OF_TASK]); | ||
break; | ||
} | ||
} | ||
|
||
private static void printDone(Task task) { | ||
System.out.println(LINE); | ||
System.out.println("Nice! I've marked this task as done: "); | ||
System.out.println(" " + task); | ||
System.out.println(LINE); | ||
} | ||
|
||
private static void printConfirm(Task task) { | ||
System.out.println(LINE); | ||
System.out.println("Got it! I've added this task:"); | ||
System.out.println(" " + task); | ||
int num = NUM_OF_TASK + 1; | ||
System.out.println("Now you have " + num + " task(s) in the list."); | ||
System.out.println(LINE); | ||
NUM_OF_TASK++; | ||
} | ||
|
||
private static void printExitMessage() { | ||
String outro = "Bye. Hope to see you again soon!"; | ||
System.out.println(LINE); | ||
System.out.println(outro); | ||
System.out.println(LINE); | ||
System.exit(0); | ||
} | ||
|
||
private static void printWelcomeMessage() { | ||
String tos = "──────────▄▄▄▄▄▄▄▄▄▄▄──────────\n" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like your mascot! |
||
"─────▄▄▀▀▀▀──────────▀▀▄▄──────\n" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like too!👻 |
||
"───▄▀───────────────────▀▀▄────\n" + | ||
"──█────────────────────────█───\n" + | ||
"─█─────────────────────▄▀▀▀▀▀█▄\n" + | ||
"█▀────────────────────█────▄███\n" + | ||
"█─────────────────────█────▀███\n" + | ||
"█─────▄▀▀██▀▄─────────█───────█\n" + | ||
"█────█──████─█─────────▀▄▄▄▄▄█─\n" + | ||
"█────█──▀██▀─█───────────────█─\n" + | ||
"█────█───────█──────────────▄▀─\n" + | ||
"█────▀▄─────▄▀──▄▄▄▄▄▄▄▄▄───█──\n" + | ||
"█──────▀▀▀▀▀────█─█─█─█─█──▄▀──\n" + | ||
"─█──────────────▀▄█▄█▄█▀──▄▀───\n" + | ||
"──█──────────────────────▄▀────\n" + | ||
"───▀▀▀▄──────────▄▄▄▄▄▄▀▀──────\n" + | ||
"────▄▀─────────▀▀──▄▀──────────\n" + | ||
"──▄▀───────────────█───────────\n" + | ||
"─▄▀────────────────█──▄▀▀▀█▀▀▄─\n" + | ||
"─█────█──█▀▀▀▄─────█▀▀────█──█─\n" + | ||
"▄█────▀▀▀────█─────█────▀▀───█─\n" + | ||
"█▀▄──────────█─────█▄────────█─\n" + | ||
"█──▀▀▀▀▀█▄▄▄▄▀─────▀█▀▀▀▄▄▄▄▀──\n" + | ||
"█───────────────────▀▄─────────\n"; | ||
|
||
System.out.println("What is up my dudes!\n" + tos); | ||
|
||
String intro = "____________________________________________________________\n" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you could use the LINE constant for this line? |
||
" It is I, Bob!\n" + | ||
" How may I spook you today?\n" + | ||
"____________________________________________________________\n"; | ||
|
||
System.out.println(intro); | ||
} | ||
|
||
public static void printList(Task[] Task) { | ||
System.out.println(LINE); | ||
System.out.println("Here are the tasks in your list: \n"); | ||
for (int i = 0; i < NUM_OF_TASK; i++) { | ||
int num = i + 1; | ||
System.out.println(num + ". " + Task[i]); | ||
} | ||
System.out.println(LINE); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public class Event extends Task { | ||
|
||
protected String time; | ||
|
||
public Event(String description, String time) { | ||
super(description); | ||
this.time = time; | ||
} | ||
|
||
public String getTime() { | ||
return time; | ||
} | ||
|
||
public void setTime(String time) { | ||
this.time = time; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[E]" + super.toString() + "(at: " + this.time + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
public class Task { | ||
protected String description; | ||
protected boolean isDone; | ||
protected int num; | ||
|
||
private static int curr = 1; | ||
|
||
public Task(String description) { | ||
this.description = description; | ||
this.isDone = false; | ||
this.num = curr; | ||
curr++; | ||
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public boolean isDone() { | ||
return isDone; | ||
} | ||
|
||
public void setDone(boolean done) { | ||
isDone = done; | ||
} | ||
|
||
public int getNum() { | ||
return num; | ||
} | ||
|
||
public void setNum(int num) { | ||
this.num = num; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[" + this.getStatusIcon() + "] " + 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(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
What is up my dudes! | ||
──────────▄▄▄▄▄▄▄▄▄▄▄────────── | ||
─────▄▄▀▀▀▀──────────▀▀▄▄────── | ||
───▄▀───────────────────▀▀▄──── | ||
──█────────────────────────█─── | ||
─█─────────────────────▄▀▀▀▀▀█▄ | ||
█▀────────────────────█────▄███ | ||
█─────────────────────█────▀███ | ||
█─────▄▀▀██▀▄─────────█───────█ | ||
█────█──████─█─────────▀▄▄▄▄▄█─ | ||
█────█──▀██▀─█───────────────█─ | ||
█────█───────█──────────────▄▀─ | ||
█────▀▄─────▄▀──▄▄▄▄▄▄▄▄▄───█── | ||
█──────▀▀▀▀▀────█─█─█─█─█──▄▀── | ||
─█──────────────▀▄█▄█▄█▀──▄▀─── | ||
──█──────────────────────▄▀──── | ||
───▀▀▀▄──────────▄▄▄▄▄▄▀▀────── | ||
────▄▀─────────▀▀──▄▀────────── | ||
──▄▀───────────────█─────────── | ||
─▄▀────────────────█──▄▀▀▀█▀▀▄─ | ||
─█────█──█▀▀▀▄─────█▀▀────█──█─ | ||
▄█────▀▀▀────█─────█────▀▀───█─ | ||
█▀▄──────────█─────█▄────────█─ | ||
█──▀▀▀▀▀█▄▄▄▄▀─────▀█▀▀▀▄▄▄▄▀── | ||
█───────────────────▀▄───────── | ||
|
||
____________________________________________________________ | ||
It is I, Bob! | ||
How may I spook you today? | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Got it! I've added this task: | ||
[T][✘] call dentist | ||
Now you have 1 task(s) in the list. | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Got it! I've added this task: | ||
[T][✘] make appointment at clinic | ||
Now you have 2 task(s) in the list. | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Got it! I've added this task: | ||
[E][✘] team meeting (at: AS3 10 Feb 10am) | ||
Now you have 3 task(s) in the list. | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Got it! I've added this task: | ||
[D][✘] OP1 research (by: 6 Feb) | ||
Now you have 4 task(s) in the list. | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Got it! I've added this task: | ||
[E][✘] Project Link sales (at: 4 Feb 1pm) | ||
Now you have 5 task(s) in the list. | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Here are the tasks in your list: | ||
|
||
1. [T][✘] call dentist | ||
2. [T][✘] make appointment at clinic | ||
3. [E][✘] team meeting (at: AS3 10 Feb 10am) | ||
4. [D][✘] OP1 research (by: 6 Feb) | ||
5. [E][✘] Project Link sales (at: 4 Feb 1pm) | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Nice! I've marked this task as done: | ||
[T][✓] make appointment at clinic | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Nice! I've marked this task as done: | ||
[D][✓] OP1 research (by: 6 Feb) | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Here are the tasks in your list: | ||
|
||
1. [T][✘] call dentist | ||
2. [T][✓] make appointment at clinic | ||
3. [E][✘] team meeting (at: AS3 10 Feb 10am) | ||
4. [D][✓] OP1 research (by: 6 Feb) | ||
5. [E][✘] Project Link sales (at: 4 Feb 1pm) | ||
____________________________________________________________ | ||
|
||
____________________________________________________________ | ||
|
||
Bye. Hope to see you again soon! | ||
____________________________________________________________ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
todo call dentist | ||
todo make appointment at clinic | ||
event team meeting /at AS3 10 Feb 10am | ||
deadline OP1 research /by 6 Feb | ||
event Project Link sales /at 4 Feb 1pm | ||
list | ||
done 2 | ||
done 4 | ||
list | ||
bye |
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.
Delete some useless blank lines.