|
-
November 30th, 2011, 05:46 PM
#9
Re: Need Help Finishing My Code!!
I dont think this is correct, I need some help badly.
private SimpleList<Integer> buildList(String line) {
//Build a list of integers from line
//Assume the line is syntactically correct
SimpleList<Integer> list;
list = new SimpleList<Integer>();
int i=0;
while(i<=line.length()){
int num=0;
while(i<line.length() && line.charAt(i)!='i');
num=i+(line.charAt(i)-'0');
i++;
list.add(num);
i++;
}
return list;
}
private int findMax(SimpleList<Integer> list) {
//Return the maximum integer in list
int max;
list.reset();
max=list.next();
while(list.hasNext()){
int i=list.next();
if(i>max);
max=i;
i++;
}
return max;
}
private int findMin(SimpleList<Integer> list) {
//Return the minimum integer in list
int min;
list.reset();
min=list.next();
while(list.hasNext()){
int i=list.next();
if(i<min);
min=i;
i++;
}
return min;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|