-
Notifications
You must be signed in to change notification settings - Fork 129
Robin Kaga #123
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
Open
Robin-Ka
wants to merge
19
commits into
boolean-uk:main
Choose a base branch
from
Robin-Ka:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Robin Kaga #123
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6b20164
core domain model done
28eb237
added Task class and TaskTest
274f65c
added validation test for Task
4bc8f50
Added Task constructur
1df8082
Added test for completeing tasks
2c3a7db
Added method for completing task
0d74a86
Added tests for getting task name and status
46bc918
Updated domain model and added methods for fetching name/status
4a1231a
Updated domain model and added tests for addTask and removeTask
9f06f06
Added add and remove methods
d725c87
added tests for change status and see tasks (made methods in same com…
308543a
Adeed tests for complete/incomplete view of tasks
14d054b
added methods for complete/incomplete
3e4b781
search test added
4884d82
search method added
809d6cd
added tests for alphebetical methods
9e8a512
added methods for alphabetical
61d9f31
Added files for extension
224f31a
completed extension requirements (except for time/date)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
|
|
||
| ## Task Class | ||
|
|
||
| | Methods | Variables | Scenario | Output | | ||
| |-------------------------|----------------------|-----------------------------|-----------------------| | ||
| | | `boolean completed ` | | | | ||
| | | `String name ` | | | | ||
| | `void completeTask() ` | | A task is completed | Set completed to true | | ||
| | `String getName() ` | | Want to fetch a task name | Return task name | | ||
| | `boolean getStatus() ` | | Want to fetch a task status | Return task status | | ||
| | | | | | | ||
|
|
||
|
|
||
| ## ToDoList Class | ||
|
|
||
| | Methods | Variables | Scenario | Output | | ||
| |-----------------------------------------|------------------------------|----------------------------------------------------|---------------------------------------------------------| | ||
| | | `ArrayList<Task task> list ` | | | | ||
| | ` void addTask(Task task) ` | | Want to add a task to the ToDo List | Adds task to list | | ||
| | ` Arraylist<String> seeAllTasks() ` | | Want to see all tasks in the list | Shows tasks in list | | ||
| | ` void changeStaus(Task task) ` | | Want to change status of existing task | Changes completed variable in chosen task | | ||
| | ` Arraylist<Task> getCompletedTasks() ` | | Want to get only completed tasks | Returns all completed tasks | | ||
| | ` Arraylist<Task> getInompleteTasks() ` | | Want to get only incomplete tasks | Returns all incomplete tasks | | ||
| | ` Task search(String taskName) ` | | Want to search for tasks | Searches for and returns task, and informs if not found | | ||
| | ` void removeTask(String taskName) ` | | Want to remove a task | removes task from list | | ||
| | ` Arraylist<String> alphabeticalA() ` | | Want to see tasks in alphabetical ascending order | Shows tasks in alphabetical ascending order | | ||
| | ` Arraylist<String> alphabeticalD() ` | | Want to see tasks in alphabetical descending order | Shows tasks in alphabetical descending order | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.booleanuk.core; | ||
|
|
||
| public class Task { | ||
|
|
||
| String name; | ||
| boolean completed; | ||
|
|
||
| public Task(String name){ | ||
| this.name = name; | ||
| this.completed = false; | ||
| } | ||
|
|
||
| public String getName(){ | ||
| return this.name; | ||
| } | ||
|
|
||
| public boolean getStatus(){ | ||
| return this.completed; | ||
| } | ||
|
|
||
| public void setStatus(boolean status){ | ||
| this.completed = status; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package com.booleanuk.core; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
|
|
||
| public class ToDoList { | ||
|
|
||
| ArrayList<Task> tasks = new ArrayList<>(); | ||
|
|
||
| public void addTask(Task task){ | ||
| if (!tasks.contains(task)){ | ||
| tasks.add(task); | ||
| } | ||
| } | ||
|
|
||
| public void removeTask(String taskName){ | ||
| tasks.removeIf(task -> task.getName().equals(taskName)); | ||
| } | ||
|
|
||
| public void changeStatus(Task task, boolean completed){ | ||
| if (tasks.contains(task)){ | ||
| task.setStatus(completed); | ||
| } | ||
| } | ||
|
|
||
| public ArrayList<String> seeAllTasks(){ | ||
| ArrayList<String> showTasks = new ArrayList<>(); | ||
| for (int i = 0; i < tasks.size(); i++){ | ||
| showTasks.add(i, tasks.get(i).name); | ||
| } | ||
| return showTasks; | ||
| } | ||
|
|
||
| public ArrayList<Task> getCompletedTasks(){ | ||
| ArrayList<Task> completedTasks = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| if (task.completed){ | ||
| completedTasks.add(task); | ||
| } | ||
| } | ||
| return completedTasks; | ||
| } | ||
|
|
||
| public ArrayList<Task> getIncompleteTasks(){ | ||
| ArrayList<Task> incompleteTasks = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| if (!task.completed){ | ||
| incompleteTasks.add(task); | ||
| } | ||
| } | ||
| return incompleteTasks; | ||
| } | ||
|
|
||
| public Task search(String taskName){ | ||
| for (Task task : tasks){ | ||
| if (task.name.equals(taskName)){ | ||
| return task; | ||
| } | ||
| } | ||
| System.out.println("The task was not found or does not exist!"); | ||
| return null; | ||
| } | ||
|
|
||
| public ArrayList<String> alphabeticalA(){ | ||
| ArrayList<String> alphabeticalAscending = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| alphabeticalAscending.add(task.name); | ||
| } | ||
| Collections.sort(alphabeticalAscending); | ||
| return alphabeticalAscending; | ||
| } | ||
|
|
||
| public ArrayList<String> alphabeticalD(){ | ||
| ArrayList<String> alphabeticalDescending = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| alphabeticalDescending.add(task.name); | ||
| } | ||
| Collections.sort(alphabeticalDescending); | ||
| Collections.reverse(alphabeticalDescending); | ||
| return alphabeticalDescending; | ||
| } | ||
|
|
||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.booleanuk.extension; | ||
|
|
||
| public class Task { | ||
|
|
||
| private static int counter = 0; | ||
| private final int id; | ||
| private String name; | ||
| private boolean completed; | ||
|
|
||
| public Task(String name){ | ||
| this.name = name; | ||
| this.completed = false; | ||
| this.id = counter += 1; | ||
| } | ||
|
|
||
| public int getId(){ | ||
| return this.id; | ||
| } | ||
|
|
||
| public String getName(){ | ||
| return this.name; | ||
| } | ||
|
|
||
| public void changeName(String newName){ | ||
| this.name = newName; | ||
| } | ||
|
|
||
| public boolean getStatus(){ | ||
| return this.completed; | ||
| } | ||
|
|
||
| public void setStatus(boolean status){ | ||
| this.completed = status; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package com.booleanuk.extension; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
|
|
||
| public class ToDoList { | ||
|
|
||
| ArrayList<Task> tasks = new ArrayList<>(); | ||
|
|
||
| public Task getTask(int id){ | ||
| for (Task task : tasks){ | ||
| if (task.getId() == id){ | ||
| return task; | ||
| } | ||
| } | ||
| System.out.println("No task with this ID!"); | ||
| return null; | ||
| } | ||
|
|
||
| public void updateName(int id, String newName){ | ||
| for (Task task : tasks){ | ||
| if (task.getId() == id){ | ||
| task.changeName(newName); | ||
| } | ||
| } | ||
| System.out.println("No task with given ID!"); | ||
| } | ||
|
|
||
| public void addTask(Task task){ | ||
| if (!tasks.contains(task)){ | ||
| tasks.add(task); | ||
| } | ||
| } | ||
|
|
||
| public void removeTask(String taskName){ | ||
| tasks.removeIf(task -> task.getName().equals(taskName)); | ||
| } | ||
|
|
||
| public void changeStatus(int id, boolean completed){ | ||
| for (Task task : tasks){ | ||
| if (task.getId() == id){ | ||
| task.setStatus(completed); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public ArrayList<String> seeAllTasks(){ | ||
| ArrayList<String> showTasks = new ArrayList<>(); | ||
| for (int i = 0; i < tasks.size(); i++){ | ||
| showTasks.add(i, tasks.get(i).getName()); | ||
| } | ||
| return showTasks; | ||
| } | ||
|
|
||
| public ArrayList<Task> getCompletedTasks(){ | ||
| ArrayList<Task> completedTasks = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| if (task.getStatus()){ | ||
| completedTasks.add(task); | ||
| } | ||
| } | ||
| return completedTasks; | ||
| } | ||
|
|
||
| public ArrayList<Task> getIncompleteTasks(){ | ||
| ArrayList<Task> incompleteTasks = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| if (!task.getStatus()){ | ||
| incompleteTasks.add(task); | ||
| } | ||
| } | ||
| return incompleteTasks; | ||
| } | ||
|
|
||
| public Task search(String taskName){ | ||
| for (Task task : tasks){ | ||
| if (task.getName().equals(taskName)){ | ||
| return task; | ||
| } | ||
| } | ||
| System.out.println("The task was not found or does not exist!"); | ||
| return null; | ||
| } | ||
|
|
||
| public ArrayList<String> alphabeticalA(){ | ||
| ArrayList<String> alphabeticalAscending = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| alphabeticalAscending.add(task.getName()); | ||
| } | ||
| Collections.sort(alphabeticalAscending); | ||
| return alphabeticalAscending; | ||
| } | ||
|
|
||
| public ArrayList<String> alphabeticalD(){ | ||
| ArrayList<String> alphabeticalDescending = new ArrayList<>(); | ||
| for (Task task : tasks){ | ||
| alphabeticalDescending.add(task.getName()); | ||
| } | ||
| Collections.sort(alphabeticalDescending); | ||
| Collections.reverse(alphabeticalDescending); | ||
| return alphabeticalDescending; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.booleanuk.core; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class TaskTest { | ||
|
|
||
| @Test | ||
| public void testValidTask(){ | ||
| Task task = new Task("Code"); | ||
|
|
||
| Assertions.assertFalse(task.name.isEmpty()); | ||
| Assertions.assertFalse(task.completed); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetName(){ | ||
| Task task = new Task("Run"); | ||
|
|
||
| String name = task.getName(); | ||
| Assertions.assertEquals("Run", name); | ||
| } | ||
|
|
||
| @Test | ||
| public void testChangeStatusTrue(){ | ||
| Task task = new Task("Run"); | ||
|
|
||
| task.setStatus(true); | ||
| Assertions.assertTrue(task.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testChangeStatusFalse(){ | ||
| Task task = new Task("Run"); | ||
|
|
||
| task.setStatus(true); | ||
| Assertions.assertTrue(task.getStatus()); | ||
| task.setStatus(false); | ||
| Assertions.assertFalse(task.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetStatus(){ | ||
| Task task = new Task("Run"); | ||
|
|
||
| Assertions.assertFalse(task.getStatus()); | ||
| task.setStatus(true); | ||
| Assertions.assertTrue(task.getStatus()); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not just return the original array of tasks here?