Преглед на файлове

Merge branch 'master' into BinarySearchUseGenerics

FridaTveit преди 9 години
родител
ревизия
d6e66977a2

+ 34
- 0
CONTRIBUTING.md Целия файл

@@ -8,6 +8,7 @@
8 8
   * [The Problem Submodules](#the-problem-submodules)
9 9
 * [Advanced: Complete Local Setup](#advanced-complete-local-setup)
10 10
   * [Tip: `gradle clean` before `exercism fetch`](#tip-gradle-clean-before-exercism-fetch)
11
+* [Adding a New Exercise](#adding-a-new-exercise)
11 12
 
12 13
 ## Overview
13 14
 
@@ -15,6 +16,7 @@ This guide covers contributing to the Java track.  If you are new, this guide is
15 16
 
16 17
 If, at any point, you're having any trouble, pop in the [Gitter exercism/java room](https://gitter.im/exercism/java) or the [Gitter exercism/dev room](https://gitter.im/exercism/dev) for help.
17 18
 
19
+For general guidelines about contributing to Exercism see the [Exercism contributing guide](https://github.com/exercism/docs/tree/master/contributing-to-language-tracks).
18 20
 
19 21
 ## Before Making Your Pull Request
20 22
 
@@ -132,3 +134,35 @@ gradle clean
132 134
 cd ~/workspace/exercism/exercises
133 135
 exercism fetch java bob
134 136
 ```
137
+
138
+## Adding a New Exercise
139
+
140
+The easiest way to add a new exercise to the Java track is to port an exercise from another track.
141
+That means that you take an exercise that has already been implemented in another language and you implement it in this track.
142
+
143
+To add a completely new exercise you need to open a pull request to the [problem specifications repository](https://github.com/exercism/problem-specifications/tree/master/exercises).
144
+Any completely new exercise needs to be added and accepted there before it can be added to the Java track.
145
+
146
+There is a [general Exercism guide for porting an exercise to a new language](https://github.com/exercism/docs/blob/master/you-can-help/implement-an-exercise-from-specification.md).
147
+Please review this before porting an exercise to the Java track.
148
+ 
149
+See [here](http://exercism.io/languages/java/todo) for a list of exercises that have yet to be implemented on the Java track and can therefore be ported to this track.
150
+Please make sure no one else has a pull request open to implement your chosen exercise before you start.
151
+Also please make a [dibs pull request](https://github.com/exercism/docs/blob/master/you-can-help/implement-an-exercise-from-specification.md#avoiding-duplicate-work) to make it clear to others that you are working on this exercise.
152
+
153
+The Java specific details you need to know about adding an exercise are:
154
+
155
+1. Please add an entry to the `exercises` array in `config.json`. You can find details about what should be in that entry [here](https://github.com/exercism/docs/blob/master/language-tracks/configuration/exercises.md).
156
+You can also look at other entries in `config.json` as examples and try to mimic them.
157
+
158
+2. Please add an entry for your exercise to `settings.gradle`.
159
+This should just be `include 'exercise-name'`.
160
+This list is in alphabetical order so please add your exercise so that it maintains this order.
161
+
162
+3. Please add an exercise submodule for your exercise.
163
+See [The Problem Submodules](#the-problem-submodules) section for what needs to be in this.
164
+The `build.gradle` file can just be copied from any other exercise submodule.
165
+See the [POLICIES doc](https://github.com/exercism/java/blob/master/POLICIES.md#starter-implementations) for an explanation of when you need to add a starter implementation.
166
+
167
+Hopefully that should be enough information to help you port an exercise to the Java track.
168
+Feel free to open an issue or post in the [Gitter exercism/java room](https://gitter.im/exercism/java) if you have any questions and we'll try and answer as soon as we can.

+ 203
- 36
config.json Целия файл

@@ -199,7 +199,14 @@
199 199
       "core": true,
200 200
       "difficulty": 4,
201 201
       "slug": "matrix",
202
-      "topics": null,
202
+      "topics": [
203
+        "loops",
204
+        "arrays",
205
+        "pattern_matching",
206
+        "integers",
207
+        "strings",
208
+        "type_conversion"
209
+      ],
203 210
       "unlocked_by": null,
204 211
       "uuid": "c1d4e0b4-6a0f-4be9-8222-345966621f53"
205 212
     },
@@ -229,7 +236,13 @@
229 236
       "core": false,
230 237
       "difficulty": 4,
231 238
       "slug": "sieve",
232
-      "topics": null,
239
+      "topics": [
240
+        "loops",
241
+        "lists",
242
+        "integers",
243
+        "algorithms",
244
+        "mathematics"
245
+      ],
233 246
       "unlocked_by": "difference-of-squares",
234 247
       "uuid": "6791d01f-bae4-4b63-ae76-86529ac49e36"
235 248
     },
@@ -250,7 +263,11 @@
250 263
       "core": true,
251 264
       "difficulty": 4,
252 265
       "slug": "rotational-cipher",
253
-      "topics": null,
266
+      "topics": [
267
+        "integers",
268
+        "strings",
269
+        "cryptography"
270
+      ],
254 271
       "unlocked_by": null,
255 272
       "uuid": "9eb41883-55ef-4681-b5ac-5c2259302772"
256 273
     },
@@ -258,7 +275,15 @@
258 275
       "core": false,
259 276
       "difficulty": 4,
260 277
       "slug": "kindergarten-garden",
261
-      "topics": null,
278
+      "topics": [
279
+        "loops",
280
+        "arrays",
281
+        "strings",
282
+        "logic",
283
+        "pattern_recognition",
284
+        "enumerations",
285
+        "lists"
286
+      ],
262 287
       "unlocked_by": "matrix",
263 288
       "uuid": "0b92ffee-c092-4ab1-ad78-76c8cf80e1b5"
264 289
     },
@@ -266,7 +291,13 @@
266 291
       "core": false,
267 292
       "difficulty": 4,
268 293
       "slug": "collatz-conjecture",
269
-      "topics": null,
294
+      "topics": [
295
+        "exception_handling",
296
+        "recursion",
297
+        "conditionals",
298
+        "integers",
299
+        "mathematics"
300
+      ],
270 301
       "unlocked_by": "triangle",
271 302
       "uuid": "1500d39a-c9d9-4d3a-9e77-fdc1837fc6ad"
272 303
     },
@@ -274,7 +305,13 @@
274 305
       "core": false,
275 306
       "difficulty": 4,
276 307
       "slug": "nth-prime",
277
-      "topics": null,
308
+      "topics": [
309
+        "arrays",
310
+        "exception_handling",
311
+        "lists",
312
+        "loops",
313
+        "integers"
314
+      ],
278 315
       "unlocked_by": "triangle",
279 316
       "uuid": "2c69db99-648d-4bd7-8012-1fbdeff6ca0a"
280 317
     },
@@ -282,7 +319,16 @@
282 319
       "core": true,
283 320
       "difficulty": 4,
284 321
       "slug": "saddle-points",
285
-      "topics": null,
322
+      "topics": [
323
+        "arrays",
324
+        "conditionals",
325
+        "integers",
326
+        "lists",
327
+        "loops",
328
+        "mathematics",
329
+        "matrices",
330
+        "sets"
331
+      ],
286 332
       "unlocked_by": null,
287 333
       "uuid": "8dfc2f0d-1141-46e9-95e2-6f35ccf6f160"
288 334
     },
@@ -291,12 +337,12 @@
291 337
       "difficulty": 4,
292 338
       "slug": "diamond",
293 339
       "topics": [
294
-		"strings",
295
-		"loops",
296
-		"arrays",
297
-		"lists",
298
-		"text_formatting"
299
-		],
340
+        "strings",
341
+        "loops",
342
+        "arrays",
343
+        "lists",
344
+        "text_formatting"
345
+      ],
300 346
       "unlocked_by": "two-fer",
301 347
       "uuid": "ecbd997b-86f4-4e11-9ff0-706ac2899415"
302 348
     },
@@ -317,7 +363,12 @@
317 363
       "core": true,
318 364
       "difficulty": 5,
319 365
       "slug": "flatten-array",
320
-      "topics": null,
366
+      "topics": [
367
+        "arrays",
368
+        "lists",
369
+        "loops",
370
+        "recursion"
371
+      ],
321 372
       "unlocked_by": null,
322 373
       "uuid": "a732a838-8170-458a-a85e-d6b4c46f97a1"
323 374
     },
@@ -367,7 +418,13 @@
367 418
       "core": true,
368 419
       "difficulty": 5,
369 420
       "slug": "word-count",
370
-      "topics": null,
421
+      "topics": [
422
+        "strings",
423
+        "maps",
424
+        "loops",
425
+        "conditionals",
426
+        "integers"
427
+      ],
371 428
       "unlocked_by": null,
372 429
       "uuid": "3603b770-87a5-4758-91f3-b4d1f9075bc1"
373 430
     },
@@ -383,7 +440,13 @@
383 440
       "core": true,
384 441
       "difficulty": 5,
385 442
       "slug": "robot-name",
386
-      "topics": null,
443
+      "topics": [
444
+        "regular_expressions",
445
+        "strings",
446
+        "randomness",
447
+        "text_formatting",
448
+        "pattern_matching"
449
+      ],
387 450
       "unlocked_by": null,
388 451
       "uuid": "d7c2eed9-64c7-4c4a-b45d-c787d460337f"
389 452
     },
@@ -391,7 +454,14 @@
391 454
       "core": false,
392 455
       "difficulty": 5,
393 456
       "slug": "prime-factors",
394
-      "topics": null,
457
+      "topics": [
458
+        "arrays",
459
+        "conditionals",
460
+        "integers",
461
+        "lists",
462
+        "loops",
463
+        "mathematics"
464
+      ],
395 465
       "unlocked_by": "triangle",
396 466
       "uuid": "599c08ec-7338-46ed-99f8-a76f78f724e6"
397 467
     },
@@ -441,7 +511,10 @@
441 511
       "core": false,
442 512
       "difficulty": 5,
443 513
       "slug": "bracket-push",
444
-      "topics": null,
514
+      "topics": [
515
+        "stacks",
516
+        "strings"
517
+      ],
445 518
       "unlocked_by": "flatten-array",
446 519
       "uuid": "85aa50ac-0141-49eb-bc6f-62f3f7a97647"
447 520
     },
@@ -463,7 +536,11 @@
463 536
       "core": false,
464 537
       "difficulty": 5,
465 538
       "slug": "atbash-cipher",
466
-      "topics": null,
539
+      "topics": [
540
+        "strings",
541
+        "cryptography",
542
+        "security"
543
+      ],
467 544
       "unlocked_by": "rotational-cipher",
468 545
       "uuid": "d36ce010-210f-4e9a-9d6c-cb933e0a59af"
469 546
     },
@@ -518,10 +595,10 @@
518 595
       "difficulty": 6,
519 596
       "slug": "food-chain",
520 597
       "topics": [
521
-       	"arrays",
522
-       	"lists",
523
-       	"strings"
524
-       ],
598
+        "arrays",
599
+        "lists",
600
+        "strings"
601
+      ],
525 602
       "unlocked_by": "two-fer",
526 603
       "uuid": "dd3e6fd6-5359-4978-acd7-c39374cead4d"
527 604
     },
@@ -566,7 +643,13 @@
566 643
       "core": false,
567 644
       "difficulty": 6,
568 645
       "slug": "grade-school",
569
-      "topics": null,
646
+      "topics": [
647
+        "conditionals",
648
+        "strings",
649
+        "lists",
650
+        "maps",
651
+        "sorting"
652
+      ],
570 653
       "unlocked_by": "word-count",
571 654
       "uuid": "b4af5da1-601f-4b0f-bfb8-4a381851090c"
572 655
     },
@@ -574,7 +657,12 @@
574 657
       "core": false,
575 658
       "difficulty": 6,
576 659
       "slug": "robot-simulator",
577
-      "topics": null,
660
+      "topics": [
661
+        "classes",
662
+        "logic",
663
+        "loops",
664
+        "enumerations"
665
+      ],
578 666
       "unlocked_by": "secret-handshake",
579 667
       "uuid": "993bde9d-7774-4e7a-a381-9eee75f28ecb"
580 668
     },
@@ -622,7 +710,14 @@
622 710
       "core": false,
623 711
       "difficulty": 6,
624 712
       "slug": "all-your-base",
625
-      "topics": null,
713
+      "topics": [
714
+        "loops",
715
+        "mathematics",
716
+        "integers",
717
+        "arrays",
718
+        "conditionals",
719
+        "exception_handling"
720
+      ],
626 721
       "unlocked_by": "saddle-points",
627 722
       "uuid": "f7c2e4b5-1995-4dfe-b827-c9aff8ac5332"
628 723
     },
@@ -646,12 +741,30 @@
646 741
       "core": true,
647 742
       "difficulty": 6,
648 743
       "slug": "linked-list",
649
-      "topics": null,
744
+      "topics": [
745
+        "algorithms",
746
+        "lists",
747
+        "generics"
748
+      ],
650 749
       "unlocked_by": null,
651 750
       "uuid": "7ba5084d-3b75-4406-a0d7-87c26387f9c0"
652 751
     },
653 752
     {
654 753
       "core": false,
754
+      "difficulty": 6,
755
+      "slug": "tournament",
756
+      "topics": [
757
+        "loops",
758
+        "maps",
759
+        "sorting",
760
+        "parsing",
761
+        "text_formatting"
762
+      ],
763
+      "unlocked_by": "matrix",
764
+      "uuid": "99191d53-0fed-f680-de7a-55cfb872de17bc58629"
765
+    },
766
+    {
767
+      "core": false,
655 768
       "difficulty": 7,
656 769
       "slug": "anagram",
657 770
       "topics": [
@@ -669,7 +782,13 @@
669 782
       "core": false,
670 783
       "difficulty": 7,
671 784
       "slug": "sublist",
672
-      "topics": null,
785
+      "topics": [
786
+        "lists",
787
+        "searching",
788
+        "loops",
789
+        "generics",
790
+        "enumeration"
791
+      ],
673 792
       "unlocked_by": "linked-list",
674 793
       "uuid": "d2aedbd7-092a-43d0-8a5e-ae3ebd5b9c7f"
675 794
     },
@@ -708,7 +827,12 @@
708 827
       "core": false,
709 828
       "difficulty": 7,
710 829
       "slug": "meetup",
711
-      "topics": null,
830
+      "topics": [
831
+        "conditionals",
832
+        "dates",
833
+        "loops",
834
+        "enumerations"
835
+      ],
712 836
       "unlocked_by": "gigasecond",
713 837
       "uuid": "602511d5-7e89-4def-b072-4dd311816810"
714 838
     },
@@ -716,7 +840,14 @@
716 840
       "core": false,
717 841
       "difficulty": 7,
718 842
       "slug": "crypto-square",
719
-      "topics": null,
843
+      "topics": [
844
+        "strings",
845
+        "text_formatting",
846
+        "mathematics",
847
+        "cryptography",
848
+        "security",
849
+        "lists"
850
+      ],
720 851
       "unlocked_by": "rotational-cipher",
721 852
       "uuid": "162bebdc-9bf2-43c0-8460-a91f5fc16147"
722 853
     },
@@ -736,7 +867,14 @@
736 867
       "core": false,
737 868
       "difficulty": 7,
738 869
       "slug": "clock",
739
-      "topics": null,
870
+      "topics": [
871
+        "equality",
872
+        "integers",
873
+        "logic",
874
+        "object_oriented_programming",
875
+        "strings",
876
+        "time"
877
+      ],
740 878
       "unlocked_by": "saddle-points",
741 879
       "uuid": "97c8fcd4-85b6-41cb-9de2-b4e1b4951222"
742 880
     },
@@ -772,7 +910,13 @@
772 910
       "core": false,
773 911
       "difficulty": 8,
774 912
       "slug": "book-store",
775
-      "topics": null,
913
+      "topics": [
914
+        "integers",
915
+        "lists",
916
+        "algorithms",
917
+        "mathematics",
918
+        "floating_point_numbers"
919
+      ],
776 920
       "unlocked_by": "flatten-array",
777 921
       "uuid": "e5f05d00-fe5b-4d78-b2fa-934c1c9afb32"
778 922
     },
@@ -780,7 +924,14 @@
780 924
       "core": false,
781 925
       "difficulty": 8,
782 926
       "slug": "simple-cipher",
783
-      "topics": null,
927
+      "topics": [
928
+        "strings",
929
+        "cryptography",
930
+        "security",
931
+        "mathematics",
932
+        "randomness",
933
+        "exception_handling"
934
+      ],
784 935
       "unlocked_by": "rotational-cipher",
785 936
       "uuid": "f654831f-c34b-44f5-9dd5-054efbb486f2"
786 937
     },
@@ -788,7 +939,11 @@
788 939
       "core": false,
789 940
       "difficulty": 8,
790 941
       "slug": "complex-numbers",
791
-      "topics": null,
942
+      "topics": [
943
+        "mathematics",
944
+        "floating_point_numbers",
945
+        "classes"
946
+      ],
792 947
       "unlocked_by": "triangle",
793 948
       "uuid": "52d11278-0d65-4b5b-b387-1374fced3243"
794 949
     },
@@ -804,7 +959,12 @@
804 959
       "core": false,
805 960
       "difficulty": 8,
806 961
       "slug": "change",
807
-      "topics": null,
962
+      "topics": [
963
+        "algorithms",
964
+        "integers",
965
+        "exception_handling",
966
+        "lists"
967
+      ],
808 968
       "unlocked_by": "flatten-array",
809 969
       "uuid": "bac1f4bc-eea9-43c1-8e95-097347f5925e"
810 970
     },
@@ -812,7 +972,14 @@
812 972
       "core": false,
813 973
       "difficulty": 8,
814 974
       "slug": "palindrome-products",
815
-      "topics": null,
975
+      "topics": [
976
+        "conditionals",
977
+        "integers",
978
+        "lists",
979
+        "loops",
980
+        "maps",
981
+        "mathematics"
982
+      ],
816 983
       "unlocked_by": "saddle-points",
817 984
       "uuid": "873c05de-b5f5-4c5b-97f0-d1ede8a82832"
818 985
     },

+ 4
- 7
config/maintainers.json Целия файл

@@ -49,13 +49,10 @@
49 49
     },
50 50
     {
51 51
       "alumnus": false,
52
-      "avatar_url": null,
53
-      "bio": null,
52
+      "bio": "I'm a software developer working for Softwire, a UK based software company. I love programming in pretty much any language (possibly with the exception of C++) but Java is probably the language I have the most experience with.",
54 53
       "github_username": "FridaTveit",
55
-      "link_text": null,
56
-      "link_url": null,
57
-      "name": null,
58
-      "show_on_website": false
54
+      "name": "Frida Johanne Tveit",
55
+      "show_on_website": true
59 56
     }
60 57
   ]
61
-}
58
+}

exercises/binary-search-tree/.meta/src/reference/java/BST.java → exercises/binary-search-tree/.meta/src/reference/java/BinarySearchTree.java Целия файл

@@ -5,7 +5,7 @@ import java.util.LinkedList;
5 5
 import java.util.List;
6 6
 import java.util.Queue;
7 7
 
8
-public class BST<T extends Comparable<T>> {
8
+public class BinarySearchTree<T extends Comparable<T>> {
9 9
 
10 10
     public static class Node<T> {
11 11
 

exercises/binary-search-tree/src/test/java/BSTTest.java → exercises/binary-search-tree/src/test/java/BinarySearchTreeTest.java Целия файл

@@ -6,15 +6,21 @@ import static org.junit.Assert.assertEquals;
6 6
 import static org.junit.Assert.assertNotNull;
7 7
 import org.junit.Ignore;
8 8
 import org.junit.Test;
9
+import org.junit.Before;
9 10
 
10
-public class BSTTest {
11
+public class BinarySearchTreeTest {
12
+    private BinarySearchTree<Integer> binarySearchTree;
13
+
14
+    @Before
15
+    public void setUp() {
16
+        binarySearchTree = new BinarySearchTree<>();
17
+    }
11 18
 
12 19
     @Test
13 20
     public void dataIsRetained() {
14
-        BST<Integer> bst = new BST<>();
15 21
         final int actual = 4;
16
-        bst.insert(actual);
17
-        final BST.Node<Integer> root = bst.getRoot();
22
+        binarySearchTree.insert(actual);
23
+        final BinarySearchTree.Node<Integer> root = binarySearchTree.getRoot();
18 24
         assertNotNull(root);
19 25
         final int expected = root.getData();
20 26
         assertEquals(expected, actual);
@@ -23,16 +29,15 @@ public class BSTTest {
23 29
     @Ignore("Remove to run test")
24 30
     @Test
25 31
     public void insertsLess() {
26
-        BST<Integer> bst = new BST<>();
27 32
         final int expectedRoot = 4;
28 33
         final int expectedLeft = 2;
29 34
 
30
-        bst.insert(expectedRoot);
31
-        bst.insert(expectedLeft);
35
+        binarySearchTree.insert(expectedRoot);
36
+        binarySearchTree.insert(expectedLeft);
32 37
 
33
-        final BST.Node<Integer> root = bst.getRoot();
38
+        final BinarySearchTree.Node<Integer> root = binarySearchTree.getRoot();
34 39
         assertNotNull(root);
35
-        final BST.Node<Integer> left = root.getLeft();
40
+        final BinarySearchTree.Node<Integer> left = root.getLeft();
36 41
         assertNotNull(left);
37 42
 
38 43
         final int actualRoot = root.getData();
@@ -44,16 +49,15 @@ public class BSTTest {
44 49
     @Ignore("Remove to run test")
45 50
     @Test
46 51
     public void insertsSame() {
47
-        BST<Integer> bst = new BST<>();
48 52
         final int expectedRoot = 4;
49 53
         final int expectedLeft = 4;
50 54
 
51
-        bst.insert(expectedRoot);
52
-        bst.insert(expectedLeft);
55
+        binarySearchTree.insert(expectedRoot);
56
+        binarySearchTree.insert(expectedLeft);
53 57
 
54
-        final BST.Node<Integer> root = bst.getRoot();
58
+        final BinarySearchTree.Node<Integer> root = binarySearchTree.getRoot();
55 59
         assertNotNull(root);
56
-        final BST.Node<Integer> left = root.getLeft();
60
+        final BinarySearchTree.Node<Integer> left = root.getLeft();
57 61
         assertNotNull(left);
58 62
 
59 63
         final int actualRoot = root.getData();
@@ -65,16 +69,15 @@ public class BSTTest {
65 69
     @Ignore("Remove to run test")
66 70
     @Test
67 71
     public void insertsRight() {
68
-        BST<Integer> bst = new BST<>();
69 72
         final int expectedRoot = 4;
70 73
         final int expectedRight = 5;
71 74
 
72
-        bst.insert(expectedRoot);
73
-        bst.insert(expectedRight);
75
+        binarySearchTree.insert(expectedRoot);
76
+        binarySearchTree.insert(expectedRight);
74 77
 
75
-        final BST.Node<Integer> root = bst.getRoot();
78
+        final BinarySearchTree.Node<Integer> root = binarySearchTree.getRoot();
76 79
         assertNotNull(root);
77
-        final BST.Node<Integer> right = root.getRight();
80
+        final BinarySearchTree.Node<Integer> right = root.getRight();
78 81
         assertNotNull(right);
79 82
 
80 83
         final int actualRoot = root.getData();
@@ -86,7 +89,6 @@ public class BSTTest {
86 89
     @Ignore("Remove to run test")
87 90
     @Test
88 91
     public void createsComplexTree() {
89
-        BST<Integer> bst = new BST<>();
90 92
         List<Integer> expected = Collections.unmodifiableList(
91 93
                 Arrays.asList(4, 2, 6, 1, 3, 5, 7)
92 94
         );
@@ -94,60 +96,56 @@ public class BSTTest {
94 96
         List<Integer> treeData = Collections.unmodifiableList(
95 97
                 Arrays.asList(4, 2, 6, 1, 3, 7, 5)
96 98
         );
97
-        treeData.forEach(bst::insert);
99
+        treeData.forEach(binarySearchTree::insert);
98 100
 
99
-        List<Integer> actual = bst.getAsLevelOrderList();
101
+        List<Integer> actual = binarySearchTree.getAsLevelOrderList();
100 102
         assertEquals(expected, actual);
101 103
     }
102 104
 
103 105
     @Ignore("Remove to run test")
104 106
     @Test
105 107
     public void sortsSingleElement() {
106
-        BST<Integer> bst = new BST<>();
107 108
         List<Integer> expected = Collections.unmodifiableList(
108 109
                 Collections.singletonList(4)
109 110
         );
110 111
 
111
-        bst.insert(4);
112
+        binarySearchTree.insert(4);
112 113
 
113
-        List<Integer> actual = bst.getAsSortedList();
114
+        List<Integer> actual = binarySearchTree.getAsSortedList();
114 115
         assertEquals(expected, actual);
115 116
     }
116 117
 
117 118
     @Ignore("Remove to run test")
118 119
     @Test
119 120
     public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
120
-        BST<Integer> bst = new BST<>();
121 121
         List<Integer> expected = Collections.unmodifiableList(
122 122
                 Arrays.asList(2, 4)
123 123
         );
124 124
 
125
-        bst.insert(4);
126
-        bst.insert(2);
125
+        binarySearchTree.insert(4);
126
+        binarySearchTree.insert(2);
127 127
 
128
-        List<Integer> actual = bst.getAsSortedList();
128
+        List<Integer> actual = binarySearchTree.getAsSortedList();
129 129
         assertEquals(expected, actual);
130 130
     }
131 131
 
132 132
     @Ignore("Remove to run test")
133 133
     @Test
134 134
     public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
135
-        BST<Integer> bst = new BST<>();
136 135
         List<Integer> expected = Collections.unmodifiableList(
137 136
                 Arrays.asList(4, 5)
138 137
         );
139 138
 
140
-        bst.insert(4);
141
-        bst.insert(5);
139
+        binarySearchTree.insert(4);
140
+        binarySearchTree.insert(5);
142 141
 
143
-        List<Integer> actual = bst.getAsSortedList();
142
+        List<Integer> actual = binarySearchTree.getAsSortedList();
144 143
         assertEquals(expected, actual);
145 144
     }
146 145
 
147 146
     @Ignore("Remove to run test")
148 147
     @Test
149 148
     public void iteratesOverComplexTree() {
150
-        BST<Integer> bst = new BST<>();
151 149
         List<Integer> expected = Collections.unmodifiableList(
152 150
                 Arrays.asList(1, 2, 3, 4, 5, 6, 7)
153 151
         );
@@ -155,9 +153,9 @@ public class BSTTest {
155 153
         List<Integer> treeData = Collections.unmodifiableList(
156 154
                 Arrays.asList(4, 2, 1, 3, 6, 7, 5)
157 155
         );
158
-        treeData.forEach(bst::insert);
156
+        treeData.forEach(binarySearchTree::insert);
159 157
 
160
-        List<Integer> actual = bst.getAsSortedList();
158
+        List<Integer> actual = binarySearchTree.getAsSortedList();
161 159
         assertEquals(expected, actual);
162 160
     }
163 161
 }

+ 7
- 3
exercises/largest-series-product/src/main/java/LargestSeriesProductCalculator.java Целия файл

@@ -1,5 +1,9 @@
1
-public class LargestSeriesProductCalculator {
2
-
3
-
1
+class LargestSeriesProductCalculator {
2
+    LargestSeriesProductCalculator(String inputNumber) {
3
+        throw new UnsupportedOperationException ("Delete this statement and write your own implementation.");
4
+    }
4 5
 
6
+    long calculateLargestProductForSeriesLength(int numberOfDigits) {
7
+        throw new UnsupportedOperationException ("Delete this statement and write your own implementation.");
8
+    }
5 9
 }

+ 23
- 0
exercises/matrix/src/main/java/Matrix.java Целия файл

@@ -0,0 +1,23 @@
1
+
2
+class Matrix {
3
+
4
+    Matrix(String matrixAsString) {
5
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
6
+    }
7
+
8
+    int[] getRow(int rowNumber) {
9
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
10
+    }
11
+
12
+    int[] getColumn(int columnNumber) {
13
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
14
+    }
15
+
16
+    int getRowsCount() {
17
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
18
+    }
19
+
20
+    int getColumnsCount() {
21
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
22
+    }
23
+}

+ 19
- 15
exercises/robot-simulator/src/main/java/GridPosition.java Целия файл

@@ -9,21 +9,25 @@ class GridPosition {
9 9
         this.y = y;
10 10
     }
11 11
 
12
-    /*
13
-     * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase
14
-     * readability. In general, one should provide a full implementation of Object.equals(Object obj) and a
15
-     * corresponding implementation of Object.hashCode(). See
16
-     *
17
-     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
18
-     *
19
-     * and
20
-     *
21
-     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
22
-     *
23
-     * for more information.
24
-     */
25
-    boolean equals(final GridPosition gridPosition) {
26
-        return this.x == gridPosition.x && this.y == gridPosition.y;
12
+    @Override
13
+    public int hashCode() {
14
+        final int prime = 31;
15
+        int result = 1;
16
+        result = prime * result + x;
17
+        result = prime * result + y;
18
+        return result;
27 19
     }
28 20
 
21
+    @Override
22
+    public boolean equals(Object obj) {
23
+        if (this == obj) {
24
+            return true;
25
+        } else if (obj == null || getClass() != obj.getClass()) {
26
+            return false;
27
+        } else if (x != ((GridPosition) obj).x || y != ((GridPosition)obj).y) {
28
+            return false;
29
+        } else {
30
+            return true;
31
+        }
32
+    }
29 33
 }

+ 7
- 1
exercises/saddle-points/.meta/src/reference/java/MatrixCoordinate.java Целия файл

@@ -1,4 +1,4 @@
1
-class MatrixCoordinate {
1
+class MatrixCoordinate implements Comparable<MatrixCoordinate> {
2 2
     private final int row;
3 3
     private final int col;
4 4
 
@@ -30,4 +30,10 @@ class MatrixCoordinate {
30 30
         result = 31 * result + col;
31 31
         return result;
32 32
     }
33
+
34
+    @Override
35
+    public int compareTo(MatrixCoordinate o) {
36
+        int rowComparison = Integer.compare(row, o.row);
37
+        return (rowComparison == 0) ? Integer.compare(col, o.col) : rowComparison;
38
+    }
33 39
 }

+ 7
- 1
exercises/saddle-points/src/main/java/MatrixCoordinate.java Целия файл

@@ -1,4 +1,4 @@
1
-class MatrixCoordinate {
1
+class MatrixCoordinate implements Comparable<MatrixCoordinate> {
2 2
     private final int row;
3 3
     private final int col;
4 4
 
@@ -30,4 +30,10 @@ class MatrixCoordinate {
30 30
         result = 31 * result + col;
31 31
         return result;
32 32
     }
33
+
34
+    @Override
35
+    public int compareTo(MatrixCoordinate o) {
36
+        int rowComparison = Integer.compare(row, o.row);
37
+        return (rowComparison == 0) ? Integer.compare(col, o.col) : rowComparison;
38
+    }
33 39
 }

+ 1
- 0
exercises/settings.gradle Целия файл

@@ -75,6 +75,7 @@ include 'spiral-matrix'
75 75
 include 'strain'
76 76
 include 'sublist'
77 77
 include 'sum-of-multiples'
78
+include 'tournament'
78 79
 include 'transpose'
79 80
 include 'triangle'
80 81
 include 'trinary'

+ 25
- 25
exercises/simple-linked-list/src/test/java/SimpleLinkedListTest.java Целия файл

@@ -15,15 +15,15 @@ public class SimpleLinkedListTest {
15 15
 
16 16
     @Test
17 17
     public void aNewListIsEmpty() {
18
-        SimpleLinkedList list = new SimpleLinkedList();
18
+        SimpleLinkedList<Integer> list = new SimpleLinkedList<>();
19 19
         assertThat(list.size(), is(0));
20 20
     }
21 21
 
22 22
     @Ignore("Remove to run test")
23 23
     @Test
24 24
     public void canCreateFromArray() {
25
-        Integer[] values = new Integer[]{1, 2, 3};
26
-        SimpleLinkedList list = new SimpleLinkedList(values);
25
+        Character[] values = new Character[]{'1', '2', '3'};
26
+        SimpleLinkedList<Character> list = new SimpleLinkedList<Character>(values);
27 27
         assertThat(list.size(), is(3));
28 28
     }
29 29
 
@@ -31,14 +31,14 @@ public class SimpleLinkedListTest {
31 31
     @Test
32 32
     public void popOnEmptyListWillThrow() {
33 33
         expectedException.expect(NoSuchElementException.class);
34
-        SimpleLinkedList list = new SimpleLinkedList();
34
+        SimpleLinkedList<String> list = new SimpleLinkedList<String>();
35 35
         list.pop();
36 36
     }
37 37
 
38 38
     @Ignore("Remove to run test")
39 39
     @Test
40 40
     public void popReturnsLastAddedElement() {
41
-        SimpleLinkedList list = new SimpleLinkedList();
41
+        SimpleLinkedList<Integer> list = new SimpleLinkedList<Integer>();
42 42
         list.push(9);
43 43
         list.push(8);
44 44
         assertThat(list.size(), is(2));
@@ -50,37 +50,37 @@ public class SimpleLinkedListTest {
50 50
     @Ignore("Remove to run test")
51 51
     @Test
52 52
     public void reverseReversesList() {
53
-        SimpleLinkedList list = new SimpleLinkedList();
54
-        list.push(9);
55
-        list.push(8);
56
-        list.push(7);
57
-        list.push(6);
58
-        list.push(5);
53
+        SimpleLinkedList<String> list = new SimpleLinkedList<String>();
54
+        list.push("9");
55
+        list.push("8");
56
+        list.push("7");
57
+        list.push("6");
58
+        list.push("5");
59 59
         list.reverse();
60
-        assertThat(list.pop(), is(9));
61
-        assertThat(list.pop(), is(8));
62
-        assertThat(list.pop(), is(7));
63
-        assertThat(list.pop(), is(6));
64
-        assertThat(list.pop(), is(5));
60
+        assertThat(list.pop(), is("9"));
61
+        assertThat(list.pop(), is("8"));
62
+        assertThat(list.pop(), is("7"));
63
+        assertThat(list.pop(), is("6"));
64
+        assertThat(list.pop(), is("5"));
65 65
     }
66 66
 
67 67
     @Ignore("Remove to run test")
68 68
     @Test
69 69
     public void canReturnListAsArray() {
70
-        SimpleLinkedList list = new SimpleLinkedList();
71
-        list.push(9);
72
-        list.push(8);
73
-        list.push(7);
74
-        list.push(6);
75
-        list.push(5);
76
-        Integer[] expected = {5, 6, 7, 8, 9};
77
-        assertArrayEquals(expected, list.asArray(Integer.class));
70
+        SimpleLinkedList<Character> list = new SimpleLinkedList<Character>();
71
+        list.push('9');
72
+        list.push('8');
73
+        list.push('7');
74
+        list.push('6');
75
+        list.push('5');
76
+        Character[] expected = {'5', '6', '7', '8', '9'};
77
+        assertArrayEquals(expected, list.asArray(Character.class));
78 78
     }
79 79
 
80 80
     @Ignore("Remove to run test")
81 81
     @Test
82 82
     public void canReturnEmptyListAsEmptyArray() {
83
-        SimpleLinkedList list = new SimpleLinkedList();
83
+        SimpleLinkedList<Object> list = new SimpleLinkedList<Object>();
84 84
         Object[] expected = {};
85 85
         assertArrayEquals(expected, list.asArray(Object.class));
86 86
     }

+ 5
- 0
exercises/tournament/.meta/src/reference/java/Result.java Целия файл

@@ -0,0 +1,5 @@
1
+enum Result {
2
+    WIN,
3
+    DRAW,
4
+    LOSS
5
+}

+ 41
- 0
exercises/tournament/.meta/src/reference/java/TeamResult.java Целия файл

@@ -0,0 +1,41 @@
1
+class TeamResult {
2
+
3
+    private int wins;
4
+    private int losses;
5
+    private int draws;
6
+
7
+    TeamResult() {
8
+        wins = 0;
9
+        losses = 0;
10
+        draws = 0;
11
+    }
12
+
13
+    int getPlayed() {
14
+        return wins + losses + draws;
15
+    }
16
+
17
+    int getPoints() {
18
+        return wins * 3 + draws;
19
+    }
20
+
21
+    int getWins() {
22
+        return wins;
23
+    }
24
+
25
+    int getLosses() {
26
+        return losses;
27
+    }
28
+
29
+    int getDraws() {
30
+        return draws;
31
+    }
32
+
33
+    void applyResult(final Result result) {
34
+        switch (result) {
35
+            case WIN: wins++; break;
36
+            case DRAW: draws++; break;
37
+            case LOSS: losses++; break;
38
+        }
39
+    }
40
+
41
+}

+ 62
- 0
exercises/tournament/.meta/src/reference/java/Tournament.java Целия файл

@@ -0,0 +1,62 @@
1
+import java.util.HashMap;
2
+import java.util.Map;
3
+import java.util.regex.Pattern;
4
+
5
+class Tournament {
6
+
7
+    private static Pattern separatorPattern = Pattern.compile(";");
8
+    private static Pattern newlinePattern = Pattern.compile("\\n");
9
+
10
+    private Map<String, TeamResult> results;
11
+
12
+    Tournament() {
13
+        results = new HashMap<>();
14
+    }
15
+
16
+    String printTable() {
17
+        StringBuilder sb = new StringBuilder();
18
+        sb.append(String.format("%-30s | %2s | %2s | %2s | %2s | %2s\n",
19
+                "Team", "MP", "W", "D", "L", "P"));
20
+        results.entrySet()
21
+                .stream()
22
+                .sorted(Tournament::comparator)
23
+                .forEach(e -> sb.append(
24
+                        String.format("%-30s | %2d | %2d | %2d | %2d | %2d\n",
25
+                                e.getKey(), e.getValue().getPlayed(), e.getValue().getWins(), e.getValue().getDraws(),
26
+                                e.getValue().getLosses(), e.getValue().getPoints())));
27
+        return sb.toString();
28
+    }
29
+
30
+    private static int comparator(Map.Entry<String, TeamResult> teamA, Map.Entry<String, TeamResult> teamB) {
31
+        int compareByPoints = Integer.compare(teamB.getValue().getPoints(), teamA.getValue().getPoints());
32
+        return compareByPoints == 0 ? teamA.getKey().compareTo(teamB.getKey()) : compareByPoints;
33
+    }
34
+
35
+    void applyResults(final String resultString) {
36
+        String[] matches = newlinePattern.split(resultString);
37
+        for (String matchString: matches) {
38
+            String[] column = separatorPattern.split(matchString);
39
+            final TeamResult home = results.getOrDefault(column[0], new TeamResult());
40
+            final TeamResult away = results.getOrDefault(column[1], new TeamResult());
41
+            final Result result = Result.valueOf(column[2].toUpperCase());
42
+            switch (result) {
43
+                case WIN:
44
+                    home.applyResult(Result.WIN);
45
+                    away.applyResult(Result.LOSS);
46
+                    break;
47
+                case LOSS:
48
+                    home.applyResult(Result.LOSS);
49
+                    away.applyResult(Result.WIN);
50
+                    break;
51
+                case DRAW:
52
+                    home.applyResult(Result.DRAW);
53
+                    away.applyResult(Result.DRAW);
54
+                    break;
55
+            }
56
+            results.put(column[0], home);
57
+            results.put(column[1], away);
58
+        }
59
+    }
60
+
61
+
62
+}

+ 78
- 0
exercises/tournament/README.md Целия файл

@@ -0,0 +1,78 @@
1
+# Tournament
2
+
3
+Tally the results of a small football competition.
4
+
5
+Based on an input file containing which team played against which and what the
6
+outcome was, create a file with a table like this:
7
+
8
+```
9
+Team                           | MP |  W |  D |  L |  P
10
+Devastating Donkeys            |  3 |  2 |  1 |  0 |  7
11
+Allegoric Alaskans             |  3 |  2 |  0 |  1 |  6
12
+Blithering Badgers             |  3 |  1 |  0 |  2 |  3
13
+Courageous Californians        |  3 |  0 |  1 |  2 |  1
14
+```
15
+
16
+What do those abbreviations mean?
17
+
18
+- MP: Matches Played
19
+- W: Matches Won
20
+- D: Matches Drawn (Tied)
21
+- L: Matches Lost
22
+- P: Points
23
+
24
+A win earns a team 3 points. A draw earns 1. A loss earns 0.
25
+
26
+The outcome should be ordered by points, descending. In case of a tie, teams are ordered alphabetically.
27
+
28
+###
29
+
30
+Input
31
+
32
+Your tallying program will receive input that looks like:
33
+
34
+```
35
+Allegoric Alaskans;Blithering Badgers;win
36
+Devastating Donkeys;Courageous Californians;draw
37
+Devastating Donkeys;Allegoric Alaskans;win
38
+Courageous Californians;Blithering Badgers;loss
39
+Blithering Badgers;Devastating Donkeys;loss
40
+Allegoric Alaskans;Courageous Californians;win
41
+```
42
+
43
+The result of the match refers to the first team listed. So this line
44
+
45
+```
46
+Allegoric Alaskans;Blithering Badgers;win
47
+```
48
+
49
+Means that the Allegoric Alaskans beat the Blithering Badgers.
50
+
51
+This line:
52
+
53
+```
54
+Courageous Californians;Blithering Badgers;loss
55
+```
56
+
57
+Means that the Blithering Badgers beat the Courageous Californians.
58
+
59
+And this line:
60
+
61
+```
62
+Devastating Donkeys;Courageous Californians;draw
63
+```
64
+
65
+Means that the Devastating Donkeys and Courageous Californians tied.
66
+
67
+
68
+To run the tests:
69
+
70
+```sh
71
+$ gradle test
72
+```
73
+
74
+For more detailed info about the Java track see the [help page](http://exercism.io/languages/java).
75
+
76
+
77
+## Submitting Incomplete Solutions
78
+It's possible to submit an incomplete solution so you can see how others have completed the exercise.

+ 18
- 0
exercises/tournament/build.gradle Целия файл

@@ -0,0 +1,18 @@
1
+apply plugin: "java"
2
+apply plugin: "eclipse"
3
+apply plugin: "idea"
4
+
5
+repositories {
6
+    mavenCentral()
7
+}
8
+
9
+dependencies {
10
+    testCompile "junit:junit:4.12"
11
+}
12
+
13
+test {
14
+    testLogging {
15
+        exceptionFormat = 'full'
16
+        events = ["passed", "failed", "skipped"]
17
+    }
18
+}

.Rhistory → exercises/tournament/src/main/java/.keep Целия файл


+ 160
- 0
exercises/tournament/src/test/java/TournamentTest.java Целия файл

@@ -0,0 +1,160 @@
1
+import org.junit.Before;
2
+import org.junit.Ignore;
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.assertEquals;
6
+
7
+public class TournamentTest {
8
+
9
+    private Tournament tournament;
10
+
11
+    @Before
12
+    public void setUp() {
13
+        tournament = new Tournament();
14
+    }
15
+
16
+    @Test
17
+    public void justTheHeaderIfNoInput() {
18
+        assertEquals("Team                           | MP |  W |  D |  L |  P\n", tournament.printTable());
19
+    }
20
+
21
+    @Ignore("Remove to run test")
22
+    @Test
23
+    public void aWinIsThreePointsALossIsZeroPoints() {
24
+        tournament.applyResults("Allegoric Alaskans;Blithering Badgers;win");
25
+        assertEquals(
26
+                "Team                           | MP |  W |  D |  L |  P\n" +
27
+                "Allegoric Alaskans             |  1 |  1 |  0 |  0 |  3\n" +
28
+                "Blithering Badgers             |  1 |  0 |  0 |  1 |  0\n",
29
+                tournament.printTable());
30
+    }
31
+
32
+    @Ignore("Remove to run test")
33
+    @Test
34
+    public void aWinCanAlsoBeExpressedAsALoss() {
35
+        tournament.applyResults("Blithering Badgers;Allegoric Alaskans;loss");
36
+        assertEquals(
37
+                "Team                           | MP |  W |  D |  L |  P\n" +
38
+                "Allegoric Alaskans             |  1 |  1 |  0 |  0 |  3\n" +
39
+                "Blithering Badgers             |  1 |  0 |  0 |  1 |  0\n",
40
+                tournament.printTable());
41
+    }
42
+
43
+    @Ignore("Remove to run test")
44
+    @Test
45
+    public void aDifferentTeamCanWin() {
46
+        tournament.applyResults("Blithering Badgers;Allegoric Alaskans;win");
47
+        assertEquals(
48
+                "Team                           | MP |  W |  D |  L |  P\n" +
49
+                "Blithering Badgers             |  1 |  1 |  0 |  0 |  3\n" +
50
+                "Allegoric Alaskans             |  1 |  0 |  0 |  1 |  0\n",
51
+                tournament.printTable());
52
+    }
53
+
54
+    @Ignore("Remove to run test")
55
+    @Test
56
+    public void aDrawIsOnePointEach() {
57
+        tournament.applyResults( "Allegoric Alaskans;Blithering Badgers;draw");
58
+        assertEquals(
59
+                "Team                           | MP |  W |  D |  L |  P\n" +
60
+                "Allegoric Alaskans             |  1 |  0 |  1 |  0 |  1\n" +
61
+                "Blithering Badgers             |  1 |  0 |  1 |  0 |  1\n",
62
+                tournament.printTable());
63
+    }
64
+
65
+    @Ignore("Remove to run test")
66
+    @Test
67
+    public void thereCanBeMoreThanOneMatch() {
68
+        tournament.applyResults(
69
+                "Allegoric Alaskans;Blithering Badgers;win\n" +
70
+                "Allegoric Alaskans;Blithering Badgers;win");
71
+        assertEquals(
72
+                "Team                           | MP |  W |  D |  L |  P\n" +
73
+                "Allegoric Alaskans             |  2 |  2 |  0 |  0 |  6\n" +
74
+                "Blithering Badgers             |  2 |  0 |  0 |  2 |  0\n",
75
+                tournament.printTable());
76
+    }
77
+
78
+    @Ignore("Remove to run test")
79
+    @Test
80
+    public void thereCanBeMoreThanOneWinner() {
81
+        tournament.applyResults(
82
+                "Allegoric Alaskans;Blithering Badgers;loss\n" +
83
+                "Allegoric Alaskans;Blithering Badgers;win");
84
+        assertEquals(
85
+                "Team                           | MP |  W |  D |  L |  P\n" +
86
+                "Allegoric Alaskans             |  2 |  1 |  0 |  1 |  3\n" +
87
+                "Blithering Badgers             |  2 |  1 |  0 |  1 |  3\n",
88
+                tournament.printTable());
89
+    }
90
+
91
+    @Ignore("Remove to run test")
92
+    @Test
93
+    public void thereCanBeMoreThanTwoTeams() {
94
+        tournament.applyResults(
95
+                "Allegoric Alaskans;Blithering Badgers;win\n" +
96
+                "Blithering Badgers;Courageous Californians;win\n" +
97
+                "Courageous Californians;Allegoric Alaskans;loss");
98
+        assertEquals(
99
+                "Team                           | MP |  W |  D |  L |  P\n" +
100
+                "Allegoric Alaskans             |  2 |  2 |  0 |  0 |  6\n" +
101
+                "Blithering Badgers             |  2 |  1 |  0 |  1 |  3\n" +
102
+                "Courageous Californians        |  2 |  0 |  0 |  2 |  0\n",
103
+                tournament.printTable());
104
+    }
105
+
106
+    @Ignore("Remove to run test")
107
+    @Test
108
+    public void typicalInput() {
109
+        tournament.applyResults(
110
+                "Allegoric Alaskans;Blithering Badgers;win\n" +
111
+                "Devastating Donkeys;Courageous Californians;draw\n" +
112
+                "Devastating Donkeys;Allegoric Alaskans;win\n" +
113
+                "Courageous Californians;Blithering Badgers;loss\n" +
114
+                "Blithering Badgers;Devastating Donkeys;loss\n" +
115
+                "Allegoric Alaskans;Courageous Californians;win");
116
+        assertEquals(
117
+                "Team                           | MP |  W |  D |  L |  P\n" +
118
+                "Devastating Donkeys            |  3 |  2 |  1 |  0 |  7\n" +
119
+                "Allegoric Alaskans             |  3 |  2 |  0 |  1 |  6\n" +
120
+                "Blithering Badgers             |  3 |  1 |  0 |  2 |  3\n" +
121
+                "Courageous Californians        |  3 |  0 |  1 |  2 |  1\n",
122
+                tournament.printTable());
123
+    }
124
+
125
+    @Ignore("Remove to run test")
126
+    @Test
127
+    public void incompleteCompetition() {
128
+        tournament.applyResults(
129
+                "Allegoric Alaskans;Blithering Badgers;loss\n" +
130
+                "Devastating Donkeys;Allegoric Alaskans;loss\n" +
131
+                "Courageous Californians;Blithering Badgers;draw\n" +
132
+                "Allegoric Alaskans;Courageous Californians;win");
133
+        assertEquals(
134
+                "Team                           | MP |  W |  D |  L |  P\n" +
135
+                "Allegoric Alaskans             |  3 |  2 |  0 |  1 |  6\n" +
136
+                "Blithering Badgers             |  2 |  1 |  1 |  0 |  4\n" +
137
+                "Courageous Californians        |  2 |  0 |  1 |  1 |  1\n" +
138
+                "Devastating Donkeys            |  1 |  0 |  0 |  1 |  0\n",
139
+                tournament.printTable());
140
+    }
141
+
142
+    @Ignore("Remove to run test")
143
+    @Test
144
+    public void tiesBrokenAlphabetically() {
145
+        tournament.applyResults(
146
+                "Courageous Californians;Devastating Donkeys;win\n" +
147
+                "Allegoric Alaskans;Blithering Badgers;win\n" +
148
+                "Devastating Donkeys;Allegoric Alaskans;loss\n" +
149
+                "Courageous Californians;Blithering Badgers;win\n" +
150
+                "Blithering Badgers;Devastating Donkeys;draw\n" +
151
+                "Allegoric Alaskans;Courageous Californians;draw");
152
+        assertEquals(
153
+                "Team                           | MP |  W |  D |  L |  P\n" +
154
+                "Allegoric Alaskans             |  3 |  2 |  1 |  0 |  7\n" +
155
+                "Courageous Californians        |  3 |  2 |  1 |  0 |  7\n" +
156
+                "Blithering Badgers             |  3 |  0 |  1 |  2 |  1\n" +
157
+                "Devastating Donkeys            |  3 |  0 |  1 |  2 |  1\n",
158
+                tournament.printTable());
159
+    }
160
+}