Преглед изворни кода

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,7 +1,7 @@
1 1
 import java.util.Map;
2 2
 import java.util.HashMap;
3 3
 
4
-public class Scrabble {
4
+final class Scrabble {
5 5
 
6 6
     private String word;
7 7
 
@@ -36,17 +36,15 @@ public class Scrabble {
36 36
         letterScores.put('z', 10);
37 37
     }
38 38
 
39
-    private Object score;
40
-
41
-    public Scrabble(String word) {
39
+    Scrabble(String word) {
42 40
         this.word = word;
43 41
     }
44 42
 
45
-    public int getScore() {
43
+    int getScore() {
46 44
         return getScore(word);
47 45
     }
48 46
 
49
-    public static int getScore(String input) {
47
+    private static int getScore(String input) {
50 48
         if (input == null || input.trim().isEmpty()) {
51 49
             return 0;
52 50
         }
@@ -59,4 +57,5 @@ public class Scrabble {
59 57
 
60 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 Прегледај датотеку

@@ -0,0 +1,11 @@
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,11 +34,10 @@ public class ScrabbleScoreTest {
34 34
         this.scrabbleScore = scrabbleScore;
35 35
     }
36 36
 
37
-
38 37
     @Test
39 38
     public void test() {
40 39
         Scrabble scrabble = new Scrabble(scrabbleInput);
41
-
42 40
         assertEquals(scrabbleScore, scrabble.getScore());
43 41
     }
42
+
44 43
 }