To improve customer satisfaction, a supermarket chain wants to create an object-oriented program
(OOP) to simulate the lines of customers at the check-outs in their point of sale (POS) system.
This point of sale (POS) system consists of several check-out counters. After filling their shopping carts with items, customers line up at one of the check-out counters. In most cases, they wait in line until it is their turn to pay.
Three real-world objects are implemented using the following classes:
Cart |
represents a customer together with the items they intend to purchase |
POSline |
represents an individual check-out counter and the line of customers with carts
waiting at that checkout |
POSsystem |
the overall check-out system |
The UML diagram for the class POSline is provided below.
POSline |
- String id
- boolean active
- Cart[] line |
+ constructor
+ Cart getLine(int n) - returns the cart object at position n
… more accessor/mutator methods
+ void joinLine(Cart newCart) - adds a new cart object to the end of the line
+ void checkoutCart() - removes the first cart object in the line
+ Cart leaveLine(int n) - removes and returns the cart object at position n
… more methods |
State the code fragment that instantiates an array
line
of 20
Cart
objects.