In this project you will learn how to build a C++ project from scratch on Linux. You will learn C++ Classes & Objects, Vector, Makefile & G++ compiler. This project is free to download and modify it for personal use. Users are not allowed to post this code on any other website/platform. There is a video on youtube to learn how to make this project step by step.
#include<iostream>
#include<string>
#include "utilities.h"
using namespace std;
class task{
private:
string name;
bool status;
unsigned int id;
public:
task(const string &name_var){
this->name = name_var;
this->status = false;
id = task_id++;
}
void setName(const string &name_var){
this->name = name_var;
}
void setStatus(const bool &status_var){
this->status = status_var;
}
string getName(){
return name;
}
bool getStatus(){
return status;
}
unsigned int getTaskId(){
return id;
}
~task(){
}
};
#include<iostream>
#include <vector>
#include <memory>
using namespace std;
class task;
class Task Manager{
private:
vector<shared_ptr<task>> myTasks;
public:
void addTask(){
cout<<"\n I'm in addTask()";
string task_name;
cout<<"\nEnter task name : ";
cin.ignore();
getline(cin, task_name);
myTasks.push_back(make_shared<task>(task_name));
}
void displayAllTask(){
cout<<"\n ###### In displayTasks() ######";
for(auto ref = myTasks.begin(); ref!=myTasks.end(); ref++){
cout<<endl<<endl<<" "<<(*ref)->getTaskId() << ", "<< (*ref)->getName() <<", ";
if((*ref)->getStatus() == false)
cout<<"Not Completed";
else
cout<<"Completed";
}
cout<<endl<<endl;
}
void deleteTask(){
cout<<"\n#### I'm in deleteTask()#####";
unsigned int id;
cout<<"\n Enter task id :";
cin>>id;
for(auto ref=myTasks.begin(); ref!=myTasks.end(); ref++){
if((*ref)->getTaskId() == id){
cout<<"\n Task id found..";
myTasks.erase(ref);
break;
}
}
}
void updateTask(){
cout<<"\n#### I'm in updateTask() #####";
unsigned int id;
cout<<"\n Enter task id :";
cin>>id;
for(auto ref=myTasks.begin(); ref!=myTasks.end(); ref++){
if((*ref)->getTaskId() == id){
cout<<"\n Task id found..";
int choice;
cout<<"\n enter 1 to compelte the task";
cout<<"\n 0 to incomlete it\n";
cin>>choice;
if(choice == 1)
(*ref)->setStatus(true);
else
(*ref)->setStatus(false);
break;
}
}
}
};
static unsigned int task_id;
#include<iostream>
#include "task.h"
#include "Task Manager.h"
using namespace std;
int main(){
Task Manager Task Manager;
unsigned char choice=1;
while(choice!='0'){
cout<<"\n1. Add New Task";
cout<<"\n2. Update Existing Task";
cout<<"\n3: Delete Task()";
cout<<"\n4: Display all Tasks";
cout<<"\n0: Exit";
cout<<"\n\n Enter your choice:";
cin>>choice;
switch(choice){
case '1': Task Manager.addTask(); break;
case '2': Task Manager.updateTask(); break;
case '3': Task Manager.deleteTask(); break;
case '4': Task Manager.displayAllTask(); break;
case '0': cout<<"\nExiting the application..\n"; break;
default: cout<<"\n\n Invalid choice..\n";
}
}
return 0;
}
CC = g++
INC =./inc
EXE = Task Manager.out
$(EXE):
$(CC) ./src/*.cpp -o $(EXE) -I$(INC)
@echo "Task Manager.out build successfully.."
clean:
rm -f $(EXE)
@echo "Task Manager.out deleted successfully.."
All projects on our platform are for study purpose only. You can download & modify it, but not allowed to post it on any other platform/website.
Download