In this project, you will implement the TopSpin puzzle from Binary Arts, now known as ThinkFun. We will now be using ListNodes to create our implementation. Your implementation will act like the puzzle above.
public interface TopSpin { // Shift the pieces one space to the left public void shiftLeft(); // Shift the pieces one space to the right public void shiftRight(); // Reverses the pieces currently inside the spin mechanism, such that // the first and last are swapped, etc. public void spin(); // Returns true if the puzzle is solved, such that the pieces are in numerical order. public boolean isSolved(); // Retrieves the number in the ith spot of the cycle public int get(int i); // Either shift left, right, or spin the object for moves times public void mixup(int moves); }
Your implementation below should have a constructor that creates the TopSpin object with size numbers, and a spin mechanism of spinSize.
public DLTopSpin(int size, int spinSize)
Your numbers should start at 1. size must be at least 1, and spinSize must be less than or equal to size, otherwise, an InvalidTopSpinException should be thrown.