Skip to content

Commit

Permalink
A-JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
gx-huang committed Feb 2, 2020
1 parent c3bd8a5 commit 3491dd7
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion data/tasks.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
D/dividefalse/dividethis/divide1997-08-08
E/dividetrue/dividethis/dividethat
5 changes: 2 additions & 3 deletions src/main/java/Deadlines.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ public Deadlines(String description, Boolean isDone, String by) {
}

public String getDeadline() {
return this.by.toString();
return this.by;
}

@Override
public String toString() {
LocalDate date = LocalDate.parse(by);
Format formatter = new SimpleDateFormat("MMM");
String simpleMonth = date.getMonth().toString().substring(0,3);
String formattedDate = simpleMonth + " " + date.getDayOfMonth() + " " + date.getYear();
return "[D]" + super.toString() + "(by:" + formattedDate + ")";
return "[D]" + super.toString() + " (By: " + formattedDate + ")";
}
}
2 changes: 1 addition & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void run() {

@Override
public void start(Stage stage) {
Label helloWorld = new Label("Hello World!"); // Creating a new Label control
Label helloWorld = new Label("LIBERTY PRIME IS ONLINE"); // Creating a new Label control
Scene scene = new Scene(helloWorld); // Setting the scene to be our Label

stage.setScene(scene); // Setting the stage to show our screen
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/DukeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public UserText parseCommand() {
} else if (action.equalsIgnoreCase(("todo"))) {
DukeUI.showCreationMsg();
if (command_broken.length == 1) {
throw new DukeException("Ooops! The description of a ToDo cannot be empty.");
throw new DukeException("THE DESCRIPTION OF TODO CANNOT BE EMPTY");
}
tasks.addInput(new ToDos(command_broken[1], false));

Expand All @@ -69,7 +69,7 @@ public UserText parseCommand() {
}

} else {
throw new DukeException("Ooops! I'm sorry, i don't know what it means");
throw new DukeException("UNABLE TO COMPREHEND");
}

} catch (DukeException exception) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/DukeStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public UserText readText() {
tasks.add(task);
}
} catch (IOException ioException) {

System.out.println(ioException.getMessage());
}
return tasks;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/DukeUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static void showWelcomeMessage () {
+ "| |_____| |_| |_/ / |___| |\\ \\ | | | | | | | |\\ \\ _| |_| | | || |___\n"
+ "\\_____/\\___/\\____/\\____/\\_| \\_| \\_/ \\_/ \\_| \\_| \\_|\\___/\\_| |_/\\____/\n";
System.out.println(logo);
System.out.println("LIBERTY PRIME IS ONLINE");
System.out.println("DEMOCRACY IS NON NEGOTIABLE");
}

Expand All @@ -32,10 +31,12 @@ public static void showCreationMsg() {
}

public static void showDeleteMsg() {
System.out.println("OBSTRUCTION DETECTED. PROBABILITY OF DETERENCE: 0%");
System.out.println("OBSTRUCTION ELIMINATED");
}

public static void showFindMsg() {
System.out.println("TARGET FOUND");
}

public static void showCurrentListSize(int size) {System.out.println("NOW YOU HAVE " + size + " TARGETS TO ELIMINATE");}
}
2 changes: 1 addition & 1 deletion src/main/java/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public String getVenue() {

@Override
public String toString() {
return "[E]" + super.toString() + "(at:" + at + ")";
return "[E]" + super.toString() + " (At: " + at + ")";
}
}
1 change: 1 addition & 0 deletions src/main/java/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static void main(String[] args) {
Application.launch(Duke.class, args);
Duke duke = new Duke();
duke.run();

}
}

3 changes: 2 additions & 1 deletion src/main/java/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public boolean isDone() {
return isDone;
}

//returns "O" if done, "X" if not
public String getStatusIcon() {
return (isDone ? "O" : "X"); //return tick or X symbols
return (isDone ? "O" : "X");
}

public String getDescription() {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/UserText.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public UserText() {

public void addInput(Task s) {
this.allTasks.add(s);
System.out.println("Now you have " + allTasks.size() + " tasks in the list.");
DukeUI.showCurrentListSize(allTasks.size());
}

public void printTasks() {
int count = 1;
System.out.println("Here is your list");
System.out.println("HERE IS YOUR LIST");
for (Task s : allTasks) {
System.out.println(count + ". " + s);
count++;
Expand All @@ -37,13 +37,11 @@ public void add(Task task) {

public void markDone(int taskNo) {
allTasks.get(taskNo - 1).markAsDone();
System.out.println("Nice! I marked this task as done");
}

public void removeTask(int taskNo) {
Task tempTask = allTasks.remove(taskNo - 1);
System.out.println("Noted. I have removed this task");
System.out.println(" " + tempTask);
System.out.println("Now you have " + allTasks.size() + " tasks in the list.");
DukeUI.showCurrentListSize(allTasks.size());
}
}
20 changes: 20 additions & 0 deletions src/test/java/DeadlineTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class DeadlineTest {

@Test
public void testStringConvert() {
assertEquals("[D][X] read book (By: JAN 1 2020)",
new Deadlines("read book",false, "2020-01-01").toString());
assertEquals("[D][O] read book (By: JAN 1 2020)",
new Deadlines("read book", true, "2020-01-01").toString());
}

@Test
public void testGetDeadline() {
assertEquals("2020-01-01",
new Deadlines("read book", true, "2020-01-01").getDeadline());
}
}
14 changes: 14 additions & 0 deletions src/test/java/ToDoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ToDoTest {

@Test
public void testStringConvert() {
assertEquals("[T][X] read book",
new ToDos("read book", false).toString());
assertEquals("[T][O] read book",
new ToDos("read book", true).toString());
}
}

0 comments on commit 3491dd7

Please sign in to comment.