Case Study
Case Study
List in C++
1 Introduction
Ask management systems are essential tools for organizing and prioritizing tasks
efficiently. In this case study, we’ll explore how to implement a simple task
manager using a singly linked list in C++. The task manager will allow users
to add tasks, remove tasks, and display tasks in an organized manner.
2 Objective
The objective of this case study is to understand the fundamentals of linked
lists in C++ and how they can be used to implement a basic task management
system. By the end of this case study, participants should be able to:
3 Problem statement
Design and implement a task manager application that utilizes a singly linked
list to manage tasks. The application should support the following functionali-
ties:
1. Add a task: Allow users to add a new task to the task list.
2. Remove a task: Allow users to remove a task from the task list.
3. Display tasks: Display all tasks currently in the task list.
1
4 Guidelines
1. Implement a Task class to represent individual tasks. Each task should
have attributes such as task name, description, priority, and due date.
2. Implement a Node class for the singly linked list data structure. Each
node will contain a Task object and a pointer to the next node.
3. Develop a TaskManager class to manage tasks using the linked list. This
class should provide functions for adding tasks, removing tasks, and dis-
playing tasks.
4. Create a user interface to interact with the task manager application. This
can be a simple console-based interface where users can input commands
to perform various actions.
5. Test the application thoroughly to ensure that all functionalities work as
expected.
5 Sample Implementation
#include <iostream>
#include <string>
Task(string n, string desc, int prio, string due) : name(n), description(desc), priority
};
2
class TaskManager {
private:
Node* head;
public:
TaskManager() : head(nullptr) {}
if (current == nullptr) {
cout << "Task not found!" << endl;
} else {
if (prev == nullptr) {
head = head->next;
} else {
prev->next = current->next;
}
delete current;
3
cout << "Task removed successfully!" << endl;
}
}
int main() {
TaskManager taskManager;
// Adding tasks
taskManager.addTask(Task("Task 1", "Description of Task 1", 1, "2024-04-21"));
taskManager.addTask(Task("Task 2", "Description of Task 2", 2, "2024-04-22"));
// Displaying tasks
taskManager.displayTasks();
// Removing a task
taskManager.removeTask("Task 1");
return 0;
}
6 Code Explanation
1st part
class Task {
4
public:
string name;
string description;
int priority;
string dueDate;
Task(string n, string desc, int prio, string due) : name(n), description(desc), priority
};
public:
TaskManager() : head(nullptr) {}
5
// Function to remove a task from the task list by name
void removeTask(string name) {
// Implementation...
}
// Adding tasks
taskManager.addTask(Task("Task 1", "Description of Task 1", 1, "2024-04-21"));
taskManager.addTask(Task("Task 2", "Description of Task 2", 2, "2024-04-22"));
// Displaying tasks
taskManager.displayTasks();
// Removing a task
taskManager.removeTask("Task 1");
return 0;
}
6
5. A task is removed using the removeTask method.
6. The list of tasks is displayed again to show the changes after removal.
7 Conclusion
By completing this case study, participants will gain a deeper understanding of
linked lists in C++ and how they can be applied to real-world problems. They
will also learn the importance of data structure choice in designing efficient
applications. This task manager application serves as a foundation for more
complex task management systems and can be extended with additional features
and functionalities in the future.