For our last List homework assignment, we are going to simulate a Beer flight that you can taste in different orders. To facilitate this we will use a circular doubly linked list to hold the beers. The list will implement the ListIterator interface. We’ll then use the Josephus problem to choose the order in which we taste the beers.
This is where we will put some of our classes for homework 05.
Create a CircularDoublyLinkedList class that implements IList211 and Iterable. The iterator() method should return a ListIterator
In your CircularDoublyLinkedList you will need a private class that implements the ListIterator interface. The iterator method will return a new instance of your private inner class.
Your CircularDoublyLinkedList will need a constructor that takes an array and builds the list.
Since this class is circular:
Use CircularDoublyLinkedListTest.java to test your linked list class.
The Josephus problem is named after Flavius Josephus, a historian and a reluctant leader of a revolt against the Roman Empire. When it appeared Josephus and his band were about to be captured, they chose to commit suicide rather than be enslaved. It is believed that the procedure they followed was for everyone in his band to form a circle and starting in a given direction, at a certain band member, count around the circle a predetermined number. When this number is reached, the person leaves the circle and commits suicide. The circle shrinks as the counting continues. When a person drops out of the circle, the count starts over with the next person.
Instead of people and committing suicide we are going to simulate tasting beers in a flight.
Create a JosephusBeerFlight class with:
There are seven beers in the flight, numbered 1 through 7.
Create the JUnit test class CircularDoublyLinkedListTest.
Please thoroughly test your code and briefly discuss your testing strategy. Make sure that you test the ListIterator methods.
We are going to use the JosephusBeerFlightTest.java JUnit tests to evaluate your JosephusBeerFlight class for correctness.
Please thoroughly test your code and briefly discuss your testing strategy. Make sure that you test the different sorting algorithms. Turn in all your 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.