Our third abstract data structure is the Queue. For this homework assignment we are going to implement a circular array queue and use it to simulate checkout lines in a store. This assignment should give you more practice with Eclipse and using a queue to store data.
This is where we will put all our classes for homework 07.
All the methods should run in Big O(1). Your CircularArrayQueue class must pass CircularArrayQueueTest. You may want to write additional tests for your CircularArrayQueue.
Use the Shopper class that has a member variable numItems. Instances of this class represent the shoppers in the store.
Create a CheckoutLanes class that has some express lines and regular lines. The class should look something like:
The constructor should create CircularArrayQueues<Shopper>s for the express lanes and the regular lanes. Store the queues in an array. You can use two arrays. There must be at least one regular lane.
The void enterLane(int laneNumber, Shopper shopper) method adds the shopper to the given checkout lane. Express lanes come before regular lanes. If you had 2 express lanes and 4 regular lanes, lanes 0 and 1 are express and 2 - 5 are regular. This method does not check the shopper’s number of items.
The List<Shopper> simulateCheckout() method should loop until all checkout lanes are empty.
You can start with CheckoutLanesTest to create a test class that instantiates your CheckoutLanes class and adds several shoppers with different number of items. Then run the simulateCheckout method.
Here’s an example:
Could produce the following output:
Please thoroughly test your code and briefly discuss your testing strategy. Turn in all test code.
Criterion | Excellent (100%) | Satisfactory (75%) | Borderline (50%) | Unsatisfactory (25%) | Poor (0) |
---|---|---|---|---|---|
Adherence to standards - 2 points Does it conform to standards in every detail? |
No errors. | Minor details of the assignment are violated, or poor choices are made where the assignment is unclear. | Significant details of the assignment or the underlying program intent are violated, but the program still fulfills essential functions. | Significant details of the assignment or the underlying program intent are violated, but the program still fulfills some essential functions. | Misses the point of the assignment. |
Breakdown (modular design) - 1 point Does it demonstrate good modular design? |
No errors. | 1-3 minor errors. | > 3 minor errors OR 1 major error. | 2 major errors | > 2 major error. |
Correctness of code - 4 points Does it work? Does it pass JUnit? |
Passes all tests. | Works for typical input, may fail for minor special cases. | Fails for typical input, for a minor reason. | Fails for typical input, for a major reason. | No. |
Documentation, and style - 2 points Is it clear and maintainable? Does it pass CheckStyle? |
No errors. | 1-3 minor errors. | > 3 minor errors OR 1 major error. | 2 major errors | > 2 major error. |
Efficiency of code - 1 point Does it use the Java features well? |
No errors. | 1-3 minor errors. | > 3 minor errors OR 1 major error. | 2 major errors | > 2 major error. |
The assignment is due on Friday at 11:55pm. You may turn it in early.