The Sleepy Barber Problem A barbershop consists of a waiting

The Sleepy Barber Problem.

A barbershop consists of a waiting room with N chairs, and the barber room containing the barber chair. If there are no customers to be served the barber goes to sleep. If customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy, then the customer sits in one of the available free chairs. If the barber is asleep, the customer wakes the barber up. Write a program to coordinate the barber and the customers.

Solution

class CBarberShop { private: int m_NoWaitingChairs,m_NoCustomers; const int MAX_CHAIRS; bool m_BarberStatus,IsRandEven; public: CBarberShop():MAX_CHAIRS(5) //Constructor initializing variables { m_NoWaitingChairs=5; m_NoCustomers=0; m_BarberStatus=false; } bool Barber_Status() //returns the barber\'s status. true=busy; false=free; { } void Wakeup() // if the barber is sleeping customer wakes him up { } //constantly checks for new customer arriaval. If the random number is even, it triggers // new customer arrival. if random number is odd, no trigger. void Check_For_New_Customer() { } //while barber doing haircut. decrease no.of customers and increase waiting chairs. void Haircut() { } //gets the current customer and seats info void Get_Customer_Seat_Status() { } // sets the barber status to true or false depending on the customers. void Set_Barber_Status(bool status) { } //returns no.of customers at any time int No_Customers() { } //retuns no. of waiting chairs availalbe at any time int No_WaitChairs_Available() { } bool IsEven(int x) { } };

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site