Тема: Черга і одосвязний список
class Client
{
private:
char *firstname;
char *name;
int number;
int year;
int money;
public:
Client ();
Client & operator= (const Client & other);
void setFirstName ();
void setMoney ();
void setName ();
void setNumber ();
void setYearsInBank ();
int getPutMoney ();
int getRemovedMoney ();
void showClientInfo ();
~Client ();
};
Client::Client ()
{
this->firstname=new char [100];
this->name=new char [100];
this->number=this->year=this->money=0;
}
Client &Client::operator= (const Client &cl)
{
{
if (this != &cl)
{
strcpy(firstname, cl.firstname);
strcpy(name, cl.name);
number = cl.number;
year = cl.year;
}
return *this;
}
}
void Client::setFirstName ()
{
cout<<"Firstname: ";
cin>>this->firstname;
}
void Client::setMoney ()
{
this->money=rand ()%1000-200;
if (this->money>0)
putMoney+=this->money;
else
removedMoney-=this->money;
}
int Client::getPutMoney ()
{
return putMoney;
}
int Client::getRemovedMoney ()
{
return removedMoney;
}
void Client::setName ()
{
cout<<"Name: ";
cin>>this->name;
}
void Client::setNumber ()
{
static int _number=1;
this->number=_number;
_number++;
}
void Client::setYearsInBank ()
{
this->year=rand()%12;
}
void Client::showClientInfo ()
{
cout<<"--------------------------------"<<endl;
cout<<"Firstname: ";
cout<<this->firstname<<endl;
cout<<"Name: ";
cout<<this->name<<endl;
cout<<"Number: ";
cout<<this->number<<endl;
cout<<"Years in bank: ";
cout<<this->year<<endl;
cout<<"Money: ";
cout<<this->money<<endl;
}
Client::~Client ()
{
delete this->firstname;
delete this->name;
}
class Queue
{
private:
Client *obj;
int maxSize;
int currentSize;
int priority;
public:
Queue ();
bool full();
bool empty();
int getSize ();
void push (const Client &cl);
void show();
void pop();
void submitted ();
void removed ();
void top();
~Queue ();
};
Queue::Queue()
{
this->maxSize = 10;
this->obj = new Client[this->maxSize];
this->currentSize = 0;
}
bool Queue::full()
{
return this->currentSize == this->maxSize;
}
bool Queue::empty()
{
return this->currentSize == 0;
}
int Queue::getSize ()
{
return this->currentSize;
}
void Queue::push(const Client &cl)
{
this->obj[currentSize] = cl;
currentSize++;
}
void Queue::show()
{
for(int i = 0; i < currentSize; i++)
obj[i].showClientInfo() ;
}
void Queue::pop()
{
if (!empty()){
for (int i = 1;i<this->currentSize;i++)
obj[i - 1] = obj[i];
this->currentSize--;
}
}
void Queue::top()
{
obj[currentSize-1].showClientInfo ();
}
Queue::~Queue ()
{
delete [] obj;
}
struct Listitem
{
Client *obj;
Listitem *pNext;
};
class List
{
private:
Listitem *head;
Listitem *tail;
int count;
public:
List ();
void add (const Client &cl);
void clearList ();
void showList ();
~List ();
};
Мені потрібно якось зробити щоб після виклику методу pop (); Клієнт потрапив у однозв'язний список , у мене не виходить написати метод add (); Допоможіть будь ласка.