CSC234 - Project 4
TopSpin - ListNode


Overview

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.

TopSpin Interface

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 TopSpin(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.

Circular Doubly Linked List Implementation

Your second implementation of the TopSpin interface should use the ideas from linked Lists as the basis of the TopSpin game. Devise an efficient implementation based on what we have studied about queues, stack and lists and the pointer manipulation involved. This class will be written in the LLTopSpin.java.

Doubly Linked List Node Implementation

You must use the DoublyLinkedNode as described in the text on page 160 in the text in your above implementation of the Circular Doubly Linked List implementation.

InvalidTopSpinException

This exception is needed for the constructor of your TopSpin implementations. It should inherit from RunTimeException and have an empty body.

Eclipse

Download the skeleton project for TopSpin and import it into Eclipse to begin.

What to turn in

  1. ArrayTopSpin.java

© Mark Goadrich 2009, Centenary College of Louisiana