/******************************************************* * from http://home.att.net/~gobruen/ * * *LoopLL.java * * called by Slots.java * * * Class LoopLL is a linked list for setting up the slot wheels * as circular lists * * loopList() changes the null at the end into a link * to another item in the list * loadFromFirst() loads the second and third wheel from the first * spin() "spins" the wheels by going through the lists * a random number of times * * *****************************************************/ public class LoopLL{ private Node startOfList = null; public void addTo(String data){ Node newNode = new Node(); newNode.data = data; newNode.next = startOfList; startOfList = newNode; }//end addFirst() class Node{ String data; Node next = null; }//end Node() public String spin(int numOfSpins){ Node current = startOfList; for(int i = numOfSpins;i>0;i--){ current = current.next; } return current.data; }//end spin() public LoopLL loadFromFirst(int stPoint, LoopLL newWheel){ Node current = startOfList; for(int i = 0; i0;j--){ newWheel.addTo(current.data); current = current.next; } newWheel.loopList(); return newWheel; } /* changes the end null to a link in the list */ public void loopList(){ Node current = startOfList; while(current.next != null){ current = current.next; } /* bullocks up the list */ current.next = startOfList; }//end loopList() }