#thrwable not prntn

5 messages · Page 1 of 1 (latest)

shrewd blaze
#

bowl

#

public class BowlingGame {

int an = 0;

int i=0;

int[] g = new int[22];
void roll(int pins) {
    //int[] g = new int[22];
   // for (int i = 0; i < g.length; i++) {
        g[i] += pins;

        i++;

   // for (int y = 0; y < g.length; y++) {
    //    if (y + 2 < g.length) {
     //       if (g[y] == 10) {
       //         an += g[y] + g[y + 1] + g[y + 2];
       //     }
       // }
   // }
}//if(r==10){
//  an+=pins;
// }
// if(r==0){
//  an+=pins*2;
//}else{
//an+=ad;}
//if(pins=0){
//  an+=10;
//};
//if(pins=9){
// an+=1;
//}

int score() {

    int in=0;
    for (int f = 0; f < 10; f++) {
        if (f + 2 < g.length) {
         
            if(g[in]<0){
                    throw new   AssertionError ("Negative roll is invalid");}
          else  if (g[in] == 10) {
                an += g[in] + g[in + 1] + g[in + 2];
                in++;
              //  in++;
            }
              else  if(g[in]+g[in+1]==10 && g[in]!=10   ){
                    an+=10 +(g[in+2])  ;

                    in++;
                    in++;
                }
            else if(g[in]+g[in+1]!=10 && in+2!=g.length&&(g[in]+g[in+1])<10) {
                an+=g[in]+g[in+1];
                 in++;
                 in++;
            }
                else if (g[in] < 0) {
throw new IllegalArgumentException("Negative roll is invalid");

}

                 else if(g[in]>10){
                    throw new   AssertionError  ("Pin count exceeds pins on the lane") ;}
            else{
                throw new   AssertionError ("Cant roll after game is over");             }
        }
    }
    return an;
still duneBOT
#

How you ask questions makes a huge difference in the help we can provide. Learn how to write good support requests in this article: http://bit.ly/howto-ask

cosmic quiver
shrewd blaze
#

having difficulty with throwing exception