Đang Thực Hiện

123418 Barbershop 2

A barbershop has a cutting room with at least one (up to n) chair(s) and a waiting room with at least five (up to n) chairs.

A limitless number of customers enter the waiting room one at a time if space is available, otherwise they go to another shop.

Each time the barber finishes a haircut, the customer must pay at the cash register. Only one customer may pay at a time. Additional customers who want to pay must wait while the one at the counter completes the payment transaction and leaves. If the cashier is asleep, the paying customer must wake the cashier up. After paying, the customer leaves the shop. If the cashier has no waiting customers, the cashier falls asleep.

A waiting customer, if there is one, enters the cutting room and has a haircut. Customers may enter the waiting room one at a time so long as there is a chair for him/her to sit, or waiting customer may enter the cutting room one at a time, so long as there are available cutting chairs.

If the barber(s) discovers that the waiting room is empty after completing hair cut for customer in the cutting room, the barber(s) fall(s) asleep in the waiting room.

An arriving customer, finding the barber(s) asleep, wakes the barber(s) and has a haircut, otherwise the arriving customer waits.

You must use java's semaphore class to coordinate the operations of the barbers, clients and the cash registers (ie., acquire & release.)

The barber shop is located in Florida and power failures are common. Your solution will simulate a power loss during the running of the barber shop. During a power failure, stop all threads at a specific randomly selected time. After power returns, resume the barber shop simulation.

All threads representative of customers, barbers, cashiers, etc exist within a single instance of the Barber Shop Application.

Your solution will display a Graphical User Interface with basic containers and a set of controls to Start the Barber Shop simulation, simulate Power Failure, Resume from Power Failure, and Stop the Simulation.

The GUI will also provide a set up screen on which the user can fine tune the simulation by specifying the following parameters:

1) Number of chairs in cutting room. Default is one(1).

2) Number of Barbers. Default is one(1). This should not exceed the number of cutting chairs specified above.

3) Number of chairs in waiting room. Default is five(5).

4) Number of Cash Register Counters, Default is one(1).

5) Number of Cashiers. Default is one(1). This should not exceed the number of Cash Registers define above. Each register counter is operated by a cashier. Weekends are peak days, therefore the shop must operate at full capacity and must be full staffed. Since there are more barbers cutting hair and more customers walking it, more cashiers need to be available to allow serviced customers to leave the shop as soon as possible so that new ones can walk in and be served.

As the simulation is in progress, the UI (user interface) will display:

1) The number of customers in waiting room. Identify each customer with a unique sequence number.

2) The chair status of all chairs in the waiting room

3) The number of Barbers. Uniquely identify each barber with a name or a number.

4) The number of Cash Register Counters and their assigned Cashiers. Identify each cashier with a name or a number.

5) The number of customers waiting to pay.

6) The state and status of each active entity in the simulation (barber, client, cashier) when any changes occur. For example, Cust-10(waiting for barber), Barber-2(sleeping), Barber-1(Cutting Cust-3), Cust-3(waiting for cashier 2), Cashier-1(charging cust-2), Cashier-2(sleeping)?

7) When the barber(s) is/are asleep/awake

8) When cashier(s) is/are asleep/awake

9) Log of power interrupts and the status of all threads at the point of power failure.

In addition to displaying the simulation activities to the GUI, your solution must write all events, thread statuses, etc., to a (text) log file using a common interface with which all threads and event handlers can log their status changes. You should consider implementing a common interface to allow the various active entities to report their status and write messages to the GUI without requiring them to know to which container they must display their output. You may use Java's logging API or log4J. Each entry in the log file should be preceded with a time stamp (date and time).

Use timers, semaphores, and threads as necessary.

Additional Details:

The time it takes a barber to cut hair for a customer is random between 1 and 5 seconds.

The simulation must run for at least 5 minutes.

Customers enter the barber shop at random intervals of between 1 and 5 seconds.

Cashier takes between 1 and 3 seconds cashing out a customer.

Seconds are in whole numbers. (1,2 or 3)

Power loss period should be between 1 and 3 seconds

note: I chose a programmer for this project already, but he doesn't seem to be replying.

Kỹ năng: Bất kì công việc gì, Java

Xem thêm: barber shop simulation tune, barber shop java, write five basic need, ui status, thread up, peak 10, cust write, containers c, c containers, active ui, define user interface, timers, time stamp, state room, sleeping, power event, peak to, point barber shop, java thread, java simulation, counters, client paying, chairs, barbershop, barber shop

Về Bên Thuê:
( 0 nhận xét )

Mã Dự Án: #1869584