// Funkcyjny import java.util.*; import java.util.stream.Collectors; class Task { private int id; private String description; public Task(int id, String description) { this.id = id; this.description = description; } public int getId() { return id; } public String getDescription() { return description; } @Override public String toString() { return "Task{" + "id=" + id + ", description='" + description + '\'' + '}'; } } class TaskManager { private List tasks; private int nextId; public TaskManager() { tasks = new ArrayList<>(); nextId = 1; } public Task addTask(String description) { Task newTask = new Task(nextId++, description); tasks.add(newTask); return newTask; } public boolean deleteTask(int id) { return tasks.removeIf(task -> task.getId() == id); } public List getTasks() { return new ArrayList<>(tasks); } public Optional getTaskById(int id) { return tasks.stream().filter(task -> task.getId() == id).findFirst(); } public void printTasks() { tasks.forEach(System.out::println); } public static void main(String[] args) { TaskManager taskManager = new TaskManager(); taskManager.addTask("Finish homework"); taskManager.addTask("Read book"); System.out.println("All tasks:"); taskManager.printTasks(); taskManager.deleteTask(1); System.out.println("Tasks after deletion:"); taskManager.printTasks(); } }