Adres: Ślusarska 9, 30-710 Kraków +48 733 883 121 sekretariat@ke.edu.pl

QS - ke.edu.pl

Task Manager Project – Recursive QuickSort Version

Level: SL/HL Core + HL Extension (Recursion)


🎯 Project Goal

You will build a structured Task Manager system using:

  • Object-Oriented Programming
  • ArrayList
  • Linear Search
  • Recursive QuickSort
  • File Processing

You must understand both the code and the structure of the system.


📐 System Architecture

Main (Control Layer)
        ↓
TaskManager (Logic Layer)
        ↓
Task (Data Model Layer)
  • Main → controls execution
  • TaskManager → manages collection and algorithms
  • Task → represents one task object

📊 UML Design

Class: Task

-------------------------
|        Task           |
-------------------------
| - title : String      |
| - priority : int      |
| - completed : boolean |
-------------------------
| + Task(...)           |
| + markCompleted()     |
| + getPriority()       |
| + getTitle()          |
| + toString()          |
-------------------------

Class: TaskManager

---------------------------------------
|           TaskManager               |
---------------------------------------
| - tasks : ArrayList<Task>          |
---------------------------------------
| + TaskManager()                     |
| + addTask(Task t)                   |
| + displayTasks()                    |
| + findTask(String title)            |
| + quickSort()                       |
| - quickSortRecursive(int,int)       |
| - partition(int,int)                |
| + saveToFile()                      |
---------------------------------------

💻 Step 1 – Create Task.java

public class Task {

    private String title;
    private int priority;
    private boolean completed;

    public Task(String title, int priority) {
        this.title = title;
        this.priority = priority;
        this.completed = false;
    }

    public void markCompleted() {
        completed = true;
    }

    public int getPriority() {
        return priority;
    }

    public String getTitle() {
        return title;
    }

    public String toString() {
        return title + " | Priority: " + priority + " | Done: " + completed;
    }
}

Structure Explanation:

  • Fields are private → encapsulation
  • Constructor initializes object state
  • Getters allow controlled access
  • toString defines display format

💻 Step 2 – Create TaskManager.java

import java.util.ArrayList;
import java.io.FileWriter;
import java.io.IOException;

public class TaskManager {

    private ArrayList<Task> tasks;

    public TaskManager() {
        tasks = new ArrayList<>();
    }

    public void addTask(Task task) {
        tasks.add(task);
    }

    public void displayTasks() {
        for (int i = 0; i < tasks.size(); i++) {
            System.out.println(tasks.get(i));
        }
    }

    public Task findTask(String title) {

        for (int i = 0; i < tasks.size(); i++) {
            if (tasks.get(i).getTitle().equals(title)) {
                return tasks.get(i);
            }
        }

        return null;
    }

    public void quickSort() {
        quickSortRecursive(0, tasks.size() - 1);
    }

    private void quickSortRecursive(int low, int high) {

        if (low < high) {

            int pivotIndex = partition(low, high);

            quickSortRecursive(low, pivotIndex - 1);
            quickSortRecursive(pivotIndex + 1, high);
        }
    }

    private int partition(int low, int high) {

        int pivot = tasks.get(high).getPriority();
        int i = low - 1;

        for (int j = low; j < high; j++) {

            if (tasks.get(j).getPriority() <= pivot) {

                i++;

                Task temp = tasks.get(i);
                tasks.set(i, tasks.get(j));
                tasks.set(j, temp);
            }
        }

        Task temp = tasks.get(i + 1);
        tasks.set(i + 1, tasks.get(high));
        tasks.set(high, temp);

        return i + 1;
    }

    public void saveToFile() {

        try {

            FileWriter writer = new FileWriter("tasks.txt");

            for (Task t : tasks) {
                writer.write(t.toString() + "\n");
            }

            writer.close();

        } catch (IOException e) {
            System.out.println("File error.");
        }
    }
}

🧠 Understanding Recursive QuickSort

  • Recursion = method calling itself
  • Base case = stops recursion (low < high)
  • Pivot = element used to divide the list
  • Partition = reorganizes elements around pivot

Each recursive call handles a smaller section of the list.


💻 Step 3 – Main.java

public class Main {

    public static void main(String[] args) {

        TaskManager manager = new TaskManager();

        manager.addTask(new Task("Math homework", 3));
        manager.addTask(new Task("Project", 1));
        manager.addTask(new Task("Gym", 5));
        manager.addTask(new Task("Reading", 2));

        System.out.println("Before sorting:");
        manager.displayTasks();

        manager.quickSort();

        System.out.println("After sorting:");
        manager.displayTasks();

        manager.saveToFile();
    }
}

🎥 Video Submission (Upload to ManageBac)

Video length: 4–5 minutes

You must show:

  • UML diagram
  • Running program
  • Sorting before and after
  • tasks.txt file
  • Explain recursion
  • Explain pivot and partition
  • Explain encapsulation

🔐 AI Usage Policy

  • You may use AI for clarification only.
  • You must understand and explain all code.
  • If asked, you must modify one method live.
  • If you cannot explain your recursion, the work will not be accepted.

📦 Final Upload to ManageBac

  1. ZIP file of full Java project
  2. Video recording (MP4)

✅ Self-Checklist

  • Program compiles
  • QuickSort works correctly
  • File is created
  • I understand recursion
  • I understand system structure
Ślusarska 9, 30-710 Kraków sekretariat@ke.edu.pl +48 733 883 121