Bowling Score Assistant: Difference between revisions
Jump to navigation
Jump to search
imported>Yt65 Created page with " private int score_calculator(ArrayList<Integer> arr){ int index = 0; int rank=0; int score=0; int len = arr.size(); while(index<len..." |
(No difference)
|
Revision as of 04:52, 17 March 2015
private int score_calculator(ArrayList<Integer> arr){
int index = 0;
int rank=0;
int score=0;
int len = arr.size();
while(index<len-2){
rank=0;
int first = arr.get(index);
int second = arr.get(index+1);
score+=first;
if(first==10){
rank=2;
score+=arr.get(index+1)+arr.get(index+2);
index++;
continue;
}else if(first+second==10){
rank=1;
score+=arr.get(index+2);
}
score+=second;
index+=2;
}
if(rank==0){
score+=arr.get(len-2)+arr.get(len-1);
}
return score;
}