All pastes #936300 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-10 09:19 UTC
rendered paste body
Error from javaC:
--------------------------------------------
ian@ian-laptop:~/Desktop/CSCI 1101/Ass 3$ javac josephusTester.java
./josephusSolver.java:57: incompatible types
found   : LinkList.linkNode
required: linkNode
                _temp = this.dataList.traverseList(this.count);
                                                  ^
./josephusSolver.java:62: cannot find symbol
symbol  : method traverseList(linkNode,int)
location: class LinkList
                        _temp = this.dataList.traverseList(_temp, this.count);
                                             ^

----------------------------------------------
Code: The Methods
----------------------------------------------
        // traverseList -- Traverses the Link List N results, and then returns that node -- Starts at tail
        public linkNode traverseList (int n) {
        
                // make we havea tleast one node in the list
                if (this.nodeCount < 1) {
                        return null;
                }
                    
                // Start at Tail
                linkNode _temp = this.tailNode;
                
                // Now we are at the begginning:
                _temp = _temp.getPointer();
                
                for (int i = 1; i <= n; i++) {
                        _temp = _temp.getPointer();
                }
                
                // Return _temp!
                return _temp;
        }
        
        // traverseList -- Traverses the Link List N results, starting from the linkNode provided, and then returns the node that it finds.
        public linkNode traverseList (linkNode _temp, int n) {
                
                // make sure we have atleast one node in the list
                if (this.nodeCount < 1) {
                        return null;
                }
                
                // Start at provided linkNode
                for (int i = 1; i <= n; i++) {
                        _temp = _temp.getPointer();
                }
                
                // Return Temp!
                return _temp;
        }

-------------------------------------------------
Code: The Implementation
-------------------------------------------------
        // getSurvivor -- Traverses the Link List and kills the rebels until only one is left
        public void getSurvivor () {
                
                // Set Variables
                linkNode _temp;
                
                // Traverse the list, and return the temp
                _temp = this.dataList.traverseList(this.count);
                this.dataList.delNode(_temp.getValue());
                
                // While loop: More than one rebel is left
                while (this.dataList.size() >= 1) {
                        _temp = this.dataList.traverseList(_temp, this.count);
                        this.dataList.delNode(_temp.getValue());
                }
                
                // Set the Survivor Position
                this.survivorPosition = _temp.getValue().toString();
        }