-
Notifications
You must be signed in to change notification settings - Fork 437
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 Eu Zin iP #470
base: master
Are you sure you want to change the base?
Tan Eu Zin iP #470
Changes from 11 commits
3b19ba1
5fa8ff1
913c098
193dc5b
41f3eac
f699f2b
fc87ead
60c2438
7569542
4deb825
1cd2bc0
0c53018
30be8f6
c290955
37b18f1
5c8e64f
59863e8
cc4252f
c6fb802
aef36dd
cb2a2ce
bb86215
e1d5ed0
46425bf
dc639f2
66408eb
623bee8
e747751
779e689
5ea632b
e5eacc7
cd290bf
b1d46b4
d21247f
e61f350
56b2c52
8d9ad84
dda2132
a9f9480
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,18 @@ | ||
public class Deadline extends Task { | ||
String deadline; | ||
|
||
public Deadline(String description, String deadline) { | ||
super(description); | ||
this.deadline = deadline; | ||
} | ||
|
||
@Override | ||
public String getStatusIcon() { | ||
return (isDone ? "[\u2713]" : "[\u2718]"); //return tick or X symbols | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[D]" + super.getStatusIcon() + this.description + " (by:" + this.deadline + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,89 @@ | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.Scanner; | ||
|
||
public class Duke { | ||
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. the websites says: "Class variables should never be declared public" |
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
System.out.println(logo + "\nHello im Eu Zin's Duke, he spent thursday afternoon creating me cuz he forgot abt the iP"); | ||
|
||
ArrayList<Task> taskList = new ArrayList<>(); | ||
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. From the websites it says that : "Plural form should be used on names representing a collection of objects." |
||
Scanner scanner = new Scanner(System.in); | ||
while(scanner.hasNextLine()) { | ||
try { | ||
Duke.response(scanner, taskList); | ||
} catch (DukeException e) { | ||
System.out.println(e.toString()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
static void response(Scanner scanner, ArrayList<Task> taskList) throws DukeException { | ||
String userInput = scanner.nextLine(); | ||
String borders = "\n\\ / \\ / \\ / \\ / im not very creative \\ / \\ / \\ / \\ /\n \\ / \\ / \\ / \\ / EuZin's Duke \\ / \\ / \\ / \\ /\n\n"; | ||
String addedMessage = "ok can i've added it\n"; | ||
if (userInput.equals("bye")) { | ||
System.out.println(borders + "Bye. Hope to see you again soon!" + borders); | ||
} else if (userInput.equals("list")) { | ||
int counter = 0; | ||
String returnString = borders + "faster do don't netflix already"; | ||
Iterator<Task> taskIterator = taskList.iterator(); | ||
while (taskIterator.hasNext()) { | ||
Task thisTask = taskIterator.next(); | ||
returnString += "\n" + (counter + 1) + ". " + thisTask.toString(); | ||
counter++; | ||
} | ||
System.out.println(returnString + "\n" + borders); | ||
response(scanner, taskList); | ||
} else if (userInput.startsWith("done")) { | ||
String returnString = borders + "ok sure good job i guess\n"; | ||
int taskDone = Integer.parseInt(userInput.substring(5)); | ||
Task thisTask = taskList.get(taskDone - 1); | ||
thisTask.done(); | ||
returnString += thisTask.toString(); | ||
System.out.println(returnString + "\n" + borders); | ||
response(scanner, taskList); | ||
} else if (userInput.startsWith("todo")) { | ||
if (userInput.equals("todo")) throw new ToDoException(); | ||
Task thisTask = new Task(userInput); | ||
taskList.add(thisTask); | ||
System.out.println(borders + addedMessage + thisTask.toString().replace("todo ","") + "\n" + | ||
"Now got " + taskList.size() + " task in the list\n" + borders); | ||
Duke.response(scanner, taskList); | ||
} else if (userInput.startsWith("deadline")) { | ||
if (userInput.equals("deadline")) { | ||
throw new deadlineException(); | ||
} | ||
String[] StringArr = userInput.split(" /by"); | ||
Task thisTask = new Deadline(StringArr[0].replace("deadline ", ""), StringArr[1]); | ||
taskList.add(thisTask); | ||
System.out.println(borders + addedMessage + thisTask.toString() + "\n" + | ||
"Now got " + taskList.size() + " task in the list\n" + borders); | ||
Duke.response(scanner, taskList); | ||
} else if (userInput.startsWith("event")) { | ||
if (userInput.equals("event")) throw new eventException(); | ||
String[] StringArr = userInput.split(" /at"); | ||
Task thisTask = new Event(StringArr[0].replace("event ", ""), StringArr[1]); | ||
taskList.add(thisTask); | ||
System.out.println(borders + addedMessage + thisTask.toString() + "\n" + | ||
"Now got " + taskList.size() + " task in the list\n" + borders); | ||
Duke.response(scanner, taskList); | ||
} else if (userInput.startsWith("delete")) { | ||
if (userInput.equals("delete")) throw new deleteException(); | ||
int indexDeleted = Integer.parseInt(userInput.replace("delete ", "")); | ||
if (indexDeleted > taskList.size()) throw new deleteException(); | ||
else { | ||
Task thisTask = taskList.get(indexDeleted - 1); | ||
taskList.remove(indexDeleted - 1); | ||
System.out.println(borders + "ok delete this task alr:\n" + thisTask + "\nNow you left " + taskList.size() + " task(s) left\n" + borders); | ||
Duke.response(scanner, taskList); | ||
} | ||
} else { | ||
throw new DukeException(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
public class DukeException extends Throwable { | ||
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. the websites says: "Class variables should never be declared public" |
||
|
||
public String toString() { | ||
return "Duke is too dumb, Duke dunno what you mean"; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
public class Event extends Task{ | ||
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. the websites says: "Class variables should never be declared public" |
||
String timeFrame; | ||
|
||
public Event(String description, String timeFrame) { | ||
super(description); | ||
this.timeFrame = timeFrame; | ||
} | ||
|
||
@Override | ||
public String getStatusIcon() { | ||
return (isDone ? "[\u2713]" : "[\u2718]"); //return tick or X symbols | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[E]" + getStatusIcon() + this.description + " (at:" + this.timeFrame + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class Task { | ||
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. the websites says: "Class variables should never be declared public" |
||
protected String description; | ||
protected boolean isDone; | ||
|
||
public Task(String description) { | ||
this.description = description; | ||
this.isDone = false; | ||
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "[\u2713]" : "[\u2718]"); //return tick or X symbols | ||
} | ||
|
||
public void done() { | ||
this.isDone = true; | ||
} | ||
|
||
public String toString(){ | ||
return "[T]" + this.getStatusIcon() + this.description; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
public class ToDoException extends DukeException { | ||
|
||
public String toString() { | ||
return "what todo gimme smth to write pls"; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public class deadlineException extends DukeException { | ||
|
||
public String toString() { | ||
return "what deadline gimme smth to write pls"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class deleteException extends DukeException { | ||
public String toString() { | ||
return "delete whaaaaaaaaat"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class eventException extends DukeException { | ||
public String toString() { | ||
return "what event gimme smth to write pls"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,62 @@ | ||
Hello from | ||
____ _ | ||
____ _ | ||
| _ \ _ _| | _____ | ||
| | | | | | | |/ / _ \ | ||
| |_| | |_| | < __/ | ||
|____/ \__,_|_|\_\___| | ||
|
||
Hello im Eu Zin's Duke, he spent thursday afternoon creating me cuz he forgot abt the iP | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
ok can i've added it | ||
[T][✘]bring dogs for walk | ||
Now got 1 task in the list | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
ok can i've added it | ||
[E][✘]birthday party (at: tonight) | ||
Now got 2 task in the list | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
ok can i've added it | ||
[D][✘]finish tutorial (by: today) | ||
Now got 3 task in the list | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
ok sure good job i guess | ||
[✓] [E][✓]birthday party (at: tonight) | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
faster do don't netflix already | ||
1. [T][✘]todo bring dogs for walk | ||
2. [E][✓]birthday party (at: tonight) | ||
3. [D][✘]finish tutorial (by: today) | ||
|
||
\ / \ / \ / \ / im not very creative \ / \ / \ / \ / | ||
\ / \ / \ / \ / EuZin's Duke \ / \ / \ / \ / | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
todo bring dogs for walk | ||
event birthday party /at tonight | ||
deadline finish tutorial /by today | ||
done 2 | ||
list |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
@ECHO OFF | ||
|
||
REM create bin directory if it doesn't exist | ||
if not exist ..\bin mkdir ..\bin | ||
if not exist C:\Users\euzun\IdeaProjects\ip\bin mkdir C:\Users\euzun\IdeaProjects\ip\bin | ||
|
||
REM delete output from previous run | ||
del ACTUAL.TXT | ||
|
||
REM compile the code into the bin folder | ||
javac -cp ..\src -Xlint:none -d ..\bin ..\src\main\java\Duke.java | ||
javac -cp ..\src -Xlint:none -d ..\bin ..\src\main\java\*.java | ||
IF ERRORLEVEL 1 ( | ||
echo ********** BUILD FAILURE ********** | ||
exit /b 1 | ||
) | ||
REM no error here, errorlevel == 0 | ||
|
||
REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT | ||
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT | ||
java -classpath C:\Users\euzun\IdeaProjects\ip\bin Duke < input.txt > ACTUAL.TXT | ||
|
||
REM compare the output to the expected output | ||
FC ACTUAL.TXT EXPECTED.TXT |
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.
the websites says: "Class variables should never be declared public"
So, perhaps it should not public.