H
hariharan.priya
Hi,
I am a beginner in programming! I work part time on C++ projects in
University. Currently, i am developing a barber shop simulation model.
The current model is--> Each time when the client arrives, he checks
for a free barber. if a barber is free, he is serviced. Else he waits
in a queue (Common queue for all clients).
After barber is done with his work, he checks if the queue is empty, if
not, the 1st client in the queue is served by the barber.
Now i need to change it as follows--> The client has a preference for
barber ( i am done with this)! and each barber has HIS SEPARATE queue!
the client checks if this barber is free! if not he waits in the
corresponding queue of the barber! I wish to know how to implement this
qeueue for each barber. I am just pasting the source code of barber,
where i have generated the number of barbers and has set his chair
number, and also the intialisation of the clientqueue.
queue<client*> barber::clientQueue; // this is a common queue
barber::barber( int numberOfBarbers ) : currentClient( 0 ), name( 0 ) {
for( int i = 1; i <= numberOfBarbers; i++ ) {
barber* b = dynamic_cast<barber*>( this->clone( ) );
b->setChairNumber( i );
barbers.push_back( b );
b->name = new char[255];
sprintf( b->name, "%s - %i", this->getClassName( ), i );
}
}
I am a beginner in programming! I work part time on C++ projects in
University. Currently, i am developing a barber shop simulation model.
The current model is--> Each time when the client arrives, he checks
for a free barber. if a barber is free, he is serviced. Else he waits
in a queue (Common queue for all clients).
After barber is done with his work, he checks if the queue is empty, if
not, the 1st client in the queue is served by the barber.
Now i need to change it as follows--> The client has a preference for
barber ( i am done with this)! and each barber has HIS SEPARATE queue!
the client checks if this barber is free! if not he waits in the
corresponding queue of the barber! I wish to know how to implement this
qeueue for each barber. I am just pasting the source code of barber,
where i have generated the number of barbers and has set his chair
number, and also the intialisation of the clientqueue.
queue<client*> barber::clientQueue; // this is a common queue
barber::barber( int numberOfBarbers ) : currentClient( 0 ), name( 0 ) {
for( int i = 1; i <= numberOfBarbers; i++ ) {
barber* b = dynamic_cast<barber*>( this->clone( ) );
b->setChairNumber( i );
barbers.push_back( b );
b->name = new char[255];
sprintf( b->name, "%s - %i", this->getClassName( ), i );
}
}