An evil prince has kidnapped your true love. He is demanding that you create three different potion bags for the return of your true love. The first bag must be a quick bag. The second bag must be a medium bag and the last bag must be a slow bag.
You’re going to implement three different versions of a data structure, a PotionBag, that have different performance characteristics. You’ll get to choose the implementation details to meet the performance requirements.
This assignment should give you more practice with Eclipse and choosing the right Abstract Data Type to use to solve a problem.
This is where we will put all our classes for homework 12. Use the following java files:
The QuickPotionBag class must implement the PotionBag interface.
The store, retrieve and size methods must all be BigO(1) or close to constant time.
The MediumPotionBag class must implement the PotionBag interface, but the store and retrieve methods must be BigO(log n).
The SlowPotionBag class must implement the PotionBag interface, but the store and retrieve methods must be BigO(n).
PotionBagTest.java is a simple JUnit test that adds 111,000 random potions to your three PotionBags then times storing one more and times retrieving that potion. It prints out the times for your three implementations.
Here is an example output:
Q store: 1891, M store: 2417, S store: 7364
Q retrieve: 12962, M retrieve: 18570, S retrieve: 11112615
Because of timing issues and implementation choices you won’t get the same values, but your quick bag should be faster than the medium and slow bags.
Criterion | Excellent (111%) | 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.