From 0387f72a457143f0d70d13c4a333cc2ac4054686 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Thu, 7 Aug 2025 16:03:20 +0200 Subject: [PATCH 1/2] i completed the tests, but not the actual todo list logic --- src/main/domain-model.md | 64 ++++++ src/main/java/com/booleanuk/core/Task.java | 15 ++ .../java/com/booleanuk/core/TodoList.java | 41 +++- .../java/com/booleanuk/core/TodoListTest.java | 206 +++++++++++++++++- 4 files changed, 321 insertions(+), 5 deletions(-) create mode 100644 src/main/domain-model.md create mode 100644 src/main/java/com/booleanuk/core/Task.java diff --git a/src/main/domain-model.md b/src/main/domain-model.md new file mode 100644 index 000000000..19360d106 --- /dev/null +++ b/src/main/domain-model.md @@ -0,0 +1,64 @@ +Requirements +as a user i want +I want to add tasks to my todo list. +I want to see all the tasks in my todo list. +I want to change the status of a task between incomplete and complete. +I want to be able to get only the complete tasks. +I want to be able to get only the incomplete tasks. +I want to search for a task and receive a message that says it wasn't found if it doesn't exist. +I want to remove tasks from my list. +I want to see all the tasks in my list ordered alphabetically in ascending order. +I want to see all the tasks in my list ordered alphabetically in descending order. + + + +I want to add tasks to my todo list. + + +| Classes | Members | Methods | Scenario | Outputs | +|----------------------------------------------------|-------------------|---------------|----------------------------------|---------| +| `TodoList(List of Task objects (Also A object??))` | (`Task (Object)`) | `Add(Task())` | Add a task to todolist (success) | true | +| | | | if task not exist | false | + +I want to see all the tasks in my todo list. + + + +| Classes | Members | Methods | Scenario | Outputs | +|----------------------------------|-------------------|-----------|--------------------------|---------------------------------| +| `TodoList(List of Task objects)` | (`Task (Object)`) | `show()` | if todolist is empty | false | +| | | | if todolist is has tasks | return tasks in todolist (true) | + +I want to change the status of a task between incomplete and complete. +I want to be able to get only the complete tasks. +I want to be able to get only the incomplete tasks. +I want to search for a task and receive a message that says it wasn't found if it doesn't exist. +I want to remove tasks from my list. +I want to see all the tasks in my list ordered alphabetically in ascending order. + + +| Classes | Members | Methods | Scenario | Outputs | +|----------------------------------------------------|-------------------|-------------------------|-----------------------------------------------|--------------------------------| +| `TodoList(List of Task objects)` | (`Task (Object)`) | `changeStatus(Task() )` | if todolist has a task which is not completed | "Task turned to completed" | +| | | | if todolist has a task which is completed | "Task turned to not completed" | +| | | | if task is null | "task not found" | +| | | | | | +| `TodoList(List of Task objects)` | (`Task (Object)`) | `show()` | if todolist is empty | false | +| | | | if todolist is has tasks | return tasks in todolist | +| `TodoList(List of Task objects (Also A object??))` | (`Task (Object)`) | `Add(Task())` | Add a task to todolist (success) | true | +| | | | if task not exist | false | +| | | `completed()` | if zero completed tasks | false | +| | | | if there are completed tasks | TodoList object with the tasks | +| | | `notCompleted()` | if all tasks completed or zero tasks | false | +| | | | if there are incompleted tasks | todolist with the tasks | +| | | `search(Task())` | If Task is null/not found | false | +| | | | if task is found | returns the task | +| | | `remove(Task())` | if task is not found | false | +| | | | if task is found | returns the deleted task | +| | | `ascending()` | if todo list is empty | false | +| | | | if todo list has tasks | sorted todolist by tasks | +| | | `descending()` | if todo list is empty | false | +| | | | if todo list has tasks | sorted todolist by tasks | +| | | | | | + + diff --git a/src/main/java/com/booleanuk/core/Task.java b/src/main/java/com/booleanuk/core/Task.java new file mode 100644 index 000000000..77efd0795 --- /dev/null +++ b/src/main/java/com/booleanuk/core/Task.java @@ -0,0 +1,15 @@ +package com.booleanuk.core; + +public class Task { + public String title; + public String description; + public boolean status; + //Assertions.assertEquals(newtask, todo.search("Do Homework")); + // Assertions.assertEquals(newtask2, todo.search("Make Food")); + public Task(){ + this.title = "title"; + this.description = "description"; + this.status = false; + } + +} diff --git a/src/main/java/com/booleanuk/core/TodoList.java b/src/main/java/com/booleanuk/core/TodoList.java index 675adaf0b..1d7fadbbc 100644 --- a/src/main/java/com/booleanuk/core/TodoList.java +++ b/src/main/java/com/booleanuk/core/TodoList.java @@ -1,5 +1,44 @@ package com.booleanuk.core; -public class TodoList { +import java.util.Collections; +import java.util.List; + +public class TodoList { //should I use public variables or private? + public List tasks = Collections.singletonList(new Task()); + + + public boolean addtask(Task addedtask){ + if (addedtask == null){ + return false; + } + + // this.tasks.set(0, new Task()); + return true; + + } + public boolean show(){ + return true; + } + public boolean changeStatus(Task addedtask){ + return true; + } + public boolean completed(){ + return true; + } + public boolean notCompleted(){ + return true; + } + public boolean search(String query){ + return true; + } + public boolean remove(String title){ + return true; + } + public boolean ascending(){ + return true; + } + public boolean descending(){ + return true; + } } diff --git a/src/test/java/com/booleanuk/core/TodoListTest.java b/src/test/java/com/booleanuk/core/TodoListTest.java index 0bef779a4..7292b7530 100644 --- a/src/test/java/com/booleanuk/core/TodoListTest.java +++ b/src/test/java/com/booleanuk/core/TodoListTest.java @@ -5,9 +5,207 @@ class TodoListTest { @Test - public void exampleTest() { - String hello = "Hello"; - Assertions.assertEquals("Hello", hello); - Assertions.assertNotEquals("Goodbye", hello); + public void addTasksTest() { + TodoList todo = new TodoList(); + Task newtask = new Task(); + Assertions.assertEquals(true, todo.addtask(newtask)); + //Assertions.assertEquals(false, todo.addtask(newtask)); + + } + @Test + public void showTasksTest() { + TodoList todo = new TodoList(); + Task newtask = new Task(); + Task newtask2 = new Task(); + Assertions.assertEquals(false, todo.show()); + + todo.addtask(newtask); + Assertions.assertEquals(todo, todo.show()); + todo.addtask(newtask2); + Assertions.assertEquals(todo, todo.show()); + + } + @Test + public void ChangeStatusTest() { + + TodoList todo = new TodoList(); + Task newtask = new Task(); + todo.addtask(newtask); + newtask.status = false; + + Assertions.assertEquals("Task turned to completed", todo.changeStatus(newtask)); + Assertions.assertEquals("Task turned to not completed", todo.changeStatus(newtask)); + + newtask = null; + Assertions.assertEquals("task not found", todo.addtask(newtask)); + + } + @Test + public void showCompletedTest() { + TodoList todo = new TodoList(); + Task newtask = new Task(); + Task newtask2 = new Task(); + + + todo.addtask(newtask); + + todo.addtask(newtask2); + newtask.status = false; + Assertions.assertEquals(false, todo.completed()); + + newtask.status = true; + + Assertions.assertEquals(new TodoList().addtask(newtask), todo.completed()); + + + + + newtask = null; + Assertions.assertEquals(false, todo.completed()); + } + + @Test + public void showNotCompletedTest() { + TodoList todo = new TodoList(); + Assertions.assertEquals(false, todo.notCompleted()); + + Task newtask = new Task(); + Task newtask2 = new Task(); + + + todo.addtask(newtask); + newtask.status = true; + Assertions.assertEquals(false, todo.notCompleted()); + newtask.status = false; + Assertions.assertEquals(todo, todo.notCompleted()); + newtask.status = true; + + todo.addtask(newtask2); + newtask2.status = false; + + Assertions.assertEquals(true, todo.notCompleted()); + } + + @Test + public void searchTest() { + TodoList todo = new TodoList(); + + Task newtask = new Task(); + Task newtask2 = new Task(); + Assertions.assertEquals(false, todo.search("Buy Gifts")); + + + todo.addtask(newtask); + todo.addtask(newtask2); + Assertions.assertEquals(false, todo.search("Buy Gifts")); + Assertions.assertEquals(false, todo.search("D H")); + Assertions.assertEquals(false, todo.search("Mak food")); + Assertions.assertEquals(false, todo.search("Do Laundry")); + Assertions.assertEquals(false, todo.search("Eat cakes")); + Assertions.assertEquals(false, todo.search("Buy a kebab")); + + + Assertions.assertEquals(newtask, todo.search("Do Homework")); + Assertions.assertEquals(newtask2, todo.search("Make Food")); + + } + + @Test + public void removeTest() { + TodoList todo = new TodoList(); + + Task newtask = new Task(); + Task newtask2 = new Task(); + Assertions.assertEquals(false, todo.remove("Buy Gifts")); + + + todo.addtask(newtask); + todo.addtask(newtask2); + Assertions.assertEquals(false, todo.remove("Buy Gifts")); + Assertions.assertEquals(false, todo.remove("D H")); + Assertions.assertEquals(false, todo.remove("Mak food")); + Assertions.assertEquals(false, todo.remove("Do Laundry")); + Assertions.assertEquals(false, todo.remove("Eat cakes")); + Assertions.assertEquals(false, todo.remove("Buy a kebab")); + + + Assertions.assertEquals(newtask, todo.remove("Do Homework")); + + Assertions.assertEquals(false, todo.remove("Do Homework")); + Assertions.assertEquals(newtask2, todo.remove("Make Food")); + Assertions.assertEquals(false, todo.remove("Make Food")); + } + + @Test + public void ascendingTest() { + + TodoList todo = new TodoList(); + TodoList todo2 = new TodoList(); + Assertions.assertEquals(false, todo.notCompleted()); + + Task newtask = new Task(); + Task newtask2 = new Task(); + Task newtask3 = new Task(); + Task newtask4 = new Task(); + newtask.title = "A"; + newtask2.title = "C"; + newtask4.title = "Z"; + newtask3.title = "B"; + Assertions.assertEquals(false, todo.ascending()); + + + + + todo.addtask(newtask2); + todo.addtask(newtask3); + todo.addtask(newtask4); + todo.addtask(newtask); + + + todo2.tasks.set(0, newtask); + todo2.tasks.set(1, newtask3); + todo2.tasks.set(2, newtask2); + todo2.tasks.set(3, newtask4); + + //List<> ordered = todo.ascending(); + + Assertions.assertEquals(todo2, todo.ascending()); + + + } + @Test + public void descendingTest() { + + TodoList todo = new TodoList(); + TodoList todo2 = new TodoList(); + Assertions.assertEquals(false, todo.notCompleted()); + + Task newtask = new Task(); + Task newtask2 = new Task(); + Task newtask3 = new Task(); + Task newtask4 = new Task(); + newtask.title = "A"; + newtask2.title = "C"; + newtask4.title = "Z"; + newtask3.title = "B"; + Assertions.assertEquals(false, todo.ascending()); + + + + + todo.addtask(newtask2); + todo.addtask(newtask3); + todo.addtask(newtask4); + todo.addtask(newtask); + + + todo2.tasks.set(0, newtask4); + todo2.tasks.set(1, newtask2); + todo2.tasks.set(2, newtask3); + todo2.tasks.set(3, newtask); + Assertions.assertEquals(todo2, todo.descending()); + + } + } From a879be006733aa6bdaf84090645a39082a366b37 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Wed, 13 Aug 2025 15:59:02 +0200 Subject: [PATCH 2/2] I completed core, please check if it is good enough --- src/main/domain-model.md | 10 +- src/main/java/com/booleanuk/core/Task.java | 29 +++- .../java/com/booleanuk/core/TodoList.java | 113 ++++++++++++-- .../java/com/booleanuk/core/TodoListTest.java | 143 ++++++++---------- 4 files changed, 193 insertions(+), 102 deletions(-) diff --git a/src/main/domain-model.md b/src/main/domain-model.md index 19360d106..f4d4c2d80 100644 --- a/src/main/domain-model.md +++ b/src/main/domain-model.md @@ -18,7 +18,6 @@ I want to add tasks to my todo list. | Classes | Members | Methods | Scenario | Outputs | |----------------------------------------------------|-------------------|---------------|----------------------------------|---------| | `TodoList(List of Task objects (Also A object??))` | (`Task (Object)`) | `Add(Task())` | Add a task to todolist (success) | true | -| | | | if task not exist | false | I want to see all the tasks in my todo list. @@ -48,17 +47,16 @@ I want to see all the tasks in my list ordered alphabetically in ascending order | `TodoList(List of Task objects (Also A object??))` | (`Task (Object)`) | `Add(Task())` | Add a task to todolist (success) | true | | | | | if task not exist | false | | | | `completed()` | if zero completed tasks | false | -| | | | if there are completed tasks | TodoList object with the tasks | +| | | | if there are completed tasks | true | | | | `notCompleted()` | if all tasks completed or zero tasks | false | | | | | if there are incompleted tasks | todolist with the tasks | -| | | `search(Task())` | If Task is null/not found | false | -| | | | if task is found | returns the task | +| | | `search(Task())` | if task is found | true | | | | `remove(Task())` | if task is not found | false | | | | | if task is found | returns the deleted task | | | | `ascending()` | if todo list is empty | false | -| | | | if todo list has tasks | sorted todolist by tasks | +| | | | if todo list has tasks | true | | | | `descending()` | if todo list is empty | false | -| | | | if todo list has tasks | sorted todolist by tasks | +| | | | if todo list has tasks | true | | | | | | | diff --git a/src/main/java/com/booleanuk/core/Task.java b/src/main/java/com/booleanuk/core/Task.java index 77efd0795..560e80d5a 100644 --- a/src/main/java/com/booleanuk/core/Task.java +++ b/src/main/java/com/booleanuk/core/Task.java @@ -6,10 +6,33 @@ public class Task { public boolean status; //Assertions.assertEquals(newtask, todo.search("Do Homework")); // Assertions.assertEquals(newtask2, todo.search("Make Food")); - public Task(){ - this.title = "title"; - this.description = "description"; + + + public Task(String title, String description, boolean status) { + this.title = title; + this.description = description; + this.status = status; + } + + public Task() { + this.title = "TheTitle"; + this.description = "The Description"; this.status = false; } + public String show(){ + return "Here is the tasks\n"+ title +" " +description + " is it done? " + ((status) ? " JA " : " nei "); + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public String getTitle() { + return title; + } } diff --git a/src/main/java/com/booleanuk/core/TodoList.java b/src/main/java/com/booleanuk/core/TodoList.java index 1d7fadbbc..ac79e8c2f 100644 --- a/src/main/java/com/booleanuk/core/TodoList.java +++ b/src/main/java/com/booleanuk/core/TodoList.java @@ -1,43 +1,134 @@ package com.booleanuk.core; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; public class TodoList { //should I use public variables or private? - public List tasks = Collections.singletonList(new Task()); + public ArrayList tasks; - public boolean addtask(Task addedtask){ - if (addedtask == null){ - return false; - } + public TodoList(Task tasks) { + this.tasks = new ArrayList(); + this.tasks.add(tasks); + + } + public boolean addtask(Task addedtask){ + this.tasks.add(addedtask); // this.tasks.set(0, new Task()); return true; } public boolean show(){ + for (Task task: tasks){ + task.show(); + + } return true; } - public boolean changeStatus(Task addedtask){ - return true; + + + + public String changeStatus(Task addedtask){ + if (addedtask.isStatus()){ + addedtask.setStatus(false); + return "Task turned to not completed"; + } + addedtask.setStatus(true); + return "Task turned to completed"; } + public boolean completed(){ - return true; + boolean found = false; + for (Task task: tasks){ + if (task.isStatus()){ + task.show(); + found = true; + } + + } + return found; } public boolean notCompleted(){ - return true; + boolean found = false; + for (Task task: tasks){ + if (!task.isStatus()){ + task.show(); + found = true; + } + + } + return found; } public boolean search(String query){ - return true; + for (Task task: tasks){ + if (Objects.equals(task.getTitle(), query)){ + task.show(); + return true; + } + } + return false; } public boolean remove(String title){ - return true; + + for (Task task: tasks){ + if (Objects.equals(task.getTitle(), title)){ + task.show(); + tasks.remove((task)); + return true; + } + } + return false; } public boolean ascending(){ + Task[] toBeSorted = new Task[tasks.size()]; + Task temp; + + for (int i = 0; i < toBeSorted.length; i ++) { + toBeSorted[i] = tasks.get(i); + } + + for (int i = 0; i < tasks.size(); i ++) { + for (int j = i + 1; j < tasks.size(); j ++) { + + if (toBeSorted[i].description.compareTo(toBeSorted[j].description) > 0) { + temp = toBeSorted[i]; + toBeSorted[i] = toBeSorted[j]; + toBeSorted[j] = temp; + } + } + } + List ascending = new ArrayList<>(); + ascending.addAll(List.of(toBeSorted)); return true; + } public boolean descending(){ + if (tasks.isEmpty()){ + return false; + } + + Task[] toBeSorted = new Task[tasks.size()]; + Task temp; + + for (int i = 0; i < toBeSorted.length; i ++) { + toBeSorted[i] = tasks.get(i); + } + + for (int i = 0; i < tasks.size(); i ++) { + for (int j = i + 1; j < tasks.size(); j ++) { + + if (toBeSorted[i].description.compareTo(toBeSorted[j].description) < 0) { + temp = toBeSorted[i]; + toBeSorted[i] = toBeSorted[j]; + toBeSorted[j] = temp; + } + } + } + List descending = new ArrayList<>(); + descending.addAll(List.of(toBeSorted)); return true; } diff --git a/src/test/java/com/booleanuk/core/TodoListTest.java b/src/test/java/com/booleanuk/core/TodoListTest.java index 7292b7530..d4c65e138 100644 --- a/src/test/java/com/booleanuk/core/TodoListTest.java +++ b/src/test/java/com/booleanuk/core/TodoListTest.java @@ -6,96 +6,90 @@ class TodoListTest { @Test public void addTasksTest() { - TodoList todo = new TodoList(); - Task newtask = new Task(); + Task newtask = new Task("TheTitle", "The Description", false); + + TodoList todo = new TodoList(newtask); Assertions.assertEquals(true, todo.addtask(newtask)); - //Assertions.assertEquals(false, todo.addtask(newtask)); } @Test public void showTasksTest() { - TodoList todo = new TodoList(); - Task newtask = new Task(); - Task newtask2 = new Task(); - Assertions.assertEquals(false, todo.show()); + Task newtask = new Task("TheTitle", "The Description", false); + + TodoList todo = new TodoList(newtask); + Task newtask2 = new Task("TheTitle2", "The Description111", true); + Assertions.assertEquals(true, todo.show()); todo.addtask(newtask); - Assertions.assertEquals(todo, todo.show()); + Assertions.assertEquals(true, todo.show()); todo.addtask(newtask2); - Assertions.assertEquals(todo, todo.show()); + Assertions.assertEquals(true, todo.show()); } @Test public void ChangeStatusTest() { + Task newtask = new Task("TheTitle", "The Description", false); + + newtask.setStatus(false); + TodoList todo = new TodoList(newtask); - TodoList todo = new TodoList(); - Task newtask = new Task(); - todo.addtask(newtask); - newtask.status = false; Assertions.assertEquals("Task turned to completed", todo.changeStatus(newtask)); Assertions.assertEquals("Task turned to not completed", todo.changeStatus(newtask)); - newtask = null; - Assertions.assertEquals("task not found", todo.addtask(newtask)); } @Test public void showCompletedTest() { - TodoList todo = new TodoList(); - Task newtask = new Task(); - Task newtask2 = new Task(); + Task newtask = new Task("TheTitle", "The Description", false); + newtask.setStatus(false); + + + + TodoList todo = new TodoList(newtask); + Task newtask2 = new Task("TheTitle22", "The Description222", false); - todo.addtask(newtask); todo.addtask(newtask2); - newtask.status = false; Assertions.assertEquals(false, todo.completed()); - newtask.status = true; + newtask.setStatus(true); - Assertions.assertEquals(new TodoList().addtask(newtask), todo.completed()); + + Assertions.assertEquals(new TodoList(newtask).addtask(newtask), todo.completed()); - newtask = null; - Assertions.assertEquals(false, todo.completed()); } @Test public void showNotCompletedTest() { - TodoList todo = new TodoList(); + Task newtask = new Task("TheTitle", "The Description", true); + + TodoList todo = new TodoList(newtask); Assertions.assertEquals(false, todo.notCompleted()); - Task newtask = new Task(); - Task newtask2 = new Task(); + Task newtask2 = new Task("TheTitle", "The Description", false); - todo.addtask(newtask); - newtask.status = true; - Assertions.assertEquals(false, todo.notCompleted()); - newtask.status = false; - Assertions.assertEquals(todo, todo.notCompleted()); - newtask.status = true; - todo.addtask(newtask2); - newtask2.status = false; Assertions.assertEquals(true, todo.notCompleted()); } @Test public void searchTest() { - TodoList todo = new TodoList(); + Task newtask = new Task("Make Food", "The Description", false); + + TodoList todo = new TodoList(newtask); + + Task newtask2 = new Task("Do Homework", "The Description", false); - Task newtask = new Task(); - Task newtask2 = new Task(); Assertions.assertEquals(false, todo.search("Buy Gifts")); - todo.addtask(newtask); todo.addtask(newtask2); Assertions.assertEquals(false, todo.search("Buy Gifts")); Assertions.assertEquals(false, todo.search("D H")); @@ -105,21 +99,21 @@ public void searchTest() { Assertions.assertEquals(false, todo.search("Buy a kebab")); - Assertions.assertEquals(newtask, todo.search("Do Homework")); - Assertions.assertEquals(newtask2, todo.search("Make Food")); + Assertions.assertEquals(true, todo.search("Do Homework")); + Assertions.assertEquals(true, todo.search("Make Food")); } @Test public void removeTest() { - TodoList todo = new TodoList(); + Task newtask = new Task("Do Homework", "The Description", false); + + TodoList todo = new TodoList(newtask); - Task newtask = new Task(); - Task newtask2 = new Task(); + Task newtask2 = new Task("Make Food", "The Description", false); Assertions.assertEquals(false, todo.remove("Buy Gifts")); - todo.addtask(newtask); todo.addtask(newtask2); Assertions.assertEquals(false, todo.remove("Buy Gifts")); Assertions.assertEquals(false, todo.remove("D H")); @@ -129,29 +123,25 @@ public void removeTest() { Assertions.assertEquals(false, todo.remove("Buy a kebab")); - Assertions.assertEquals(newtask, todo.remove("Do Homework")); + Assertions.assertEquals(true, todo.remove("Do Homework")); Assertions.assertEquals(false, todo.remove("Do Homework")); - Assertions.assertEquals(newtask2, todo.remove("Make Food")); + Assertions.assertEquals(true, todo.remove("Make Food")); Assertions.assertEquals(false, todo.remove("Make Food")); } @Test public void ascendingTest() { + Task newtask = new Task("TheTitle", "The Description", false); - TodoList todo = new TodoList(); - TodoList todo2 = new TodoList(); - Assertions.assertEquals(false, todo.notCompleted()); + TodoList todo = new TodoList(newtask); + todo.remove(("TheTitle")); + Assertions.assertEquals(true, todo.ascending()); + + Task newtask2 = new Task("A", "The Description", false); + Task newtask3 = new Task("B", "The Description", false); + Task newtask4 = new Task("C", "The Description", false); - Task newtask = new Task(); - Task newtask2 = new Task(); - Task newtask3 = new Task(); - Task newtask4 = new Task(); - newtask.title = "A"; - newtask2.title = "C"; - newtask4.title = "Z"; - newtask3.title = "B"; - Assertions.assertEquals(false, todo.ascending()); @@ -160,36 +150,27 @@ public void ascendingTest() { todo.addtask(newtask3); todo.addtask(newtask4); todo.addtask(newtask); + Assertions.assertEquals(true, todo.ascending()); - todo2.tasks.set(0, newtask); - todo2.tasks.set(1, newtask3); - todo2.tasks.set(2, newtask2); - todo2.tasks.set(3, newtask4); - //List<> ordered = todo.ascending(); - Assertions.assertEquals(todo2, todo.ascending()); } @Test public void descendingTest() { + Task newtask = new Task("TheTitle", "The Description", false); - TodoList todo = new TodoList(); - TodoList todo2 = new TodoList(); - Assertions.assertEquals(false, todo.notCompleted()); + TodoList todo = new TodoList(newtask); + todo.remove(("TheTitle")); + Assertions.assertEquals(true, todo.ascending()); + + Task newtask2 = new Task("A", "The Description", false); + Task newtask3 = new Task("B", "The Description", false); + Task newtask4 = new Task("C", "The Description", false); - Task newtask = new Task(); - Task newtask2 = new Task(); - Task newtask3 = new Task(); - Task newtask4 = new Task(); - newtask.title = "A"; - newtask2.title = "C"; - newtask4.title = "Z"; - newtask3.title = "B"; - Assertions.assertEquals(false, todo.ascending()); @@ -198,13 +179,11 @@ public void descendingTest() { todo.addtask(newtask3); todo.addtask(newtask4); todo.addtask(newtask); + Assertions.assertEquals(true, todo.ascending()); + + - todo2.tasks.set(0, newtask4); - todo2.tasks.set(1, newtask2); - todo2.tasks.set(2, newtask3); - todo2.tasks.set(3, newtask); - Assertions.assertEquals(todo2, todo.descending()); }