Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

All Exercises in This Part

Exercise 8.1: Todo Application, Part 7 1 p.

Return the project refactored in Exercise 8.1. Recap of the steps in this part:

  • Create a separate model object (Task) for tasks instead of using UI components directly.
  • Add at least a task title and a done/not-done state to the model.
  • Use ObservableList<Task> as the primary data structure for tasks.
  • Update the task creation logic to use the model object.

When the phase is complete, run git add for the modified files and create a git commit. Return your project files.

Complete this exercise in TIM
Exercise 8.2: Todo Application, Part 8 1 p.

Return the project refactored in Exercise 8.2. Recap of the steps in this part:

  • Replace the task VBox + CheckBox listing with a TableView component.
  • Add at least the following columns to the table: task (title), done status.
  • Bind the table's data to an ObservableList<Task> list.
  • Allow the user to select a task and delete the selected row.

When the phase is complete, run git add for the modified files and create a git commit. Return your project files.

Complete this exercise in TIM
Exercise 8.3: Todo Application, Part 9 1 p.

Return the project refactored in Exercise 8.3. Recap of the steps in this part:

  • Organize the project into layers (at minimum: model + UI logic).
  • Move the file reading and writing logic from the controller into a TaskCollection class.
  • Modify the MainController class so that it delegates save and load operations to the model.

When the phase is complete, run git add for the modified files and create a git commit. Return your project files.

Complete this exercise in TIM
Exercise 8.4: Todo Application, Part 10 1 p.

Return the project refactored in Exercise 8.4. Recap of the steps in this part:

  • Open the task editing view when the user double-clicks a task.
  • Add at least a description and a priority to the task.
  • Add validation for user input (for example, the task title must not be empty).
  • Save the changes back to the task and update the view.

When the phase is complete, run git add for the modified files and create a git commit. Return your project files.

Complete this exercise in TIM
Exercise 8.5: Testing 1 p.

Take your solution (or the model solution) from Exercise 5.10 and write unit tests for it. Test the functionality of the method with at least five different inputs. Use the examples given in the exercise or create your own test cases.

Complete this exercise in TIM
Exercise 8.6: Testing Business Logic 1 p.

Write unit tests for the TaskCollection class. Test at least the following:

  • When a task is added with a title that contains leading and trailing spaces, the spaces are removed before the task is stored in the list.
  • When two tasks with the same title are added to the collection, both of them are actually stored in the list.
  • Continuing from the previous case: when one of those tasks is marked as completed, only that specific task is marked as completed, not the other one.
  • When two different tasks are added to the collection one after another, both are stored in the list in the correct order.

Return the TaskCollectionTest class.

Complete this exercise in TIM
Exercise 8.7: Todo Application, Part 11 1 p.

Return the project refactored in Exercise 8.5. Recap of the steps in this part:

  • Add unit tests to the project.
  • Separate task saving and loading into a dedicated class that implements the TaskRepository interface.
  • Create a mock class in the test package that implements the TaskRepository interface but stores data only in memory.
  • Test file saving and loading.

When the phase is complete, run git add for the modified files and create a git commit. Return the TaskRepository interface as well as the JsonTaskRepository, MockTaskRepository, and TaskCollectionTest classes. No other classes or FXML files need to be returned.

Complete this exercise in TIM
Exercise 8.8: Git Remote Repository 1 p.

Create a public Git remote repository for your work and save your code there.

Complete this exercise in TIM