The passing code on local machine fails on excercism test checker:
class Scrabble {
private int sum = 0;
Scrabble(String word) {
if(word == null) {
return;
}
for(int i = 0; i < word.length(); i++) {
switch(word.toLowerCase().charAt(i)) {
case 'a','e','i','o','u','l','n','r','s','t':
sum += 1;
break;
case 'd','g':
sum += 2;
break;
case 'b','c','m', 'p':
sum += 3;
break;
case 'f', 'h', 'v', 'w', 'y':
sum += 4;
break;
case 'k':
sum += 5;
break;
case 'j', 'x':
sum += 8;
break;
case 'q', 'z':
sum += 10;
break;
default:
sum = 0;
break;
}
}
}
int getScore() {
return sum;
}
}
https://exercism.org/tracks/java/exercises/scrabble-score
The passing code on local machine fails on excercism test checker:
class Scrabble { private int sum = 0; Scrabble(String word) { if(word == null) { return; } for(int i = 0; i < word.length(); i++) { switch(word.toLowerCase().charAt(i)) { case 'a','e','i','o','u','l','n','r','s','t': sum += 1; break; case 'd','g': sum += 2; break; case 'b','c','m', 'p': sum += 3; break; case 'f', 'h', 'v', 'w', 'y': sum += 4; break; case 'k': sum += 5; break; case 'j', 'x': sum += 8; break; case 'q', 'z': sum += 10; break; default: sum = 0; break; } } } int getScore() { return sum; } }