ソースを参照

Merge pull request #563 from exercism/541-scrabble-score-starter

scrabble-score: standardize starter implementation
FridaTveit 9 年 前
コミット
c7eab63ab6

+ 5
- 6
exercises/scrabble-score/src/example/java/Scrabble.java ファイルの表示

1
 import java.util.Map;
1
 import java.util.Map;
2
 import java.util.HashMap;
2
 import java.util.HashMap;
3
 
3
 
4
-public class Scrabble {
4
+final class Scrabble {
5
 
5
 
6
     private String word;
6
     private String word;
7
 
7
 
36
         letterScores.put('z', 10);
36
         letterScores.put('z', 10);
37
     }
37
     }
38
 
38
 
39
-    private Object score;
40
-
41
-    public Scrabble(String word) {
39
+    Scrabble(String word) {
42
         this.word = word;
40
         this.word = word;
43
     }
41
     }
44
 
42
 
45
-    public int getScore() {
43
+    int getScore() {
46
         return getScore(word);
44
         return getScore(word);
47
     }
45
     }
48
 
46
 
49
-    public static int getScore(String input) {
47
+    private static int getScore(String input) {
50
         if (input == null || input.trim().isEmpty()) {
48
         if (input == null || input.trim().isEmpty()) {
51
             return 0;
49
             return 0;
52
         }
50
         }
59
 
57
 
60
         return score;
58
         return score;
61
     }
59
     }
60
+
62
 }
61
 }

+ 0
- 0
exercises/scrabble-score/src/main/java/.keep ファイルの表示


+ 11
- 0
exercises/scrabble-score/src/main/java/Scrabble.java ファイルの表示

1
+final class Scrabble {
2
+
3
+    Scrabble(String word) {
4
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+    }
6
+
7
+    int getScore() {
8
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9
+    }
10
+
11
+}

+ 1
- 2
exercises/scrabble-score/src/test/java/ScrabbleScoreTest.java ファイルの表示

34
         this.scrabbleScore = scrabbleScore;
34
         this.scrabbleScore = scrabbleScore;
35
     }
35
     }
36
 
36
 
37
-
38
     @Test
37
     @Test
39
     public void test() {
38
     public void test() {
40
         Scrabble scrabble = new Scrabble(scrabbleInput);
39
         Scrabble scrabble = new Scrabble(scrabbleInput);
41
-
42
         assertEquals(scrabbleScore, scrabble.getScore());
40
         assertEquals(scrabbleScore, scrabble.getScore());
43
     }
41
     }
42
+
44
 }
43
 }