টু-ডু লিস্ট অ্যাপ

প্র্যাকটিস প্রোজেক্টস - কম্পিউটার প্রোগ্রামিং (Computer Programming) - Computer Science

400

নিচে একটি মৌলিক কনসোল ভিত্তিক টু-ডু লিস্ট অ্যাপ তৈরি করার উদাহরণ দেওয়া হলো, যা C++ ভাষায় লেখা হয়েছে। এই অ্যাপটি ব্যবহারকারীদের টাস্ক যুক্ত, প্রদর্শন, সম্পন্ন, এবং মুছতে সাহায্য করবে।

C++ এ টু-ডু লিস্ট অ্যাপের উদাহরণ

#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Task {
public:
    string description;
    bool completed;

    Task(string desc) : description(desc), completed(false) {}
};

class ToDoList {
private:
    vector<Task> tasks; // টাস্কের তালিকা

public:
    void addTask(const string& description) {
        tasks.push_back(Task(description));
        cout << "Task added: " << description << endl;
    }

    void displayTasks() {
        if (tasks.empty()) {
            cout << "No tasks found." << endl;
            return;
        }
        cout << "=== To-Do List ===" << endl;
        for (size_t i = 0; i < tasks.size(); ++i) {
            cout << i + 1 << ". " << tasks[i].description;
            if (tasks[i].completed) {
                cout << " [Completed]";
            }
            cout << endl;
        }
    }

    void completeTask(int index) {
        if (index < 1 || index > tasks.size()) {
            cout << "Invalid task number." << endl;
            return;
        }
        tasks[index - 1].completed = true;
        cout << "Task marked as completed: " << tasks[index - 1].description << endl;
    }

    void removeTask(int index) {
        if (index < 1 || index > tasks.size()) {
            cout << "Invalid task number." << endl;
            return;
        }
        cout << "Task removed: " << tasks[index - 1].description << endl;
        tasks.erase(tasks.begin() + (index - 1));
    }
};

int main() {
    ToDoList todoList;
    int choice;
    string taskDescription;
    int taskNumber;

    while (true) {
        cout << "\n=== To-Do List Application ===" << endl;
        cout << "1. Add Task" << endl;
        cout << "2. Display Tasks" << endl;
        cout << "3. Complete Task" << endl;
        cout << "4. Remove Task" << endl;
        cout << "5. Exit" << endl;
        cout << "Enter your choice: ";
        cin >> choice;
        cin.ignore(); // Clear the newline character from the buffer

        switch (choice) {
            case 1:
                cout << "Enter task description: ";
                getline(cin, taskDescription);
                todoList.addTask(taskDescription);
                break;
            case 2:
                todoList.displayTasks();
                break;
            case 3:
                cout << "Enter task number to mark as completed: ";
                cin >> taskNumber;
                todoList.completeTask(taskNumber);
                break;
            case 4:
                cout << "Enter task number to remove: ";
                cin >> taskNumber;
                todoList.removeTask(taskNumber);
                break;
            case 5:
                cout << "Exiting the application." << endl;
                return 0;
            default:
                cout << "Invalid choice! Please try again." << endl;
        }
    }

    return 0;
}

কোড বিশ্লেষণ

ক্লাস ডিজাইন:

  • Task ক্লাস: টাস্কের বর্ণনা এবং সম্পন্ন (completed) স্টেট ধারণ করে।
  • ToDoList ক্লাস: টাস্কগুলির তালিকা পরিচালনা করে।

মূল ফাংশন:

  • একটি ইনফিনিট লুপের মাধ্যমে ব্যবহারকারী মেনু থেকে অপশন নির্বাচন করে।
  • ব্যবহারকারী তাদের অপশনের ভিত্তিতে বিভিন্ন কার্যকলাপ করতে পারে।

ফাংশনালিটি:

  • ব্যবহারকারী টাস্ক যুক্ত করতে, টাস্কগুলি প্রদর্শন করতে, টাস্ক সম্পন্ন করতে, এবং টাস্ক মুছতে পারে।

রান করার পদ্ধতি

  1. আপনার সিস্টেমে একটি C++ কম্পাইলার ইনস্টল করুন (যেমন g++, clang++)।
  2. উপরোক্ত কোডটি একটি .cpp ফাইলে সংরক্ষণ করুন (যেমন todo_list.cpp)।
  3. কমান্ড লাইন বা টার্মিনালে কোডটি কম্পাইল করুন:
g++ todo_list.cpp -o todo_list
  1. প্রোগ্রামটি চালান:
./todo_list

উপসংহার

এটি একটি মৌলিক টু-ডু লিস্ট অ্যাপ্লিকেশন যা ব্যবহারকারীদের টাস্ক পরিচালনা করতে সাহায্য করে। এই প্রকল্পটি OOP ধারণা এবং C++ প্রোগ্রামিং ভাষায় কাজ করার জন্য একটি ভাল উদাহরণ। আপনি এই সিস্টেমের ফিচারগুলো আরও উন্নত করার মাধ্যমে নতুন প্রযুক্তি এবং ধারণা শেখার সুযোগ পাবেন, যেমন ডেটাবেস সংযোগ যোগ করা, GUI তৈরি করা, বা ফাইল ম্যানেজমেন্টের মাধ্যমে টাস্কগুলি সংরক্ষণ করা।

Content added By
Promotion

Are you sure to start over?

Loading...