Programming Question? - index of /private -dsc
   This program is an independent adjustment of the list that begins with 10 numbers, and if a number is called, moves the list .. the teacher wrote the following code, and I can not imagine what they do with the first 2 classes, or loop. There are customers, but it goes .. any help is appreciated. 
 public class SelfAdjustingList ( 
 selfAdjust private int []; 
 Public SelfAdjustingList (arraySize int) 
 ( 
 ) 
 placeNum public void (int, int num) 
 ( 
 ) 
 public void findAndMove (int searchNum) 
 ( 
 int index = findNum (searchNum); 
 (moveNum index); 
 ) 
 private void moveNum (int pos) 
 ( 
 int temp = selfAdjust [pos]; 
 / / Loop 
 selfAdjust [selfAdjust.length - 1] = temp; 
) 
 findNum public int (int searchNum) 
 ( 
 boolean found = false; 
 posOfSearchNum int i = 0; 
 while (found) 
 ( 
 if (searchNum == selfAdjust [posOfSearchNum]) 
 ( 
 posOfSearchNum return; 
 ) 
 other 
 posOfSearchNum + +; 
 ) 
 return -1; 
 ) 
 public String toString () 
 ( 
 / / Always this   


 
No comments:
Post a Comment