BarberShop simulation Single server queuing system Ghena Ajami 0156820Shoroq BaniAta0143821 Prof.Mohammad Obaidat BarberShop Simulation AbstractThe report describes building a Simulation on barbershop. Choose the server queuing system model to build this simulation. The program generation will describe on Turbo Java programing language IntroductionThere are many types of barbershop system model, such as one chair model, two chairs model. We choose the first model is one chair model to simulate on a barbershop.
Assume that the barbershop has a single chair served by a single serviceman. Naturally, barbershop system is the queuing system. It means that when customers arrive they always wait in line if the barber is busy, but if the barber is free then they start service.
Problems and ObjectiveBefore creating the real barbershop system, it is very important to create any models to simulate the system because it so hazards creating the real once. It might face many problems throughout the system method. For example, a barbershop that needs only onechair of service, and customers come a lot, some customers will wait in line in the barbershop; some customer do not want to wait, some customers delay for a long time before they start service, so the barbershop will lose some customers.
To solve the problem, we estimate and analyze the result of the simulation after running to make the choice to the barbershop. Conceptual Model:In barbershop, when a customer arrives the first time of a day he ready to start service because the barber is free. During the barber is busy other customers arrive, so they wait for the service in line (queue).-System model: single server queuing system ComponentsDefine what to do at per event. At the event of arrival, create next arrival. If the server is free or idle, send the customer to start service, then server becomes busy. Otherwise, it joins the queue.
At an event of service end, then server become free. If any customers waiting in queue remove the first customer from the queue; send it for start of service. Program Organization and Logic:The simulation program builds on Java programming language.
The program joins program logic, input parameters, variables, events, sub routines, library routines, and other. Program:This program contains a set of classes including the Arrival, whiting, customer.Customer Class:This class was created to give the customer name, arrival time, service time.based on a generic node class.
Name String Arrival time Int Service time Whiting Class: That creates an array based circular queue using the Customer class array of customers. -Add CustomerAdds a new customer to back of the array Remove Customer – Remove customer from the front of the queue and set the head index to null. Next Customer -Returns the next customer in the queue. Display Waiting List – Display contents of queue Arrival class:That creates a linked list based queue using the Customer class as nodes-Display Arrival List -Read ArrivalsRead data random from file Barbershop SimulationHandles the arrival of customers into a barbershop, sits them down, and then services them it main method that uses Arrival.java, Waiting.java, and Customer.javaPseudo-codeSet Arrival object -Print “Opening and Reading File Customers_1.
txt” -Read file (Customers_1.txt) — print “Finished reading file”- initialize barberChair to null- Waiting waiting1 to new Waiting (4) //replace 4 with however many chairs you’d like to be available-Set time to 0- while loop that runs until every customer is serviced -while arrival not empty or whiting not empty or barberchair not nullPrint time If barberChair is empty If waiting queue is not empty barberChair = waiting1.removeCustomer ()//remove customer from waiting list and put them on barber chair If waiting queue is empty Print “Barber takes a break”If barberChair is not empty Set customerTime to barberChair.getServiceTime set customer service time to new reduced time If service time is 0 barberChair to null if time is next customer’s arrival time remove customer from the queue Add them to waiting queue If customer is moved Print” A chair is available”If customer can’t be added to waiting queue Print “The shop is full, come back later.
“Else waiting1.displayWaitingList()// display the waiting listIf waiting queue is empty Print “out that chairs are emptyIf barber chair is empty Print “out that barber chair is empty”Else Print “out barber chair person and service time”Add to time at the end of each loopEnd Conclusion After testing this code the result:Depiction of number of people arriving at any instant. Depiction of number of People at the Queue Before service Demonstration of no.
of people at the queue after service Depiction of number of People taking service Shows the efficiency of the system at any instant