-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScabbleScore.java
More file actions
47 lines (35 loc) · 1016 Bytes
/
Copy pathScabbleScore.java
File metadata and controls
47 lines (35 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Scrabble {
private int score;
Scrabble(String word) {
score = 0;
word = word.toUpperCase();
for (char c : word.toCharArray()) {
switch(c){
case 'D' , 'G':
score += 2;
break;
case 'B' , 'C' , 'M' , 'P':
score += 3;
break;
case 'F' , 'H' , 'V' , 'W' , 'Y':
score += 4;
break;
case 'K':
score += 5;
break;
case 'J' , 'X':
score += 8;
break;
case 'Q' , 'Z':
score += 10;
break;
default:
score += 1;
break;
}
}
}
int getScore() {
return score;
}
}