Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 1 of 2 pages
Problem description:Write java programs to simulate the management of customer queues in a grocery store. Assume thatthere are two cashier counters in the store. The customers may choose any counter to checkout.Assume a store manager who is in charge of balancing the length of the queues for efficient services.Display the sale’s report when the store closes.Implementation:1.Create aCustomerclass with the following variables and methods:1)Variables-Customer ID(may use static var, or set a random number),# of itemsin the cart(int, a random number between 1 to 20), thetotalpriceof all items in the cart (double, # ofitems * 10)2)Methods – set/get, toString()2.Create aCashierclass. This class representsa customer queuefor a cashier. Each element in aqueue is an object of Customer class. There are following methods in the class to allow us tosimulate and manipulate the queues:1)void addToQueue(Customer c)– adds one customer to the end of the queue2)Customer endService()– Adds the subtotal of the items from one customer and removesthe customer from the front of the queue.3)Int getLength()– returns the length of a queue4)Void clone(Customer[] customerQueue)– copy the contents in customerQueue to thiscustomer queue5)boolean isEmpty()– returns true if the queue is empty6)Boolean isFull()– returns true if the queue is full7)String toString()– returns a string containing the detail info of all customers in the queueDesign constructors in each object class.3.Create an app class to manipulate the queues. Provide the following operations (the mainmenu):1)Customer checkout(a customer is able to choose a cashier queue, do not do auto assigning)2)Cashier 1 serves a customer3)Cashier 2 serves a customer4)Report queue status(display the detail info of two queues including the number ofcustomers and customer ID, # of items in the cart and the price for every customer in eachqueue)5)Manager adjusts queues(adjusts the length of two queues to let them to be equal or haveone difference in the # of customers)6)Close a cashier(merge two queues, not concatenate one queue to another)7)Closes store(two cashiers serve all customers in the queues. The total sale of the storeshould be reported.)Methods:
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access