Skip to content

Commit

Permalink
Added Junit
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeyou committed Sep 6, 2019
1 parent 33338cd commit 5efdaac
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/main/java/Duke.java → src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package duke;

import duke.logic.*;
import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.Todo;

import java.io.FileNotFoundException;
import java.lang.reflect.Array;

Expand Down Expand Up @@ -72,7 +80,7 @@ public void run() {
} else {
tasks.addTask(new Event(description, secondString));
}
} else {//all other keywords not part of Duke's task handling schedule
} else {//all other keywords not part of duke.Duke's duke.task handling schedule
throw new DukeException(" OOPS!!! I'm sorry, but I don't know what that means :-(");
}
} catch (DukeException de) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java.io.FileNotFoundException;
package duke.logic;

public class DukeException extends Exception {
public DukeException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.logic;

import java.lang.reflect.Array;

public class Parser {
Expand All @@ -14,7 +16,7 @@ public void parse() { //cannot use "|" as a replacement
System.out.println(temp);
String[] tempArr = temp.split(":");
command = (String)Array.get(tempArr, 0);
if(tempArr.length > 1) { //account for the fact that commands like "list" do not have task details
if(tempArr.length > 1) { //account for the fact that commands like "list" do not have duke.task details
taskDetails = ((String) Array.get(tempArr, 1)).trim();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package duke.logic;

import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.Todo;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke.logic;

import duke.task.Task;

import java.util.ArrayList;

/**
Expand Down Expand Up @@ -33,20 +37,20 @@ public void printList() {
}

/**
* Sets a task in a specified position in listOfTasks as done.
* Sets a duke.task in a specified position in listOfTasks as done.
*
* @param number Specified index of task.Task object in listOfTasks.
* @param number Specified index of duke.task.duke.task.Task object in listOfTasks.
*/
public void setTaskAsDone(int number) {
Task temp = this.listOfTasks.get(number - 1);
temp.setDone();
}

/**
* Returns a task.Task object in a specified position in listOfTasks.
* Returns a duke.task.duke.task.Task object in a specified position in listOfTasks.
*
* @param number Specified index of task.Task object in listOfTasks.
* @return task.Task
* @param number Specified index of duke.task.duke.task.Task object in listOfTasks.
* @return duke.task.duke.task.Task
*/
public Task getTask(int number) { //what about case where it is empty?
return this.listOfTasks.get(number);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/Ui.java → src/main/java/duke/logic/Ui.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke.logic;

import duke.task.Task;

import java.util.Scanner;

public class Ui {
Expand Down Expand Up @@ -38,26 +42,26 @@ public void showWelcome() {
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("Hello! I'm Duke\nWhat can I do for you?" );
System.out.println("Hello! I'm duke.Duke\nWhat can I do for you?" );
}
public void showDone(Task task) {
this.showLine();
System.out.println(" Nice! I've marked this task as done:");
System.out.println(" Nice! I've marked this duke.task as done:");
System.out.println(" " + task);
this.showLine();
this.separationline();
}
public void showDelete(Task task, int size) {
this.showLine();
System.out.println(" Nice! I've removed this task:");
System.out.println(" Nice! I've removed this duke.task:");
System.out.println(" " + task);
System.out.println(" Now you have " + size + " tasks in the list.");
this.showLine();
this.separationline();
}
public void showAdd(Task task, int size) {
this.showLine();
System.out.println(" Got it. I've added this task:");
System.out.println(" Got it. I've added this duke.task:");
System.out.println(" " + task);
System.out.println(" Now you have " + size + " tasks in the list.");
this.showLine();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Date.java → src/main/java/duke/task/Date.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

import java.lang.reflect.Array;

public class Date {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

import java.lang.reflect.Array;

public class Deadline extends Task {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

import java.lang.reflect.Array;

public class Event extends Task {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Task.java → src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

public class Task {
private String description;
public boolean done;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/Time.java → src/main/java/duke/task/Time.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

public class Time {
private int hour;
private int minute;
Expand All @@ -23,6 +25,7 @@ public String toString() {
} else {
timeString.append(this.hour);
if (this.minute != 0) {
timeString.append(":");
timeString.append(this.minute);
}
timeString.append("am");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Todo.java → src/main/java/duke/task/Todo.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke.task;

public class Todo extends Task {

public Todo(String description) {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/duke/task/TaskTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import
public class TaskTest {
@Test
public void testStringConversion() {
Assertions.assertEquals("[T][✗] eat", new Todo("eat").toString());
Assertions.assertEquals("[D][✗] read by: 6th September 2019, 740pm", new Deadline("read", "06/09/2019 1940");
Assertions.assertEquals("[D][✗] meeting Jason at: 6th September 2019, 8:02pm",
new Event("meeting Jason", "06/09/2019 2002"));
}
public void testSetDone() {
Task temp = new Todo("sleep");
temp.setDone();
Assertions.assertEquals(done, temp.isDone());
}
}

0 comments on commit 5efdaac

Please sign in to comment.