Ask a question to Desklib · AI bot


Java program to simulate customer queues in a grocery store

2 Pages601 Words291 Views

Added on  2019-09-22

About This Document

This Java program simulates the management of customer queues in a grocery store with two cashier counters. Customers can choose any counter to checkout and a store manager balances the length of the queues for efficient services. The program allows for adding customers to queues, serving customers, reporting queue status, adjusting queues, closing cashiers, and closing the store. The program ends only when the user selects to close the store. The output includes a sales report at the end of the day.
BookmarkShareRelated Documents
Problem description:Write java programs to simulate the management of customer queues in a grocery store. Assume that there 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 a Customer class with the following variables and methods:1)Variables - Customer ID (may use static var, or set a random number), # of items in the cart (int, a random number between 1 to 20), the totalprice of all items in the cart (double, # of items * 10)2)Methods – set/get, toString()2. Create a Cashier class. This class represents a customer queue for a cashier. Each element in a queue is an object of Customer class. There are following methods in the class to allow us to simulate 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 removes the 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 this customer 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 main menu):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 of customers and customer ID, # of items in the cart and the price for every customer in each queue)5)Manager adjusts queues (adjusts the length of two queues to let them to be equal or have one 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 store should be reported.)Methods:
Java program to simulate customer queues in a grocery store_1

Found this document preview useful?

Related Documents
Source codes for Maximum Flow Algorithm

Top-Down Approach for Palindrome Partitioning Problem

Java Classes for Inventory System Development and Implementation

4100COMP: Introduction to Computer Programming

Android Quiz Contest App Code