Problem Description:
We want to build tool for managing our education. This tool preserves our time and
effort. It keeps all books (that we study) with their chapters (you do not know how many
chapters that the book may have). For each book, name of book and provided course name
must be saved. If the student studied full chapter, the number of chapters will be decreased.
Code:
#include<iostream>
using namespace std;
class chapter
{
int size;
int *ptr;
public:
chapter(int size=10)
{
ptr=new int[size];
for(int i=0;i<size;i++)
ptr[i]=0;
}
bool chapterread(int f)
{for(int i=0;i<f;i++)
ptr[i]=1;
if(f)
return true;
else
return false;
}
int operator--(int)
{
chapter t=*this;
for(int i=0;i<size;i++)
{
if(chapterread(i)==true)
--size;
}
return size;
}
};
class book
{
private:
string booknamme;
chapter obj;
public:
book(string n,int s):obj(s)
{
booknamme=n;
}
void print()
{cout<<"book name::"<<booknamme<<endl;
cout<<"number of chapter"<<obj.size;
}
};
int main()
{
book b("c++",6);
chapter ch(6);
ch.chapterread(2);
ch--;
}