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

Tan Eu Zin iP #470

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3b19ba1
Add Gradle support
May 24, 2020
5fa8ff1
This is level 1, I hope im committing this correctly.
euzintan Aug 20, 2020
913c098
Level 2
euzintan Aug 20, 2020
193dc5b
Level 2
euzintan Aug 20, 2020
41f3eac
Revert "Level 2"
euzintan Aug 20, 2020
f699f2b
Level 3
euzintan Aug 20, 2020
fc87ead
Level 4:
euzintan Aug 20, 2020
60c2438
Merge remote-tracking branch 'origin/master' into master
euzintan Aug 20, 2020
7569542
Added Automated Text UI Testing
euzintan Aug 20, 2020
4deb825
Implemented Duke specific extensions
euzintan Aug 20, 2020
1cd2bc0
Implemented Delete
euzintan Aug 20, 2020
0c53018
Updated Exceptions to continue accepting input after exceptions thrown
euzintan Aug 20, 2020
30be8f6
Created new class Storage to deal with saving and loading
euzintan Sep 1, 2020
c290955
Created new class Storage to deal with saving and loading
euzintan Sep 1, 2020
37b18f1
Changed Deadline class so Duke can deal with LocalDate and LocalTime …
euzintan Sep 1, 2020
5c8e64f
Merge branch 'branch-Level-8'
euzintan Sep 1, 2020
59863e8
Resolved conflicts caused during merging of save to harddisk feature …
euzintan Sep 1, 2020
cc4252f
Created Parser and Ui classes
euzintan Sep 1, 2020
c6fb802
Added JUnit Tests for Parser
euzintan Sep 1, 2020
aef36dd
Added JavaDoc Comments
euzintan Sep 1, 2020
cb2a2ce
Implemented Find feature
euzintan Sep 1, 2020
bb86215
Made changes to comply to Coding Standards
euzintan Sep 1, 2020
e1d5ed0
Resolved conflicts when merging increment branches
euzintan Sep 1, 2020
46425bf
Merge remote-tracking branch 'origin/add-gradle-support'
euzintan Sep 1, 2020
dc639f2
Prepared Duke for GUI, tested out Hello World
euzintan Sep 2, 2020
66408eb
Created Working GUI for Duke
euzintan Sep 3, 2020
623bee8
Added assertions in Parser class to make sure input of the user is ap…
euzintan Sep 7, 2020
e747751
Improve Code Quality
euzintan Sep 7, 2020
779e689
Created shadowJar file
euzintan Sep 7, 2020
5ea632b
Merge pull request #1 from euzintan/branch-Assertions
euzintan Sep 8, 2020
e5eacc7
Merge branch 'branch-A-CodeQuality'
euzintan Sep 8, 2020
cd290bf
Implemented FixedDurationTasks so that durations can be added to all …
euzintan Sep 8, 2020
b1d46b4
SLAPed harder to reduce abstraction problems
euzintan Sep 13, 2020
d21247f
Set theme jekyll-theme-slate
euzintan Sep 13, 2020
e61f350
Edited README.md to be a proper User Guide
euzintan Sep 14, 2020
56b2c52
Merge from GitHub to change theme
euzintan Sep 14, 2020
8d9ad84
Improved User Guide
euzintan Sep 15, 2020
dda2132
Changed Ui Screenshot
euzintan Sep 15, 2020
a9f9480
Fixed Duke to work with Mac
euzintan Sep 18, 2020
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
18 changes: 18 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class Deadline extends Task {
Copy link

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.

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 + ")";
}
}
83 changes: 81 additions & 2 deletions src/main/java/Duke.java
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 {
Copy link

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.

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<>();
Copy link

Choose a reason for hiding this comment

The 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."
So I think perhaps it should be taskLists instead of taskList.

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();
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class DukeException extends Throwable {
Copy link

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.


public String toString() {
return "Duke is too dumb, Duke dunno what you mean";
}

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

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.

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 + ")";
}
}
21 changes: 21 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Task {
Copy link

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.

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;
}
}
7 changes: 7 additions & 0 deletions src/main/java/ToDoException.java
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";
}

}
6 changes: 6 additions & 0 deletions src/main/java/deadlineException.java
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";
}
}
5 changes: 5 additions & 0 deletions src/main/java/deleteException.java
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";
}
}
5 changes: 5 additions & 0 deletions src/main/java/eventException.java
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";
}
}
59 changes: 57 additions & 2 deletions text-ui-test/EXPECTED.TXT
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 \ / \ / \ / \ /




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 bring dogs for walk
event birthday party /at tonight
deadline finish tutorial /by today
done 2
list
6 changes: 3 additions & 3 deletions text-ui-test/runtest.bat
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