Просмотр исходного кода

Merge branch 'master' into transpose

Logan Stucki 9 лет назад
Родитель
Сommit
b16946a40b
100 измененных файлов: 875 добавлений и 571 удалений
  1. 0
    8
      .github/stale.yml
  2. 0
    1
      .gitignore
  3. 23
    9
      .travis.yml
  4. 2
    2
      LICENSE
  5. 11
    7
      POLICIES.md
  6. 13
    20
      README.md
  7. 1
    0
      _template/build.gradle
  8. 0
    0
      _template/src/example/java/.keep
  9. 0
    0
      _template/src/main/java/.keep
  10. 0
    0
      _template/src/test/java/.keep
  11. 1
    1
      bin/fetch-configlet
  12. 29
    21
      bin/journey-test.sh
  13. 3
    3
      bin/unit-tests.sh
  14. 245
    109
      config.json
  15. 0
    0
      docs/EXERCISE_README_INSERT.md
  16. 4
    21
      docs/MAINTAINING.md
  17. 3
    3
      docs/TESTS.md
  18. 1
    0
      exercises/accumulate/build.gradle
  19. 1
    0
      exercises/acronym/build.gradle
  20. 1
    1
      exercises/acronym/src/main/java/Acronym.java
  21. 1
    0
      exercises/all-your-base/build.gradle
  22. 1
    1
      exercises/all-your-base/src/main/java/BaseConverter.java
  23. 23
    20
      exercises/all-your-base/src/test/java/BaseConverterTest.java
  24. 1
    0
      exercises/allergies/build.gradle
  25. 1
    0
      exercises/anagram/build.gradle
  26. 1
    0
      exercises/atbash-cipher/build.gradle
  27. 1
    0
      exercises/beer-song/build.gradle
  28. 32
    32
      exercises/binary-search-tree/src/test/java/BSTTest.java
  29. 1
    0
      exercises/binary-search/build.gradle
  30. 70
    78
      exercises/binary-search/src/test/java/BinarySearchTest.java
  31. 1
    0
      exercises/binary/build.gradle
  32. 1
    0
      exercises/bob/build.gradle
  33. 1
    0
      exercises/book-store/build.gradle
  34. 5
    12
      exercises/book-store/src/example/java/BookStore.java
  35. 113
    0
      exercises/book-store/src/test/java/BookStoreTest.java
  36. 0
    119
      exercises/book-store/src/test/java/BookstoreTest.java
  37. 1
    0
      exercises/bracket-push/build.gradle
  38. 1
    1
      exercises/bracket-push/src/main/java/BracketChecker.java
  39. 57
    31
      exercises/build.gradle
  40. 1
    0
      exercises/change/build.gradle
  41. 1
    1
      exercises/change/src/main/java/ChangeCalculator.java
  42. 1
    1
      exercises/change/src/test/java/ChangeCalculatorTest.java
  43. 3
    0
      exercises/clock/HINT.md
  44. 2
    1
      exercises/clock/build.gradle
  45. 3
    0
      exercises/clock/src/test/java/ClockAddTest.java
  46. 3
    0
      exercises/clock/src/test/java/ClockCreationTest.java
  47. 21
    17
      exercises/clock/src/test/java/ClockEqualTest.java
  48. 18
    0
      exercises/collatz-conjecture/build.gradle
  49. 19
    0
      exercises/collatz-conjecture/src/example/java/CollatzCalculator.java
  50. 7
    0
      exercises/collatz-conjecture/src/main/java/CollatzCalculator.java
  51. 65
    0
      exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java
  52. 1
    0
      exercises/crypto-square/build.gradle
  53. 1
    0
      exercises/diamond/build.gradle
  54. 4
    4
      exercises/diamond/src/example/java/DiamondPrinter.java
  55. 1
    1
      exercises/diamond/src/main/java/DiamondPrinter.java
  56. 6
    2
      exercises/diamond/src/test/java/DiamondPrinterTest.java
  57. 1
    0
      exercises/difference-of-squares/build.gradle
  58. 0
    0
      exercises/difference-of-squares/src/main/java/.keep
  59. 0
    15
      exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java
  60. 1
    0
      exercises/etl/build.gradle
  61. 1
    0
      exercises/flatten-array/build.gradle
  62. 1
    1
      exercises/flatten-array/src/main/java/Flattener.java
  63. 1
    0
      exercises/gigasecond/build.gradle
  64. 1
    0
      exercises/grade-school/build.gradle
  65. 1
    0
      exercises/hamming/build.gradle
  66. 5
    1
      exercises/hello-world/GETTING_STARTED.md
  67. 3
    3
      exercises/hello-world/TUTORIAL.md
  68. 1
    0
      exercises/hexadecimal/build.gradle
  69. 10
    0
      exercises/isogram/HINT.md
  70. 1
    0
      exercises/isogram/build.gradle
  71. 1
    0
      exercises/kindergarten-garden/build.gradle
  72. 4
    4
      exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java
  73. 1
    0
      exercises/largest-series-product/build.gradle
  74. 1
    0
      exercises/linked-list/build.gradle
  75. 1
    0
      exercises/luhn/build.gradle
  76. 1
    1
      exercises/luhn/src/main/java/LuhnValidator.java
  77. 2
    1
      exercises/matrix/build.gradle
  78. 1
    0
      exercises/meetup/build.gradle
  79. 1
    0
      exercises/minesweeper/build.gradle
  80. 1
    1
      exercises/minesweeper/src/main/java/MinesweeperBoard.java
  81. 1
    0
      exercises/nth-prime/build.gradle
  82. 1
    0
      exercises/ocr-numbers/build.gradle
  83. 3
    3
      exercises/ocr-numbers/src/example/java/OpticalCharacterReader.java
  84. 1
    1
      exercises/ocr-numbers/src/main/java/OpticalCharacterReader.java
  85. 1
    0
      exercises/octal/build.gradle
  86. 1
    0
      exercises/pangram/build.gradle
  87. 1
    0
      exercises/pascals-triangle/build.gradle
  88. 1
    0
      exercises/perfect-numbers/build.gradle
  89. 1
    1
      exercises/perfect-numbers/src/main/java/NaturalNumber.java
  90. 0
    1
      exercises/perfect-numbers/src/test/java/NaturalNumberTest.java
  91. 1
    0
      exercises/phone-number/build.gradle
  92. 1
    0
      exercises/pig-latin/build.gradle
  93. 8
    8
      exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java
  94. 1
    0
      exercises/queen-attack/build.gradle
  95. 1
    1
      exercises/queen-attack/src/main/java/BoardCoordinate.java
  96. 1
    1
      exercises/queen-attack/src/main/java/QueenAttackCalculator.java
  97. 1
    0
      exercises/raindrops/build.gradle
  98. 1
    0
      exercises/rectangles/build.gradle
  99. 1
    1
      exercises/rectangles/src/main/java/RectangleCounter.java
  100. 0
    0
      exercises/rna-transcription/build.gradle

+ 0
- 8
.github/stale.yml Просмотреть файл

@@ -1,8 +0,0 @@
1
-# Issues or Pull Requests with these labels will never be considered stale
2
-exemptLabels:
3
-  - "first-timers only"
4
-  - "good first patch"
5
-  - "policy"
6
-
7
-# Label to use when marking as stale
8
-staleLabel: stale

+ 0
- 1
.gitignore Просмотреть файл

@@ -8,5 +8,4 @@ build/
8 8
 *.iml
9 9
 bin/configlet
10 10
 bin/configlet.exe
11
-gradle/
12 11
 /exercises/.nb-gradle/

+ 23
- 9
.travis.yml Просмотреть файл

@@ -3,17 +3,9 @@ language: java
3 3
 jdk:
4 4
   - oraclejdk8
5 5
 
6
-notifications:
7
-  webhooks:
8
-    urls:
9
-      - https://webhooks.gitter.im/e/5e9ccd41111917b19478
10
-    on_success: change  # options: [always|never|change] default: always
11
-    on_failure: always  # options: [always|never|change] default: always
12
-    on_start: never     # options: [always|never|change] default: always
13
-
14 6
 # http://docs.travis-ci.com/user/migrating-from-legacy
15 7
 sudo: false
16
-cache: bundler
8
+
17 9
 addons:
18 10
   apt:
19 11
     packages:
@@ -24,9 +16,31 @@ before_install:
24 16
   - rvm use 2.2.5
25 17
   - bin/build-jq.sh  # we want jq 1.5 features; not avail through pkg repo.
26 18
 
19
+# https://docs.travis-ci.com/user/customizing-the-build#Skipping-the-Installation-Step
20
+install: true  # if we don't skip install, ./gradlew assemble is invoked, but this task is not available.
21
+
27 22
 before_script:
28 23
   - export PATH=$TRAVIS_BUILD_DIR/bin:$PATH  # ensure our tools are prefered over included ones.
29 24
 
30 25
 script:
31 26
   - bin/unit-tests.sh
32 27
   - bin/journey-test.sh
28
+
29
+# configure caching (https://docs.travis-ci.com/user/languages/java/#Caching)
30
+before_cache:
31
+  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
32
+  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
33
+# format from https://docs.travis-ci.com/user/caching/#Enabling-multiple-caching-features
34
+cache:
35
+  bundler: true
36
+  directories:
37
+    - $HOME/.gradle/caches/
38
+    - $HOME/.gradle/wrapper/
39
+
40
+notifications:
41
+  webhooks:
42
+    urls:
43
+      - https://webhooks.gitter.im/e/5e9ccd41111917b19478
44
+    on_success: change  # options: [always|never|change] default: always
45
+    on_failure: always  # options: [always|never|change] default: always
46
+    on_start: never     # options: [always|never|change] default: always

+ 2
- 2
LICENSE Просмотреть файл

@@ -1,6 +1,6 @@
1
-The MIT License (MIT)
1
+MIT License
2 2
 
3
-Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
3
+Copyright (c) 2017 Exercism, Inc
4 4
 
5 5
 Permission is hereby granted, free of charge, to any person obtaining a copy
6 6
 of this software and associated documentation files (the "Software"), to deal

+ 11
- 7
POLICIES.md Просмотреть файл

@@ -30,7 +30,7 @@ Our policies are not set-in-stone. They represent directions chosen at a point i
30 30
 
31 31
 > Most (all?) exercises should be implemented in the form of instance methods since they contain "domain logic" and we (Exercism) want to encourage exemplary software.
32 32
 
33
-References: [[1](https://github.com/exercism/xjava/issues/177#issuecomment-261291741)]
33
+References: [[1](https://github.com/exercism/java/issues/177#issuecomment-261291741)]
34 34
 
35 35
 ### Starter implementations
36 36
 
@@ -40,28 +40,32 @@ References: [[1](https://github.com/exercism/xjava/issues/177#issuecomment-26129
40 40
     `throw new UnsupportedOperationException("Delete this statement and provide your own implementation.");`
41 41
 > - Exercises 21+: provide no stubs, but mention any "interesting" interface aspects in the HINT.md file (which gets merged into the README.md for the exercise).
42 42
 
43
-References: [[1](https://github.com/exercism/xjava/issues/178)]
43
+References: [[1](https://github.com/exercism/java/issues/178)]
44
+
45
+### Do not make user-facing classes `final`
46
+
47
+> Starter implementations and test classes should not include the `final` keyword in class declarations as it isn't strictly necessary and could be confusing to people unfamiliar with Java.
44 48
 
45 49
 ### Ignore noninitial tests
46 50
 
47 51
 > All but the first test in an exercise test suite should be annotated `@Ignore("Remove to run test")` (single test) or `@Ignore("Remove to run tests")` (parametrized test).
48 52
 
49
-References: [[1](https://github.com/exercism/xjava/issues/101#issuecomment-249349204)]
53
+References: [[1](https://github.com/exercism/java/issues/101#issuecomment-249349204)]
50 54
 
51 55
 ### Multiple file submissions
52 56
 
53 57
 > The first exercise in the track whose test suite mandates multiple solution files should be accompanied by a HINT.md file reminding the practitioner that the CLI supports multiple file submissions.
54 58
 
55
-References: [[1](https://github.com/exercism/xjava/issues/365#issuecomment-292533120)]
59
+References: [[1](https://github.com/exercism/java/issues/365#issuecomment-292533120)]
56 60
 
57 61
 ### Good first patches
58 62
 
59
-> Aim to keep 10-20 small and straightforward issues open at eny given time. Identify any such issues by applying the "Good first patch" label. You can view the current list of these issues [here](https://github.com/exercism/xjava/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+patch%22).
63
+> Aim to keep 10-20 small and straightforward issues open at eny given time. Identify any such issues by applying the "Good first patch" label. You can view the current list of these issues [here](https://github.com/exercism/java/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+patch%22).
60 64
 
61
-References: [[1](https://github.com/exercism/xjava/issues/220#issue-196447088)]
65
+References: [[1](https://github.com/exercism/java/issues/220#issue-196447088)]
62 66
 
63 67
 ### Simple onboarding
64 68
 
65 69
 > The Installing Java instructions should seek to minimize the number of steps and the number of concepts a new-to-the-track practitioner needs to learn to get to coding.
66 70
 
67
-References: [[1](https://github.com/exercism/xjava/issues/395#issue-215734887)]
71
+References: [[1](https://github.com/exercism/java/issues/395#issue-215734887)]

+ 13
- 20
README.md Просмотреть файл

@@ -1,10 +1,10 @@
1
-# xJava [![Build Status](https://travis-ci.org/exercism/xjava.svg?branch=master)](https://travis-ci.org/exercism/xjava) [![Join the chat at https://gitter.im/exercism/xjava](https://badges.gitter.im/exercism/xjava.svg)](https://gitter.im/exercism/xjava?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+# java [![Build Status](https://travis-ci.org/exercism/java.svg?branch=master)](https://travis-ci.org/exercism/java) [![Join the chat at https://gitter.im/exercism/xjava](https://badges.gitter.im/exercism/java.svg)](https://gitter.im/exercism/xjava?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2 2
 
3 3
 Source for Exercism Exercises in Java.
4 4
 
5 5
 ## Contributing Guide
6 6
 
7
-For general information about how to contribute to Exercism, please refer to the [Contributing Guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data).
7
+For general information about how to contribute to Exercism, please refer to the [Contributing Guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks).
8 8
 
9 9
 ## Table of Contents
10 10
 
@@ -32,13 +32,13 @@ To submit a fix for an existing exercise or port an exercise to Java with the le
32 32
 1. **Ensure you have the basic Java tooling installed:**  JDK 1.8+, an editor and Gradle 2.x.
33 33
 
34 34
    (see [exercism.io: Installing Java](http://exercism.io/languages/java/installing))
35
--  **Setup a branch on a fork of [exercism/xjava](https://github.com/exercism/xjava) on your computer.**
35
+-  **Setup a branch on a fork of [exercism/java](https://github.com/exercism/java) on your computer.**
36 36
 
37
-   See [GitHub Help: Forking](https://help.github.com/articles/fork-a-repo/).  Use those instructions (in conjunction with [Exercism Contributing Guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#git-basics)) to:
37
+   See [GitHub Help: Forking](https://help.github.com/articles/fork-a-repo/).  Use those instructions (in conjunction with the [Git Basics doc](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/git-basics.md)) to:
38 38
    * "fork" a repository on GitHub;
39 39
    - install `git`;
40 40
    - "clone" a copy of your fork;
41
-   - configure an "upstream remote" (in this case, `exercism/xjava`);
41
+   - configure an "upstream remote" (in this case, `exercism/java`);
42 42
    - create a branch to house your work
43 43
 -  **Write the codes.**  Do your work on that branch you just created.
44 44
 
@@ -52,15 +52,15 @@ To submit a fix for an existing exercise or port an exercise to Java with the le
52 52
    $ git push
53 53
    ```
54 54
 
55
-   [Exercism Contributing Guide :: Commit Messages](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#commit-messages) provides practical advice on crafting meaningful commit messages.
55
+   The Git Basics doc has a section on [commit messages](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/git-basics.md#commit-messages) that provides practical advice on crafting meaningful commit messages.
56 56
 -  **Verify that your work passes all tests.**  When you create a pull request (PR), GitHub triggers a build on Travis CI.  Your PR will not be merged unless those tests pass.
57 57
 
58 58
 ## Getting Familiar With the Codebase
59 59
 
60 60
 There are two objectives to the design of this build:
61 61
 
62
-1. when a problem is built from within the xjava repo, the tests run against the "example" code (i.e. when you, the contributor, are developing the exercise);
63
-2. when a problem is built outside the xjava repo (when a participant is solving the exercise), the tests run against the "main" code.
62
+1. when a problem is built from within the `exercism/java` repo (i.e. when you, the contributor, are developing the exercise), the tests run against the "example" code;
63
+2. when a problem is built outside the `exercism/java` repo (when a participant is solving the exercise), the tests run against the "main" code.
64 64
 
65 65
 This repo is a multi-project gradle build.
66 66
 
@@ -68,15 +68,15 @@ This repo is a multi-project gradle build.
68 68
 
69 69
 This is the top-level module, contained in the `exercises` directory.  It is a container for the problem sub-modules.
70 70
 
71
-  * it's `build.gradle` points the "main" sourceset to the example code.
72
-  * it's `settings.gradle` names each of the subprojects, one for each problem in the set.
71
+  * its `build.gradle` points the "main" sourceset to the example code.
72
+  * its `settings.gradle` names each of the subprojects, one for each problem in the set.
73 73
 
74 74
 ### The Problem Submodules
75 75
 
76 76
 The `exercises` subdirectory contains all of the problem submodules.
77 77
 Each problem/submodule is a subdirectory of the same name as its slug.
78 78
 
79
-  * it's `build.gradle` names dependencies required to work that problem.
79
+  * its `build.gradle` names dependencies required to work that problem.
80 80
 
81 81
 Each problem/submodule has three source sets:
82 82
 
@@ -109,18 +109,11 @@ and if you review the logs of your x-api, you'll find:
109 109
 2015-09-06 15:21:01 - JSON::GeneratorError - source sequence is illegal/malformed utf-8:
110 110
 ```
111 111
 
112
-This is because some files generated by the build can't be served from the x-api.  This is by design: the CLI does not serve binaries.  To fix this, simply make sure you do a clean in your `xjava` repo before you fetch:
112
+This is because some files generated by the build can't be served from the x-api.  This is by design: the CLI does not serve binaries.  To fix this, simply make sure you do a clean in your `exercism/java` repo before you fetch:
113 113
 
114 114
 ```
115
-cd ~/workspace/exercism/xjava/exercises
115
+cd ~/workspace/exercism/java/exercises
116 116
 gradle clean
117 117
 cd ~/workspace/exercism/exercises
118 118
 exercism fetch java bob
119 119
 ```
120
-
121
-
122
-# License
123
-
124
-The MIT License (MIT)
125
-
126
-Copyright (c) 2014 Katrina Owen, _@kytrinyx.com

exercises/_template/build.gradle → _template/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

exercises/_template/src/test/java/.keep → _template/src/example/java/.keep Просмотреть файл


exercises/_template/src/main/java/.keep → _template/src/main/java/.keep Просмотреть файл


exercises/_template/src/example/java/.keep → _template/src/test/java/.keep Просмотреть файл


+ 1
- 1
bin/fetch-configlet Просмотреть файл

@@ -1,4 +1,4 @@
1
-#!/bin/bash
1
+#!/usr/bin/env bash
2 2
 
3 3
 LATEST=https://github.com/exercism/configlet/releases/latest
4 4
 

+ 29
- 21
bin/journey-test.sh Просмотреть файл

@@ -1,5 +1,11 @@
1 1
 #!/usr/bin/env bash
2 2
 
3
+# This script is shared between the Java and Kotlin tracks.  If you make an update to this script on
4
+# one track, please create a companion PR to merge it in to the other.  Thank you!
5
+TRACK=java
6
+TRACK_REPO="$TRACK"
7
+TRACK_SRC_EXT="java"
8
+
3 9
 on_exit() {
4 10
   echo ">>> on_exit()"
5 11
   if [[ "$xapi_pid" != "" ]] ; then
@@ -16,7 +22,7 @@ assert_installed() {
16 22
 
17 23
   if [[ "`which $binary`" == "" ]]; then
18 24
     echo "${binary} not found; it is required to perform this test."
19
-    echo -e "Have you completed the setup instructions at https://github.com/exercism/xjava ?\n"
25
+    echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
20 26
     echo "PATH=${PATH}"
21 27
     echo "aborting."
22 28
     exit 1
@@ -35,7 +41,7 @@ assert_ruby_installed() {
35 41
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
36 42
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
37 43
     echo -e "Ruby used: `which ruby`.\n"
38
-    echo -e "Have you completed the setup instructions at https://github.com/exercism/xjava ?\n"
44
+    echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
39 45
     echo "PATH=${PATH}"
40 46
     echo "aborting."
41 47
     exit 1
@@ -59,7 +65,7 @@ clean() {
59 65
     rm -rf "${build_path}"
60 66
   fi
61 67
   cd exercises
62
-  gradle clean
68
+  "$EXECPATH"/gradlew clean
63 69
   cd ..
64 70
   echo "<<< clean()"
65 71
 }
@@ -141,7 +147,7 @@ make_local_trackler() {
141 147
   local xapi_home="$2"
142 148
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
143 149
 
144
-  local xjava=$( pwd )
150
+  local track_root=$( pwd )
145 151
   pushd ${trackler}
146 152
 
147 153
   # Get the version of Trackler x-api is currently using
@@ -151,11 +157,11 @@ make_local_trackler() {
151 157
   git submodule init -- common
152 158
   git submodule update
153 159
 
154
-  # Bake in local copy of xjava; this is what we are testing.
155
-  rmdir tracks/java
156
-  mkdir -p tracks/java/exercises
157
-  cp ${xjava}/config.json tracks/java
158
-  cp -r ${xjava}/exercises tracks/java
160
+  # Bake in local copy of this track; this is what we are testing.
161
+  rmdir tracks/${TRACK}
162
+  mkdir -p tracks/${TRACK}/exercises
163
+  cp ${track_root}/config.json tracks/${TRACK}
164
+  cp -r ${track_root}/exercises tracks/${TRACK}
159 165
 
160 166
   gem install bundler
161 167
   bundle install
@@ -208,7 +214,7 @@ solve_all_exercises() {
208 214
   local exercism_configfile="$2"
209 215
   echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
210 216
 
211
-  local xjava=$( pwd )
217
+  local track_root=$( pwd )
212 218
   local exercism_cli="./exercism --config ${exercism_configfile}"
213 219
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
214 220
   local total_exercises=`cat config.json | jq '.exercises | length'`
@@ -222,17 +228,20 @@ solve_all_exercises() {
222 228
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
223 229
     echo "=================================================="
224 230
 
225
-    ${exercism_cli} fetch java $exercise
226
-    cp -R -H ${xjava}/exercises/${exercise}/src/example/java/* ${exercism_exercises_dir}/java/${exercise}/src/main/java/
231
+    ${exercism_cli} fetch ${TRACK} $exercise
232
+    cp -R -H ${track_root}/exercises/${exercise}/src/example/${TRACK}/* ${exercism_exercises_dir}/${TRACK}/${exercise}/src/main/${TRACK}/
227 233
 
228
-    pushd ${exercism_exercises_dir}/java/${exercise}
234
+    pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
229 235
     # Check that tests compile before we strip @Ignore annotations
230
-    gradle compileTestJava
236
+    "$EXECPATH"/gradlew compileTestJava
231 237
     # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
232
-    for testfile in `find . -name "*Test.java"`; do
233
-      sed 's/@Ignore\(.*\)//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
238
+    for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
239
+      # Strip @Ignore annotations to ensure we run the tests (as delivered, all but the first is @Ignore'd).
240
+      # Note that unit-test.sh also strips @Ignore annotations via the Gradle task copyTestsFilteringIgnores.
241
+      # The stripping implementations here and in copyTestsFilteringIgnores should be kept consistent.
242
+      sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
234 243
     done
235
-    gradle test
244
+    "$EXECPATH"/gradlew test
236 245
     popd
237 246
 
238 247
     current_exercise_number=$((current_exercise_number + 1))
@@ -244,9 +253,9 @@ main() {
244 253
   # all functions assume current working directory is repository root.
245 254
   cd "${SCRIPTPATH}/.."
246 255
 
247
-  local xjava=$( pwd )
256
+  local track_root=$( pwd )
248 257
   local build_dir="build"
249
-  local build_path="${xjava}/${build_dir}"
258
+  local build_path="${track_root}/${build_dir}"
250 259
 
251 260
   local xapi_home="${build_path}/x-api"
252 261
   local trackler_home="${build_path}/trackler"
@@ -256,12 +265,11 @@ main() {
256 265
   local xapi_port=9292
257 266
 
258 267
   # fail fast if required binaries are not installed.
259
-  assert_installed "gradle"
260 268
   assert_installed "jq"
261 269
 
262 270
   clean "${build_dir}"
263 271
 
264
-  # Make a version of trackler that includes the source from this repo.
272
+  # Make a local version of trackler that includes the source from this repo.
265 273
   git_clone "x-api" "${xapi_home}"
266 274
   git_clone "trackler" "${trackler_home}"
267 275
   assert_ruby_installed "${trackler_home}"

+ 3
- 3
bin/unit-tests.sh Просмотреть файл

@@ -1,6 +1,6 @@
1
-#!/bin/bash
1
+#!/usr/bin/env bash
2 2
 set -e
3
-gradle --version
3
+./gradlew --version
4 4
 
5 5
 echo ""
6 6
 echo ">>> Running configlet..."
@@ -10,6 +10,6 @@ bin/configlet .
10 10
 pushd exercises
11 11
 echo ""
12 12
 echo ">>> Running tests..."
13
-TERM=dumb gradle check compileStarterSourceJava --continue
13
+TERM=dumb ../gradlew check compileStarterSourceJava --parallel --continue
14 14
 popd
15 15
 

+ 245
- 109
config.json Просмотреть файл

@@ -1,339 +1,484 @@
1 1
 {
2 2
   "slug": "java",
3 3
   "language": "Java",
4
-  "repository": "https://github.com/exercism/xjava",
4
+  "repository": "https://github.com/exercism/java",
5 5
   "active": true,
6
-
7 6
   "exercises": [
8 7
     {
9 8
       "slug": "hello-world",
10 9
       "difficulty": 1,
11
-      "topics": []
10
+      "topics": [
11
+
12
+      ]
12 13
     },
13 14
     {
14 15
       "slug": "rna-transcription",
15 16
       "difficulty": 2,
16
-      "topics": []
17
+      "topics": [
18
+
19
+      ]
17 20
     },
18 21
     {
19 22
       "slug": "pangram",
20 23
       "difficulty": 3,
21
-      "topics": []
24
+      "topics": [
25
+
26
+      ]
22 27
     },
23 28
     {
24 29
       "slug": "hamming",
25 30
       "difficulty": 3,
26
-      "topics": []
31
+      "topics": [
32
+
33
+      ]
27 34
     },
28 35
     {
29 36
       "slug": "gigasecond",
30 37
       "difficulty": 3,
31
-      "topics": []
38
+      "topics": [
39
+
40
+      ]
32 41
     },
33 42
     {
34 43
       "slug": "space-age",
35 44
       "difficulty": 3,
36
-      "topics": []
45
+      "topics": [
46
+
47
+      ]
37 48
     },
38 49
     {
39 50
       "slug": "acronym",
40 51
       "difficulty": 3,
41
-      "topics": []
52
+      "topics": [
53
+
54
+      ]
42 55
     },
43 56
     {
44 57
       "slug": "scrabble-score",
45 58
       "difficulty": 3,
46
-      "topics": []
59
+      "topics": [
60
+
61
+      ]
47 62
     },
48 63
     {
49 64
       "slug": "raindrops",
50 65
       "difficulty": 3,
51
-      "topics": []
66
+      "topics": [
67
+
68
+      ]
52 69
     },
53 70
     {
54 71
       "slug": "difference-of-squares",
55 72
       "difficulty": 3,
56
-      "topics": []
73
+      "topics": [
74
+
75
+      ]
57 76
     },
58 77
     {
59 78
       "slug": "secret-handshake",
60 79
       "difficulty": 3,
61
-      "topics": []
80
+      "topics": [
81
+
82
+      ]
83
+    },
84
+    {
85
+      "slug": "perfect-numbers",
86
+      "difficulty": 3,
87
+      "topics": [
88
+
89
+      ]
62 90
     },
63 91
     {
64 92
       "slug": "sum-of-multiples",
65 93
       "difficulty": 4,
66
-      "topics": []
94
+      "topics": [
95
+
96
+      ]
67 97
     },
68 98
     {
69 99
       "slug": "luhn",
70 100
       "difficulty": 4,
71
-      "topics": []
101
+      "topics": [
102
+
103
+      ]
72 104
     },
73 105
     {
74 106
       "slug": "matrix",
75 107
       "difficulty": 4,
76
-      "topics": []
108
+      "topics": [
109
+
110
+      ]
77 111
     },
78 112
     {
79 113
       "slug": "triangle",
80 114
       "difficulty": 4,
81
-      "topics": []
115
+      "topics": [
116
+
117
+      ]
82 118
     },
83 119
     {
84 120
       "slug": "largest-series-product",
85 121
       "difficulty": 4,
86
-      "topics": []
122
+      "topics": [
123
+
124
+      ]
87 125
     },
88 126
     {
89 127
       "slug": "sieve",
90 128
       "difficulty": 4,
91
-      "topics": []
129
+      "topics": [
130
+
131
+      ]
92 132
     },
93 133
     {
94 134
       "slug": "twelve-days",
95 135
       "difficulty": 4,
96
-      "topics": []
136
+      "topics": [
137
+
138
+      ]
139
+    },
140
+    {
141
+      "slug": "kindergarten-garden",
142
+      "difficulty": 4,
143
+      "topics": [
144
+
145
+      ]
146
+    },
147
+    {
148
+      "slug": "collatz-conjecture",
149
+      "difficulty": 4,
150
+      "topics": [
151
+
152
+      ]
97 153
     },
98 154
     {
99 155
       "slug": "nth-prime",
100 156
       "difficulty": 4,
101
-      "topics": []
157
+      "topics": [
158
+
159
+      ]
160
+    },
161
+    {
162
+      "slug": "saddle-points",
163
+      "difficulty": 4,
164
+      "topics": [
165
+
166
+      ]
102 167
     },
103 168
     {
104 169
       "slug": "diamond",
105 170
       "difficulty": 4,
106
-      "topics": []
171
+      "topics": [
172
+
173
+      ]
107 174
     },
108 175
     {
109 176
       "slug": "isogram",
110 177
       "difficulty": 4,
111
-      "topics": []
178
+      "topics": [
179
+
180
+      ]
112 181
     },
113 182
     {
114 183
       "slug": "flatten-array",
115 184
       "difficulty": 5,
116
-      "topics": []
185
+      "topics": [
186
+
187
+      ]
117 188
     },
118 189
     {
119 190
       "slug": "pig-latin",
120 191
       "difficulty": 5,
121
-      "topics": []
192
+      "topics": [
193
+
194
+      ]
122 195
     },
123 196
     {
124 197
       "slug": "phone-number",
125 198
       "difficulty": 5,
126
-      "topics": []
199
+      "topics": [
200
+
201
+      ]
127 202
     },
128 203
     {
129 204
       "slug": "nucleotide-count",
130 205
       "difficulty": 5,
131
-      "topics": []
206
+      "topics": [
207
+
208
+      ]
132 209
     },
133 210
     {
134 211
       "slug": "word-count",
135 212
       "difficulty": 5,
136
-      "topics": []
213
+      "topics": [
214
+
215
+      ]
216
+    },
217
+    {
218
+      "slug": "run-length-encoding",
219
+      "difficulty": 5,
220
+      "topics": [
221
+
222
+      ]
137 223
     },
138 224
     {
139 225
       "slug": "robot-name",
140 226
       "difficulty": 5,
141
-      "topics": []
227
+      "topics": [
228
+
229
+      ]
142 230
     },
143 231
     {
144 232
       "slug": "prime-factors",
145 233
       "difficulty": 5,
146
-      "topics": []
234
+      "topics": [
235
+
236
+      ]
147 237
     },
148 238
     {
149 239
       "slug": "allergies",
150 240
       "difficulty": 5,
151
-      "topics": []
241
+      "topics": [
242
+
243
+      ]
152 244
     },
153 245
     {
154 246
       "slug": "bob",
155 247
       "difficulty": 5,
156
-      "topics": []
248
+      "topics": [
249
+
250
+      ]
157 251
     },
158 252
     {
159 253
       "slug": "pascals-triangle",
160 254
       "difficulty": 5,
161
-      "topics": []
255
+      "topics": [
256
+
257
+      ]
162 258
     },
163 259
     {
164 260
       "slug": "bracket-push",
165 261
       "difficulty": 5,
166
-      "topics": []
262
+      "topics": [
263
+
264
+      ]
167 265
     },
168 266
     {
169 267
       "slug": "series",
170 268
       "difficulty": 5,
171
-      "topics": []
269
+      "topics": [
270
+
271
+      ]
172 272
     },
173 273
     {
174 274
       "slug": "atbash-cipher",
175 275
       "difficulty": 5,
176
-      "topics": []
276
+      "topics": [
277
+
278
+      ]
177 279
     },
178 280
     {
179 281
       "slug": "roman-numerals",
180 282
       "difficulty": 6,
181
-      "topics": []
283
+      "topics": [
284
+
285
+      ]
182 286
     },
183 287
     {
184 288
       "slug": "beer-song",
185 289
       "difficulty": 6,
186
-      "topics": []
290
+      "topics": [
291
+
292
+      ]
187 293
     },
188 294
     {
189 295
       "slug": "queen-attack",
190 296
       "difficulty": 6,
191
-      "topics": []
297
+      "topics": [
298
+
299
+      ]
192 300
     },
193 301
     {
194 302
       "slug": "etl",
195 303
       "difficulty": 6,
196
-      "topics": []
304
+      "topics": [
305
+
306
+      ]
197 307
     },
198 308
     {
199 309
       "slug": "linked-list",
200 310
       "difficulty": 6,
201
-      "topics": []
311
+      "topics": [
312
+
313
+      ]
202 314
     },
203 315
     {
204 316
       "slug": "grade-school",
205 317
       "difficulty": 6,
206
-      "topics": []
318
+      "topics": [
319
+
320
+      ]
207 321
     },
208 322
     {
209 323
       "slug": "robot-simulator",
210 324
       "difficulty": 6,
211
-      "topics": []
325
+      "topics": [
326
+
327
+      ]
212 328
     },
213 329
     {
214 330
       "slug": "binary-search",
215 331
       "difficulty": 6,
216
-      "topics": []
332
+      "topics": [
333
+
334
+      ]
217 335
     },
218 336
     {
219 337
       "slug": "minesweeper",
220 338
       "difficulty": 6,
221
-      "topics": []
339
+      "topics": [
340
+
341
+      ]
222 342
     },
223 343
     {
224 344
       "slug": "wordy",
225 345
       "difficulty": 6,
226
-      "topics": []
346
+      "topics": [
347
+
348
+      ]
227 349
     },
228 350
     {
229 351
       "slug": "all-your-base",
230 352
       "difficulty": 6,
231
-      "topics": []
353
+      "topics": [
354
+
355
+      ]
232 356
     },
233 357
     {
234 358
       "slug": "anagram",
235 359
       "difficulty": 7,
236
-      "topics": []
360
+      "topics": [
361
+
362
+      ]
237 363
     },
238 364
     {
239 365
       "slug": "sublist",
240 366
       "difficulty": 7,
241
-      "topics": []
367
+      "topics": [
368
+
369
+      ]
242 370
     },
243 371
     {
244
-      "slug": "simple-linked-list",
372
+      "slug": "word-search",
245 373
       "difficulty": 7,
246
-      "topics": []
374
+      "topics": [
375
+
376
+      ]
247 377
     },
248 378
     {
249
-      "slug": "binary-search-tree",
379
+      "slug": "simple-linked-list",
250 380
       "difficulty": 7,
251
-      "topics": []
381
+      "topics": [
382
+
383
+      ]
252 384
     },
253 385
     {
254
-      "slug": "rectangles",
386
+      "slug": "binary-search-tree",
255 387
       "difficulty": 7,
256
-      "topics": []
388
+      "topics": [
389
+
390
+      ]
257 391
     },
258 392
     {
259 393
       "slug": "meetup",
260 394
       "difficulty": 7,
261
-      "topics": []
395
+      "topics": [
396
+
397
+      ]
262 398
     },
263 399
     {
264 400
       "slug": "crypto-square",
265 401
       "difficulty": 7,
266
-      "topics": []
402
+      "topics": [
403
+
404
+      ]
267 405
     },
268 406
     {
269
-      "slug": "simple-cipher",
270
-      "difficulty": 8,
271
-      "topics": []
407
+      "slug": "clock",
408
+      "difficulty": 7,
409
+      "topics": [
410
+
411
+      ]
272 412
     },
273 413
     {
274
-      "slug": "palindrome-products",
414
+      "slug": "ocr-numbers",
275 415
       "difficulty": 8,
276
-      "topics": []
277
-    },
278
-    {
279
-      "slug": "pythagorean-triplet",
280
-      "difficulty": 9,
281
-      "topics": []
416
+      "topics": [
417
+
418
+      ]
282 419
     },
283 420
     {
284
-      "slug": "custom-set",
285
-      "difficulty": 10,
286
-      "topics": []
421
+      "slug": "rectangles",
422
+      "difficulty": 8,
423
+      "topics": [
424
+
425
+      ]
287 426
     },
288 427
     {
289
-      "slug": "clock",
290
-      "difficulty": 1,
291
-      "topics": []
428
+      "slug": "book-store",
429
+      "difficulty": 8,
430
+      "topics": [
431
+
432
+      ]
292 433
     },
293 434
     {
294
-      "slug": "perfect-numbers",
295
-      "difficulty": 1,
296
-      "topics": []
435
+      "slug": "simple-cipher",
436
+      "difficulty": 8,
437
+      "topics": [
438
+
439
+      ]
297 440
     },
298 441
     {
299 442
       "slug": "change",
300
-      "difficulty": 1,
301
-      "topics": []
302
-    },
303
-    {
304
-      "slug": "list-ops",
305
-      "difficulty": 1,
306
-      "topics": []
307
-    },
308
-    {
309
-      "slug": "ocr-numbers",
310
-      "difficulty": 1,
311
-      "topics": []
443
+      "difficulty": 8,
444
+      "topics": [
445
+
446
+      ]
312 447
     },
313 448
     {
314
-      "slug": "book-store",
315
-      "difficulty": 1,
316
-      "topics": []
449
+      "slug": "palindrome-products",
450
+      "difficulty": 8,
451
+      "topics": [
452
+
453
+      ]
317 454
     },
318 455
     {
319
-      "slug": "saddle-points",
320
-      "difficulty": 1,
321
-      "topics": []
456
+      "slug": "pythagorean-triplet",
457
+      "difficulty": 9,
458
+      "topics": [
459
+
460
+      ]
322 461
     },
323 462
     {
324
-      "slug": "run-length-encoding",
325
-      "difficulty": 1,
326
-      "topics": []
463
+      "slug": "custom-set",
464
+      "difficulty": 10,
465
+      "topics": [
466
+
467
+      ]
327 468
     },
328 469
     {
329
-      "slug": "kindergarten-garden",
470
+      "slug": "list-ops",
330 471
       "difficulty": 1,
331
-      "topics": []
472
+      "topics": [
473
+      
474
+      ]
332 475
     },
333 476
     {
334 477
       "slug": "transpose",
335 478
       "difficulty": 1,
336
-      "topics": []
479
+      "topics": [
480
+      
481
+      ]
337 482
     }
338 483
   ],
339 484
   "deprecated": [
@@ -344,18 +489,9 @@
344 489
     "strain",
345 490
     "trinary"
346 491
   ],
347
-  "ignored": [
348
-    "_template",
349
-    ".gradle",
350
-    "build",
351
-    "docs",
352
-    "gradle",
353
-    "scripts"
354
-  ],
355 492
   "foregone": [
356 493
     "leap",
357 494
     "grains",
358 495
     "say"
359 496
   ]
360 497
 }
361
-

SETUP.md → docs/EXERCISE_README_INSERT.md Просмотреть файл


+ 4
- 21
docs/MAINTAINING.md Просмотреть файл

@@ -4,23 +4,22 @@ This is a guide/reference for maintainers of the Java track.
4 4
 
5 5
 - [Your Permissions](#your-permissions)
6 6
 - [Maintainer Guides](#maintainer-guides)
7
-- [The Project Board](#the-project-board)
8 7
 - [Miscellaneous](#miscellaneous)
9 8
 
10 9
 ## Your Permissions 
11 10
 
12
-As a maintainer, you have write access to four repositories.  "write access" means you can: review, reject, accept and merge PRs; and push changes to these repos.  Despite having permissions to push directly, we tend to seek review of even our own PRs.
11
+As a maintainer, you have write access to several repositories.  "write access" means you can: review, reject, accept and merge PRs; and push changes to these repos.  Despite having permissions to push directly, we tend to seek review of even our own PRs.
13 12
 
14 13
 ### Track-specific
15 14
 
16
-- [xjava](https://github.com/exercism/xjava) — yeah... you know what this one is. :)
15
+- [java](https://github.com/exercism/java) — yeah... you know what this one is. :)
17 16
 
18 17
 ### Exercism-wide
19 18
 
20
-- [x-common](https://github.com/exercism/x-common) — the library of canonical exercises.
19
+- [problem-specifications](https://github.com/exercism/problem-specifications) — the library of canonical exercises.
21 20
 - [discussions](https://github.com/exercism/discussions) — the place where project-wide conversations happen. 
22 21
   [issues sorted by most recently updated.](https://github.com/exercism/discussions/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
23
-- [todo](https://github.com/exercism/todo) — not really used... might just go away completely in the future.
22
+- [docs](https://github.com/exercism/docs) - the place to find project-wide documentation.
24 23
 
25 24
 ## Maintainer Guides
26 25
 
@@ -28,22 +27,6 @@ As a maintainer, you have write access to four repositories.  "write access" mea
28 27
 - [exercism.io/docs/getting-involved-in-a-track.md](https://github.com/exercism/exercism.io/blob/master/docs/getting-involved-in-a-track.md)
29 28
 - [exercism.io/docs/reviewing-a-pull-request.md](https://github.com/exercism/exercism.io/blob/master/docs/reviewing-a-pull-request.md)
30 29
 
31
-## The Project Board
32
-
33
-GitHub issues are great, but there's no way to easily set priorities.
34
-To do this, we're using a GitHub Project: https://github.com/exercism/xjava/projects/2.
35
-
36
-- **Epics** — issues that really represent bigger ideas.  These inspire creating a set of smaller issues to be elaborated...
37
-- **Icebox** — issues that just needs a little more detail to be "ready to play"...
38
-- **Backlog** — issues ready to be worked.  When we start working on an issue, we move it to the next column...
39
-- **Current** — issues in progress.  When we've considered it done, we move the card to...
40
-- **Delivered** — completed issues that could use another pair of eyes.  When these are reviewed they get moved to...
41
-- **Done** — issues we've complete.  Every so often, we get together and it's nice to review what we've completed. 
42
-  Once reviewed, we remove them from this Project.
43
-
44
-The point of this board is to make clear our shared priorities.  It's a tool you can use.
45
-However, if you have an idea and want to implement it, you can just do it; it does not have to be added to this board.
46
-
47 30
 ## Miscellaneous
48 31
 
49 32
 - Issues marked with "policy" are current "team agreements": [exercism?label:policy](https://github.com/search?q=org%3Aexercism+label%3Apolicy).

+ 3
- 3
docs/TESTS.md Просмотреть файл

@@ -37,7 +37,7 @@ Choose your operating system:
37 37
    C:\Users\JohnDoe>gradle test
38 38
    ```
39 39
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
40
-5. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/xjava/blob/master/exercises/hello-world/GETTING_STARTED.md)).
40
+5. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/java/blob/master/exercises/hello-world/GETTING_STARTED.md)).
41 41
 
42 42
 
43 43
 Good luck!  Have fun!
@@ -70,7 +70,7 @@ If you get stuck, at any point, don't forget to reach out for [help](http://exer
70 70
   $ gradle test
71 71
   ```
72 72
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
73
-4. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/xjava/blob/master/exercises/hello-world/GETTING_STARTED.md)).
73
+4. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/java/blob/master/exercises/hello-world/GETTING_STARTED.md)).
74 74
 
75 75
 Good luck!  Have fun!
76 76
 
@@ -102,7 +102,7 @@ If you get stuck, at any point, don't forget to reach out for [help](http://exer
102 102
   $ gradle test
103 103
   ```
104 104
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
105
-4. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/xjava/blob/master/exercises/hello-world/GETTING_STARTED.md)).
105
+4. Solve the exercise.  Find and work through the `GETTING_STARTED.md` guide ([view on GitHub](https://github.com/exercism/java/blob/master/exercises/hello-world/GETTING_STARTED.md)).
106 106
 
107 107
 Good luck!  Have fun!
108 108
 

+ 1
- 0
exercises/accumulate/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/acronym/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/acronym/src/main/java/Acronym.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class Acronym {
1
+class Acronym {
2 2
 
3 3
     Acronym(String phrase) {
4 4
         throw new UnsupportedOperationException("Delete this statement and write your own implementation.");

+ 1
- 0
exercises/all-your-base/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/all-your-base/src/main/java/BaseConverter.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class BaseConverter {
1
+class BaseConverter {
2 2
 
3 3
 
4 4
 

+ 23
- 20
exercises/all-your-base/src/test/java/BaseConverterTest.java Просмотреть файл

@@ -7,6 +7,9 @@ import java.util.Arrays;
7 7
 
8 8
 import static org.junit.Assert.assertArrayEquals;
9 9
 
10
+/*
11
+ * version: 1.1.0
12
+ */
10 13
 public class BaseConverterTest {
11 14
 
12 15
     /*
@@ -197,69 +200,69 @@ public class BaseConverterTest {
197 200
 
198 201
     @Ignore("Remove to run test")
199 202
     @Test
200
-    public void testNegativeDigit() {
203
+    public void testFirstBaseIsOne() {
201 204
         expectedException.expect(IllegalArgumentException.class);
202
-        expectedException.expectMessage("Digits may not be negative.");
205
+        expectedException.expectMessage("Bases must be at least 2.");
203 206
 
204
-        new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0});
207
+        new BaseConverter(1, new int[]{});
205 208
     }
206 209
 
207 210
     @Ignore("Remove to run test")
208 211
     @Test
209
-    public void testInvalidPositiveDigit() {
212
+    public void testFirstBaseIsZero() {
210 213
         expectedException.expect(IllegalArgumentException.class);
211
-        expectedException.expectMessage("All digits must be strictly less than the base.");
214
+        expectedException.expectMessage("Bases must be at least 2.");
212 215
 
213
-        new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0});
216
+        new BaseConverter(0, new int[]{});
214 217
     }
215 218
 
216 219
     @Ignore("Remove to run test")
217 220
     @Test
218
-    public void testFirstBaseIsOne() {
221
+    public void testFirstBaseIsNegative() {
219 222
         expectedException.expect(IllegalArgumentException.class);
220 223
         expectedException.expectMessage("Bases must be at least 2.");
221 224
 
222
-        new BaseConverter(1, new int[]{});
225
+        new BaseConverter(-2, new int[]{});
223 226
     }
224 227
 
225 228
     @Ignore("Remove to run test")
226 229
     @Test
227
-    public void testSecondBaseIsOne() {
228
-        final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
229
-
230
+    public void testNegativeDigit() {
230 231
         expectedException.expect(IllegalArgumentException.class);
231
-        expectedException.expectMessage("Bases must be at least 2.");
232
+        expectedException.expectMessage("Digits may not be negative.");
232 233
 
233
-        baseConverter.convertToBase(1);
234
+        new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0});
234 235
     }
235 236
 
236 237
     @Ignore("Remove to run test")
237 238
     @Test
238
-    public void testFirstBaseIsZero() {
239
+    public void testInvalidPositiveDigit() {
239 240
         expectedException.expect(IllegalArgumentException.class);
240
-        expectedException.expectMessage("Bases must be at least 2.");
241
+        expectedException.expectMessage("All digits must be strictly less than the base.");
241 242
 
242
-        new BaseConverter(0, new int[]{});
243
+        new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0});
243 244
     }
244 245
 
245 246
     @Ignore("Remove to run test")
246 247
     @Test
247
-    public void testSecondBaseIsZero() {
248
+    public void testSecondBaseIsOne() {
248 249
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
249 250
 
250 251
         expectedException.expect(IllegalArgumentException.class);
251 252
         expectedException.expectMessage("Bases must be at least 2.");
252 253
 
253
-        baseConverter.convertToBase(0);
254
+        baseConverter.convertToBase(1);
254 255
     }
255 256
 
256 257
     @Ignore("Remove to run test")
257 258
     @Test
258
-    public void testFirstBaseIsNegative() {
259
+    public void testSecondBaseIsZero() {
260
+        final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
261
+
259 262
         expectedException.expect(IllegalArgumentException.class);
260 263
         expectedException.expectMessage("Bases must be at least 2.");
261 264
 
262
-        new BaseConverter(-2, new int[]{});
265
+        baseConverter.convertToBase(0);
263 266
     }
264 267
 
265 268
     @Ignore("Remove to run test")

+ 1
- 0
exercises/allergies/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/anagram/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/atbash-cipher/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/beer-song/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 32
- 32
exercises/binary-search-tree/src/test/java/BSTTest.java Просмотреть файл

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

+ 1
- 0
exercises/binary-search/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 70
- 78
exercises/binary-search/src/test/java/BinarySearchTest.java Просмотреть файл

@@ -1,136 +1,128 @@
1 1
 
2
+import org.junit.Ignore;
3
+import org.junit.Test;
4
+
2 5
 import java.util.ArrayList;
3 6
 import java.util.Arrays;
4 7
 import java.util.Collections;
5 8
 import java.util.List;
9
+
6 10
 import static org.junit.Assert.assertEquals;
7
-import org.junit.Ignore;
8
-import org.junit.Test;
9 11
 
10 12
 public class BinarySearchTest {
11 13
 
12
-    public static final List<Integer> EMPTY_LIST
13
-            = Collections.unmodifiableList(new ArrayList<Integer>(0));
14
-
15
-    public static final List<Integer> LIST_OF_UNIT_LENGTH
16
-            = Collections.unmodifiableList(
17
-                    Arrays.asList(6)
18
-            );
19
-
20
-    private static final List<Integer> SORTED_LIST
21
-            = Collections.unmodifiableList(
22
-                    Arrays.asList(1, 3, 4, 6, 8, 9, 11)
23
-            );
24
-
25
-    public static final List<Integer> SORTED_LIST_OF_ODD_LENGTH
26
-            = Collections.unmodifiableList(
27
-                    Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55,
28
-                            89, 144, 233, 377, 634)
29
-            );
30
-
31
-    public static final List<Integer> SORTED_LIST_OF_EVEN_LENGTH
32
-            = Collections.unmodifiableList(
33
-                    Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55,
34
-                            89, 144, 233, 377)
35
-            );
36
-
37 14
     @Test
38 15
     public void findsAValueInAnArrayWithOneElement() {
39
-        BinarySearch<Integer> sut = new BinarySearch<>(LIST_OF_UNIT_LENGTH);
40
-        final int value = 6;
41
-        final int actual = sut.indexOf(value);
42
-        final int expected = 0;
43
-        assertEquals(expected, actual);
16
+        List<Integer> listOfUnitLength = Collections.singletonList(6);
17
+
18
+        BinarySearch<Integer> search = new BinarySearch<>(listOfUnitLength);
19
+
20
+        assertEquals(0, search.indexOf(6));
44 21
     }
45 22
 
46 23
     @Ignore("Remove to run test")
47 24
     @Test
48 25
     public void findsAValueInTheMiddleOfAnArray() {
49
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
50
-        final int value = 6;
51
-        final int actual = sut.indexOf(value);
52
-        final int expected = 3;
53
-        assertEquals(expected, actual);
26
+        List<Integer> sortedList = Collections.unmodifiableList(
27
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
28
+        );
29
+
30
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
31
+
32
+        assertEquals(3, search.indexOf(6));
54 33
     }
55 34
 
56 35
     @Ignore("Remove to run test")
57 36
     @Test
58 37
     public void findsAValueAtTheBeginningOfAnArray() {
59
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
60
-        final int value = 1;
61
-        final int actual = sut.indexOf(value);
62
-        final int expected = 0;
63
-        assertEquals(expected, actual);
38
+        List<Integer> sortedList = Collections.unmodifiableList(
39
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
40
+        );
41
+
42
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
43
+
44
+        assertEquals(0, search.indexOf(1));
64 45
     }
65 46
 
66 47
     @Ignore("Remove to run test")
67 48
     @Test
68 49
     public void findsAValueAtTheEndOfAnArray() {
69
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
70
-        final int value = 11;
71
-        final int actual = sut.indexOf(value);
72
-        final int expected = 6;
73
-        assertEquals(expected, actual);
50
+        List<Integer> sortedList = Collections.unmodifiableList(
51
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
52
+        );
53
+
54
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
55
+
56
+        assertEquals(6, search.indexOf(11));
74 57
     }
75 58
 
76 59
     @Ignore("Remove to run test")
77 60
     @Test
78 61
     public void findsAValueInAnArrayOfOddLength() {
79
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST_OF_ODD_LENGTH);
80
-        final int value = 144;
81
-        final int actual = sut.indexOf(value);
82
-        final int expected = 9;
83
-        assertEquals(expected, actual);
62
+        List<Integer> sortedListOfOddLength = Collections.unmodifiableList(
63
+                Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634)
64
+        );
65
+
66
+        BinarySearch<Integer> search = new BinarySearch<>(sortedListOfOddLength);
67
+
68
+        assertEquals(9, search.indexOf(144));
84 69
     }
85 70
 
86 71
     @Ignore("Remove to run test")
87 72
     @Test
88 73
     public void findsAValueInAnArrayOfEvenLength() {
89
-        BinarySearch<Integer> sut
90
-                = new BinarySearch<>(SORTED_LIST_OF_EVEN_LENGTH);
91
-        final int value = 21;
92
-        final int actual = sut.indexOf(value);
93
-        final int expected = 5;
94
-        assertEquals(expected, actual);
74
+        List<Integer> sortedListOfEvenLength = Collections.unmodifiableList(
75
+                Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377)
76
+        );
77
+
78
+        BinarySearch<Integer> search = new BinarySearch<>(sortedListOfEvenLength);
79
+
80
+        assertEquals(5, search.indexOf(21));
95 81
     }
96 82
 
97 83
     @Ignore("Remove to run test")
98 84
     @Test
99 85
     public void identifiesThatAValueIsNotIncludedInTheArray() {
100
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
101
-        final int value = 7;
102
-        final int actual = sut.indexOf(value);
103
-        final int expected = -1;
104
-        assertEquals(expected, actual);
86
+        List<Integer> sortedList = Collections.unmodifiableList(
87
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
88
+        );
89
+
90
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
91
+
92
+        assertEquals(-1, search.indexOf(7));
105 93
     }
106 94
 
107 95
     @Ignore("Remove to run test")
108 96
     @Test
109 97
     public void aValueSmallerThanTheArraysSmallestValueIsNotIncluded() {
110
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
111
-        final int value = 0;
112
-        final int actual = sut.indexOf(value);
113
-        final int expected = -1;
114
-        assertEquals(expected, actual);
98
+        List<Integer> sortedList = Collections.unmodifiableList(
99
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
100
+        );
101
+
102
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
103
+
104
+        assertEquals(-1, search.indexOf(0));
115 105
     }
116 106
 
117 107
     @Ignore("Remove to run test")
118 108
     @Test
119 109
     public void aValueLargerThanTheArraysSmallestValueIsNotIncluded() {
120
-        BinarySearch<Integer> sut = new BinarySearch<>(SORTED_LIST);
121
-        final int value = 13;
122
-        final int actual = sut.indexOf(value);
123
-        final int expected = -1;
124
-        assertEquals(expected, actual);
110
+        List<Integer> sortedList = Collections.unmodifiableList(
111
+                Arrays.asList(1, 3, 4, 6, 8, 9, 11)
112
+        );
113
+
114
+        BinarySearch<Integer> search = new BinarySearch<>(sortedList);
115
+
116
+        assertEquals(-1, search.indexOf(13));
125 117
     }
126 118
 
127 119
     @Ignore("Remove to run test")
128 120
     @Test
129 121
     public void nothingIsIncludedInAnEmptyArray() {
130
-        BinarySearch<Integer> sut = new BinarySearch<>(EMPTY_LIST);
131
-        final int value = 1;
132
-        final int actual = sut.indexOf(value);
133
-        final int expected = -1;
134
-        assertEquals(expected, actual);
122
+        List<Integer> emptyList = Collections.emptyList();
123
+
124
+        BinarySearch<Integer> search = new BinarySearch<>(emptyList);
125
+
126
+        assertEquals(-1, search.indexOf(1));
135 127
     }
136 128
 }

+ 1
- 0
exercises/binary/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/bob/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/book-store/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

exercises/book-store/src/example/java/Bookstore.java → exercises/book-store/src/example/java/BookStore.java Просмотреть файл

@@ -2,23 +2,17 @@ import java.util.ArrayList;
2 2
 import java.util.List;
3 3
 import java.util.stream.Collectors;
4 4
 
5
-class Bookstore {
5
+class BookStore {
6 6
 
7 7
   private static final int BOOK_PRICE = 8, MAX_GROUP_SIZE = 5;
8 8
 
9 9
   private static double[] DISCOUNT_TIERS = {0, 5, 10, 20, 25};
10 10
 
11
-  private List<Integer> books;
12
-
13
-  Bookstore(List<Integer> books) {
14
-    this.books = books;
15
-  }
16
-
17
-  double calculateTotalCost() {
18
-    return calculateTotalCost(this.books, 0);
11
+  double calculateBasketCost(final List<Integer> books) {
12
+    return calculateBasketCost(books, 0);
19 13
   }
20 14
 
21
-  private double calculateTotalCost(List<Integer> books, double priceSoFar) {
15
+  private double calculateBasketCost(final List<Integer> books, final double priceSoFar) {
22 16
     if (books.size() == 0) {
23 17
       return priceSoFar;
24 18
     }
@@ -38,8 +32,7 @@ class Bookstore {
38 32
         remainingBooks.remove(newGroupBook);
39 33
       }
40 34
 
41
-      double price = calculateTotalCost(remainingBooks, priceSoFar + costOfGroupSize(newGroupBooks.size()));
42
-
35
+      double price = calculateBasketCost(remainingBooks, priceSoFar + costOfGroupSize(newGroupBooks.size()));
43 36
       minPrice = Math.min(minPrice, price);
44 37
     }
45 38
 

+ 113
- 0
exercises/book-store/src/test/java/BookStoreTest.java Просмотреть файл

@@ -0,0 +1,113 @@
1
+import static org.junit.Assert.assertEquals;
2
+
3
+import java.util.Collections;
4
+import java.util.List;
5
+import java.util.Arrays;
6
+
7
+import org.junit.Before;
8
+import org.junit.Ignore;
9
+import org.junit.Test;
10
+
11
+public class BookStoreTest {
12
+
13
+  // This is sufficient accuracy since we're handling currency values, which should be equal to within 2 decimal places.
14
+  private static final double EQUALITY_TOLERANCE = 0.001;
15
+
16
+  private BookStore bookStore;
17
+
18
+  @Before
19
+  public void setUp() {
20
+    bookStore = new BookStore();
21
+  }
22
+
23
+  @Test
24
+  public void onlyASingleBook() {
25
+    List<Integer> books = Collections.singletonList(1);
26
+    assertEquals(8, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
27
+  }
28
+
29
+  @Ignore("Remove to run test")
30
+  @Test
31
+  public void twoOfSameBook() {
32
+    List<Integer> books = Arrays.asList(1, 1);
33
+    assertEquals(16, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
34
+  }
35
+
36
+  @Ignore("Remove to run test")
37
+  @Test
38
+  public void emptyBasket() {
39
+    List<Integer> books = Collections.emptyList();
40
+    assertEquals(0, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
41
+  }
42
+
43
+  @Ignore("Remove to run test")
44
+  @Test
45
+  public void twoDifferentBooks() {
46
+    List<Integer> books = Arrays.asList(1, 2);
47
+    assertEquals(15.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
48
+  }
49
+
50
+  @Ignore("Remove to run test")
51
+  @Test
52
+  public void threeDifferentBooks() {
53
+    List<Integer> books = Arrays.asList(1, 2, 3);
54
+    assertEquals(21.6, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
55
+  }
56
+
57
+  @Ignore("Remove to run test")
58
+  @Test
59
+  public void fourDifferentBooks() {
60
+    List<Integer> books = Arrays.asList(1, 2, 3, 4);
61
+    assertEquals(25.6, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
62
+  }
63
+
64
+  @Ignore("Remove to run test")
65
+  @Test
66
+  public void fiveDifferentBooks() {
67
+    List<Integer> books = Arrays.asList(1, 2, 3, 4, 5);
68
+    assertEquals(30, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
69
+  }
70
+
71
+  @Ignore("Remove to run test")
72
+  @Test
73
+  public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() {
74
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5);
75
+    assertEquals(51.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
76
+  }
77
+
78
+  @Ignore("Remove to run test")
79
+  @Test
80
+  public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() {
81
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 4);
82
+    assertEquals(40.8, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
83
+  }
84
+
85
+  @Ignore("Remove to run test")
86
+  @Test
87
+  public void twoEachOfFirst4BooksAnd1CopyEachOfRest() {
88
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5);
89
+    assertEquals(55.60, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
90
+  }
91
+
92
+  @Ignore("Remove to run test")
93
+  @Test
94
+  public void twoCopiesOfEachBook() {
95
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5);
96
+    assertEquals(60.00, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
97
+  }
98
+
99
+  @Ignore("Remove to run test")
100
+  @Test
101
+  public void threeCopiesOfFirstBookAnd2EachOfRemaining() {
102
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1);
103
+    assertEquals(68.00, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
104
+  }
105
+
106
+  @Ignore("Remove to run test")
107
+  @Test
108
+  public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() {
109
+    List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2);
110
+    assertEquals(75.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
111
+  }
112
+
113
+}

+ 0
- 119
exercises/book-store/src/test/java/BookstoreTest.java Просмотреть файл

@@ -1,119 +0,0 @@
1
-import static org.junit.Assert.assertEquals;
2
-
3
-import java.util.Collections;
4
-import java.util.List;
5
-import java.util.ArrayList;
6
-import java.util.Arrays;
7
-
8
-import org.junit.Ignore;
9
-import org.junit.Test;
10
-
11
-public class BookstoreTest {
12
-
13
-  // This is sufficient accuracy since we're handling currency values, which should be equal to within 2 decimal places.
14
-  private static final double EQUALITY_TOLERANCE = 0.001;
15
-
16
-  @Test
17
-  public void onlyASingleBook() {
18
-    List<Integer> books = new ArrayList<>(Collections.singletonList(1));
19
-    Bookstore bookstore = new Bookstore(books);
20
-    assertEquals(8, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
21
-  }
22
-
23
-  @Ignore("Remove to run test")
24
-  @Test
25
-  public void twoOfSameBook() {
26
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1));
27
-    Bookstore bookstore = new Bookstore(books);
28
-    assertEquals(16, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
29
-  }
30
-
31
-  @Ignore("Remove to run test")
32
-  @Test
33
-  public void emptyBasket() {
34
-    List<Integer> books = new ArrayList<>();
35
-    Bookstore bookstore = new Bookstore(books);
36
-    assertEquals(0, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
37
-  }
38
-
39
-  @Ignore("Remove to run test")
40
-  @Test
41
-  public void twoDifferentBooks() {
42
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 2));
43
-    Bookstore bookstore = new Bookstore(books);
44
-    assertEquals(15.20, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
45
-  }
46
-
47
-  @Ignore("Remove to run test")
48
-  @Test
49
-  public void threeDifferentBooks() {
50
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 2, 3));
51
-    Bookstore bookstore = new Bookstore(books);
52
-    assertEquals(21.6, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
53
-  }
54
-
55
-  @Ignore("Remove to run test")
56
-  @Test
57
-  public void fourDifferentBooks() {
58
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 2, 3, 4));
59
-    Bookstore bookstore = new Bookstore(books);
60
-    assertEquals(25.6, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
61
-  }
62
-
63
-  @Ignore("Remove to run test")
64
-  @Test
65
-  public void fiveDifferentBooks() {
66
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
67
-    Bookstore bookstore = new Bookstore(books);
68
-    assertEquals(30, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
69
-  }
70
-
71
-  @Ignore("Remove to run test")
72
-  @Test
73
-  public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() {
74
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5));
75
-    Bookstore bookstore = new Bookstore(books);
76
-    assertEquals(51.20, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
77
-  }
78
-
79
-  @Ignore("Remove to run test")
80
-  @Test
81
-  public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() {
82
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 4));
83
-    Bookstore bookstore = new Bookstore(books);
84
-    assertEquals(40.8, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
85
-  }
86
-
87
-  @Ignore("Remove to run test")
88
-  @Test
89
-  public void twoEachOfFirst4BooksAnd1CopyEachOfRest() {
90
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5));
91
-    Bookstore bookstore = new Bookstore(books);
92
-    assertEquals(55.60, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
93
-  }
94
-
95
-  @Ignore("Remove to run test")
96
-  @Test
97
-  public void twoCopiesOfEachBook() {
98
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5));
99
-    Bookstore bookstore = new Bookstore(books);
100
-    assertEquals(60.00, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
101
-  }
102
-
103
-  @Ignore("Remove to run test")
104
-  @Test
105
-  public void threeCopiesOfFirstBookAnd2EachOfRemaining() {
106
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1));
107
-    Bookstore bookstore = new Bookstore(books);
108
-    assertEquals(68.00, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
109
-  }
110
-
111
-  @Ignore("Remove to run test")
112
-  @Test
113
-  public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() {
114
-    List<Integer> books = new ArrayList<>(Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2));
115
-    Bookstore bookstore = new Bookstore(books);
116
-    assertEquals(75.20, bookstore.calculateTotalCost(), EQUALITY_TOLERANCE);
117
-  }
118
-
119
-}

+ 1
- 0
exercises/bracket-push/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/bracket-push/src/main/java/BracketChecker.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class BracketChecker {
1
+class BracketChecker {
2 2
 
3 3
 
4 4
 

+ 57
- 31
exercises/build.gradle Просмотреть файл

@@ -1,41 +1,67 @@
1
-subprojects { project ->
2
-  apply plugin: "java"
3
-
4
-  sourceSets {
5
-    // Verify that the tests are working by running them against the example code.
6
-    // By replacing the "main" sourceSet with the example code we avoid any collisions
7
-    //   with solution code that may have been included as a "starter" (e.g. etl).
8
-    main {
9
-      java.srcDirs = ["src/example/java"]
10
-    }
11
-    project["compileJava"].doFirst { compileTask ->
12
-      println "  (source = " + compileTask.source.asPath + ")"
13
-    }
1
+// This root Gradle project is used for:
2
+//
3
+// - Checking that every test suite compiles against its corresponding example implementation;
4
+// - Checking that every example implementation passes its corresponding test suite;
5
+// - Checking that every provided starter implementation compiles.
6
+//
7
+// This file is never delivered to Exercism users.
14 8
 
15
-    starterSource {
16
-      java.srcDirs = ["src/main/java"]
17
-    }
18
-    project["compileStarterSourceJava"].doFirst { compileTask ->
19
-      println "  (source = " + compileTask.source.asPath + ")"
20
-    }
9
+def generatedTestSourceDir = "build/gen/test/java"
21 10
 
22
-    // In lieu of being able to disable @Ignore in JUnit tests, we filter
23
-    // those annotations, placing the edited tests in the path named here.
24
-    test {
25
-      java.srcDirs = ["build/gen/test/java"]
26
-    }
27
-    project["compileTestJava"].doFirst { compileTask ->
28
-      println "  (source = " + compileTask.source.asPath + ")"
29
-    }
30
-  }
11
+subprojects {
31 12
 
13
+  // Add a task that copies test source files into a build directory. All @Ignore annotations
14
+  // are removed during this copying, so that when we run the copied tests, none are skipped and
15
+  // all should execute.
16
+  //
17
+  // Note that journey-test.sh also strips @Ignore annotations using sed. The
18
+  // stripping implementations here and in journey-test.sh should be kept
19
+  // consistent.
32 20
   task copyTestsFilteringIgnores(type: Copy) {
33 21
     from "src/test/java"
34
-    into "build/gen/test/java"
22
+    into generatedTestSourceDir
35 23
     filter { line ->
36
-      line.contains("@Ignore") ? "" : line
24
+      line.contains("@Ignore") ? null : line
25
+    }
26
+  }
27
+
28
+  afterEvaluate { project ->
29
+
30
+    sourceSets {
31
+      // Set the directory containing the example implementation as the default source set. Default
32
+      // compile tasks will now run against this source set.
33
+      main {
34
+        java.srcDirs = ["src/example/java"]
35
+      }
36
+
37
+      // Define a custom source set named "starterSource" that points to the starter implementations
38
+      // delivered to users. We can then use the generated "compileStarterSourceJava" task to verify
39
+      // that the starter source compiles as-is.
40
+      starterSource {
41
+        java.srcDirs = ["src/main/java"]
42
+      }
43
+
44
+      // Set the directory containing the @Ignore-stripped tests as the default test source set.
45
+      // Default test tasks will now run against this source set.
46
+      test {
47
+        java.srcDirs = [generatedTestSourceDir]
48
+      }
49
+
50
+      // Log the source paths associated with each source set to verify they are what we expect.
51
+      logCompileTaskSourcePath(project, "compileJava") // Corresponds to the "main" source set.
52
+      logCompileTaskSourcePath(project, "compileStarterSourceJava")
53
+      logCompileTaskSourcePath(project, "compileTestJava")
37 54
     }
55
+
56
+    // When running the standard test task, make sure we prepopulate the test source set with the
57
+    // @Ignore-stripped tests.
58
+    test.dependsOn(copyTestsFilteringIgnores)
38 59
   }
39 60
 
40
-  test.dependsOn(copyTestsFilteringIgnores)
61
+}
62
+
63
+def logCompileTaskSourcePath(Project project, String taskName) {
64
+  project[taskName].doFirst { compileTask ->
65
+    println "  (source = ${compileTask.source.asPath})"
66
+  }
41 67
 }

+ 1
- 0
exercises/change/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/change/src/main/java/ChangeCalculator.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class ChangeCalculator {
1
+class ChangeCalculator {
2 2
 
3 3
 
4 4
 

+ 1
- 1
exercises/change/src/test/java/ChangeCalculatorTest.java Просмотреть файл

@@ -8,7 +8,7 @@ import static java.util.Collections.emptyList;
8 8
 import static java.util.Collections.singletonList;
9 9
 import static org.junit.Assert.assertEquals;
10 10
 
11
-public final class ChangeCalculatorTest {
11
+public class ChangeCalculatorTest {
12 12
 
13 13
     /*
14 14
      * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and

+ 3
- 0
exercises/clock/HINT.md Просмотреть файл

@@ -0,0 +1,3 @@
1
+In order to satisfy the requirement that two clocks are considered equal just when they are set to the same time, you will need to override the [`equals`](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals(java.lang.Object)) and [`hashcode`](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode) methods in your `Clock` class.
2
+ 
3
+For more information on how to override these methods, see [this JavaWorld article](https://web.archive.org/web/20170528222153/http://www.javaworld.com/article/2072762/java-app-dev/object-equality.html).

+ 2
- 1
exercises/clock/build.gradle Просмотреть файл

@@ -9,9 +9,10 @@ repositories {
9 9
 dependencies {
10 10
     testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
     testLogging {
14 15
         exceptionFormat = 'full'
15 16
         events = ["passed", "failed", "skipped"]
16 17
     }
17
-}
18
+}

+ 3
- 0
exercises/clock/src/test/java/ClockAddTest.java Просмотреть файл

@@ -3,6 +3,9 @@ import org.junit.Test;
3 3
 
4 4
 import static org.junit.Assert.assertEquals;
5 5
 
6
+/*
7
+ * version: 1.0.1
8
+ */
6 9
 public class ClockAddTest {
7 10
 
8 11
     @Ignore("Remove to run test")

+ 3
- 0
exercises/clock/src/test/java/ClockCreationTest.java Просмотреть файл

@@ -3,6 +3,9 @@ import org.junit.Test;
3 3
 
4 4
 import static org.junit.Assert.assertEquals;
5 5
 
6
+/*
7
+ * version: 1.0.1
8
+ */
6 9
 public class ClockCreationTest {
7 10
 
8 11
     @Test

+ 21
- 17
exercises/clock/src/test/java/ClockEqualTest.java Просмотреть файл

@@ -1,98 +1,102 @@
1 1
 import org.junit.Ignore;
2 2
 import org.junit.Test;
3 3
 
4
-import static org.junit.Assert.assertFalse;
5
-import static org.junit.Assert.assertTrue;
4
+import static org.junit.Assert.assertNotEquals;
5
+import static org.junit.Assert.assertEquals;
6 6
 
7
+/*
8
+ * version: 1.0.1
9
+ */
7 10
 public class ClockEqualTest {
8 11
 
9 12
     @Ignore("Remove to run test")
10 13
     @Test
11 14
     public void clocksWithSameTimeAreEqual() {
12
-        assertTrue(new Clock(15, 37).equals(new Clock(15, 37)));
15
+        assertEquals(new Clock(15, 37), new Clock(15, 37));
13 16
     }
14 17
 
15 18
     @Ignore("Remove to run test")
16 19
     @Test
17 20
     public void clocksAMinuteApartAreNotEqual() {
18
-        assertFalse(new Clock(15, 36).equals(new Clock(15, 37)));
21
+        assertNotEquals(new Clock(15, 36), new Clock(15, 37));
19 22
     }
20 23
 
21 24
     @Ignore("Remove to run test")
22 25
     @Test
23 26
     public void clocksAnHourApartAreNotEqual() {
24
-        assertFalse(new Clock(14, 37).equals(new Clock(15, 37)));
27
+        assertNotEquals(new Clock(14, 37), new Clock(15, 37));
25 28
     }
26 29
 
27 30
     @Ignore("Remove to run test")
28 31
     @Test
29 32
     public void clocksWithHourOverflow() {
30
-        assertTrue(new Clock(10, 37).equals(new Clock(34, 37)));
33
+        assertEquals(new Clock(10, 37), new Clock(34, 37));
31 34
     }
32 35
 
33 36
     @Ignore("Remove to run test")
34 37
     @Test
35 38
     public void clocksWithHourOverflowBySeveralDays() {
36
-        assertTrue(new Clock(3, 11).equals(new Clock(99, 11)));
39
+        assertEquals(new Clock(3, 11), new Clock(99, 11));
37 40
     }
38 41
 
39 42
     @Ignore("Remove to run test")
40 43
     @Test
41 44
     public void clocksWithNegateHour() {
42
-        assertTrue(new Clock(22, 40).equals(new Clock(-2, 40)));
45
+        assertEquals(new Clock(22, 40), new Clock(-2, 40));
43 46
     }
44 47
 
45 48
     @Ignore("Remove to run test")
46 49
     @Test
47 50
     public void clocksWithNegativeHourThatWraps() {
48
-        assertTrue(new Clock(17, 3).equals(new Clock(-31, 3)));
51
+        assertEquals(new Clock(17, 3), new Clock(-31, 3));
49 52
     }
50 53
 
51 54
     @Ignore("Remove to run test")
52 55
     @Test
53 56
     public void clocksWithNegativeHourThatWrapsMultipleTimes() {
54
-        assertTrue(new Clock(13, 49).equals(new Clock(-83, 49)));
57
+        assertEquals(new Clock(13, 49), new Clock(-83, 49));
55 58
     }
56 59
 
57 60
     @Ignore("Remove to run test")
58 61
     @Test
59 62
     public void clocksWithMinuteOverflow() {
60
-        assertTrue(new Clock(0, 1).equals(new Clock(0, 1441)));
63
+        assertEquals(new Clock(0, 1), new Clock(0, 1441));
61 64
     }
62 65
 
63 66
     @Ignore("Remove to run test")
64 67
     @Test
65 68
     public void clocksWithMinuteOverflowBySeveralDays() {
66
-        assertTrue(new Clock(2, 2).equals(new Clock(2, 4322)));
69
+        assertEquals(new Clock(2, 2), new Clock(2, 4322));
67 70
     }
68 71
 
69 72
     @Ignore("Remove to run test")
70 73
     @Test
71 74
     public void clocksWithNegativeMinutes() {
72
-        assertTrue(new Clock(2, 40).equals(new Clock(3, -20)));
75
+        assertEquals(new Clock(2, 40), new Clock(3, -20));
73 76
     }
74 77
 
75 78
     @Ignore("Remove to run test")
76 79
     @Test
77 80
     public void clocksWithNegativeMinutesThatWraps() {
78
-        assertTrue(new Clock(4, 10).equals(new Clock(5, -1490)));
81
+        assertEquals(new Clock(4, 10), new Clock(5, -1490));
79 82
     }
80 83
 
81 84
     @Ignore("Remove to run test")
82 85
     @Test
83 86
     public void clocksWithNegativeMinutesThatWrapsMultipleTimes() {
84
-        assertTrue(new Clock(6, 15).equals(new Clock(6, -4305)));
87
+        assertEquals(new Clock(6, 15), new Clock(6, -4305));
85 88
     }
86 89
 
87 90
     @Ignore("Remove to run test")
88 91
     @Test
89 92
     public void clocksWithNegativeHoursAndMinutes() {
90
-        assertTrue(new Clock(7, 32).equals(new Clock(-12, -268)));
93
+        assertEquals(new Clock(7, 32), new Clock(-12, -268));
91 94
     }
92 95
 
93 96
     @Ignore("Remove to run test")
94 97
     @Test
95 98
     public void clocksWithNegativeHoursAndMinutesThatWrap() {
96
-        assertTrue(new Clock(18, 7).equals(new Clock(-54, -11513)));
99
+        assertEquals(new Clock(18, 7), new Clock(-54, -11513));
97 100
     }
101
+
98 102
 }

+ 18
- 0
exercises/collatz-conjecture/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
+}

+ 19
- 0
exercises/collatz-conjecture/src/example/java/CollatzCalculator.java Просмотреть файл

@@ -0,0 +1,19 @@
1
+class CollatzCalculator {
2
+
3
+    int computeStepCount(final int start) {
4
+        if (start <= 0) throw new IllegalArgumentException("Only natural numbers are allowed");
5
+
6
+        if (start == 1) return 0;
7
+
8
+        final int next;
9
+
10
+        if (start % 2 == 0) {
11
+            next = start / 2;
12
+        } else {
13
+            next = 3 * start + 1;
14
+        }
15
+
16
+        return 1 + computeStepCount(next);
17
+    }
18
+
19
+}

+ 7
- 0
exercises/collatz-conjecture/src/main/java/CollatzCalculator.java Просмотреть файл

@@ -0,0 +1,7 @@
1
+class CollatzCalculator {
2
+
3
+    int computeStepCount(int start) {
4
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+    }
6
+
7
+}

+ 65
- 0
exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java Просмотреть файл

@@ -0,0 +1,65 @@
1
+import org.junit.Before;
2
+import org.junit.Ignore;
3
+import org.junit.Rule;
4
+import org.junit.Test;
5
+import org.junit.rules.ExpectedException;
6
+
7
+import static org.junit.Assert.assertEquals;
8
+
9
+/*
10
+ * version: 1.1.0
11
+ */
12
+public class CollatzCalculatorTest {
13
+
14
+    @Rule
15
+    public ExpectedException expectedException = ExpectedException.none();
16
+
17
+    private CollatzCalculator collatzCalculator;
18
+
19
+    @Before
20
+    public void setUp() {
21
+        collatzCalculator = new CollatzCalculator();
22
+    }
23
+
24
+    @Test
25
+    public void testZeroStepsRequiredWhenStartingFrom1() {
26
+        assertEquals(0, collatzCalculator.computeStepCount(1));
27
+    }
28
+
29
+    @Ignore("Remove to run test")
30
+    @Test
31
+    public void testCorrectNumberOfStepsWhenAllStepsAreDivisions() {
32
+        assertEquals(4, collatzCalculator.computeStepCount(16));
33
+    }
34
+
35
+    @Ignore("Remove to run test")
36
+    @Test
37
+    public void testCorrectNumberOfStepsWhenBothStepTypesAreNeeded() {
38
+        assertEquals(9, collatzCalculator.computeStepCount(12));
39
+    }
40
+
41
+    @Ignore("Remove to run test")
42
+    @Test
43
+    public void testAVeryLargeInput() {
44
+        assertEquals(152, collatzCalculator.computeStepCount(1000000));
45
+    }
46
+
47
+    @Ignore("Remove to run test")
48
+    @Test
49
+    public void testZeroIsConsideredInvalidInput() {
50
+        expectedException.expect(IllegalArgumentException.class);
51
+        expectedException.expectMessage("Only natural numbers are allowed");
52
+
53
+        collatzCalculator.computeStepCount(0);
54
+    }
55
+
56
+    @Ignore("Remove to run test")
57
+    @Test
58
+    public void testNegativeIntegerIsConsideredInvalidInput() {
59
+        expectedException.expect(IllegalArgumentException.class);
60
+        expectedException.expectMessage("Only natural numbers are allowed");
61
+
62
+        collatzCalculator.computeStepCount(-15);
63
+    }
64
+
65
+}

+ 1
- 0
exercises/crypto-square/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/diamond/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 4
- 4
exercises/diamond/src/example/java/DiamondPrinter.java Просмотреть файл

@@ -17,7 +17,7 @@ final class DiamondPrinter {
17 17
     List<String> printToList(final char chr) {
18 18
         final int nRows = 2 * ((int) chr - A_INT) + 1;
19 19
 
20
-        final List<String> topRows = new ArrayList<>();
20
+        final List<String> result = new ArrayList<>();
21 21
 
22 22
         // Populate the top rows.
23 23
         for (int nRow = 0; nRow < (nRows + 1) / 2; nRow++) {
@@ -27,15 +27,15 @@ final class DiamondPrinter {
27 27
             final String rightHalfOfRow = reverse(leftHalfOfRow.substring(0, leftHalfOfRow.length() - 1));
28 28
             final String fullRow        = leftHalfOfRow + rightHalfOfRow;
29 29
 
30
-            topRows.add(fullRow);
30
+            result.add(fullRow);
31 31
         }
32 32
 
33 33
         // Populate the bottom rows by 'reflecting' the top rows.
34 34
         for (int nRow = (nRows - 1) / 2 - 1; nRow >= 0; nRow--) {
35
-            topRows.add(topRows.get(nRow));
35
+            result.add(result.get(nRow));
36 36
         }
37 37
 
38
-        return topRows;
38
+        return result;
39 39
     }
40 40
 
41 41
 }

+ 1
- 1
exercises/diamond/src/main/java/DiamondPrinter.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class DiamondPrinter {
1
+class DiamondPrinter {
2 2
 
3 3
 
4 4
 

+ 6
- 2
exercises/diamond/src/test/java/DiamondPrinterTest.java Просмотреть файл

@@ -9,14 +9,18 @@ import static java.util.Collections.singletonList;
9 9
 import static org.hamcrest.CoreMatchers.is;
10 10
 import static org.junit.Assert.assertThat;
11 11
 
12
+/*
13
+ * version: 1.0.0
14
+ */
12 15
 public class DiamondPrinterTest {
16
+
13 17
     private DiamondPrinter diamondPrinter;
14
-    
18
+
15 19
     @Before
16 20
     public void setUp() {
17 21
         diamondPrinter = new DiamondPrinter();
18 22
     }
19
-        
23
+
20 24
     @Test
21 25
     public void testOneByOneDiamond() {
22 26
         List<String> output = diamondPrinter.printToList('A');

+ 1
- 0
exercises/difference-of-squares/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 0
- 0
exercises/difference-of-squares/src/main/java/.keep Просмотреть файл


+ 0
- 15
exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java Просмотреть файл

@@ -1,15 +0,0 @@
1
-final class DifferenceOfSquaresCalculator {
2
-
3
-    int computeSquareOfSumTo(final int input) {
4
-        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
-    }
6
-
7
-    int computeSumOfSquaresTo(final int input) {
8
-        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9
-    }
10
-
11
-    int computeDifferenceOfSquares(final int input) {
12
-      throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
13
-    }
14
-
15
-}

+ 1
- 0
exercises/etl/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/flatten-array/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/flatten-array/src/main/java/Flattener.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class Flattener {
1
+class Flattener {
2 2
 
3 3
 
4 4
 

+ 1
- 0
exercises/gigasecond/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/grade-school/build.gradle Просмотреть файл

@@ -10,6 +10,7 @@ dependencies {
10 10
   testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
11 11
   testCompile "junit:junit:4.12"
12 12
 }
13
+
13 14
 test {
14 15
   testLogging {
15 16
     exceptionFormat = 'full'

+ 1
- 0
exercises/hamming/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 5
- 1
exercises/hello-world/GETTING_STARTED.md Просмотреть файл

@@ -5,7 +5,7 @@ This guide picks-up where [Running the Tests (in Java)](http://exercism.io/langu
5 5
 left off.  If you haven't reviewed those instructions, do so now.
6 6
 
7 7
 Need more information?  A **step-by-step tutorial** is available in this directory at TUTORIAL.md or you can read 
8
-the [HTML version](https://github.com/exercism/xjava/blob/master/exercises/hello-world/TUTORIAL.md).
8
+the [HTML version](https://github.com/exercism/java/blob/master/exercises/hello-world/TUTORIAL.md).
9 9
 
10 10
 The following instructions work equally well on Windows, Mac OS X and Linux.
11 11
 
@@ -18,6 +18,10 @@ Try writing a solution that passes one test at a time, running Gradle each time:
18 18
 $ gradle test
19 19
 ```
20 20
 
21
+To help you focus on one test at a time, [@Ignore](http://junit.sourceforge.net/javadoc/org/junit/Ignore.html)
22
+annotations have been added to every test but the first one. Any test with an `@Ignore` annotation will be skipped
23
+when you run the tests.
24
+
21 25
 ## Iterate through the tests
22 26
 
23 27
 After your first test passes, remove the `@Ignore` from the next test, and iterate on your solution,

+ 3
- 3
exercises/hello-world/TUTORIAL.md Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 NOTE: You can also view the HTML version of this file here:
2
-https://github.com/exercism/xjava/blob/master/exercises/hello-world/TUTORIAL.md
2
+https://github.com/exercism/java/blob/master/exercises/hello-world/TUTORIAL.md
3 3
 
4 4
 * [Solving "Hello, World!"](#solving-hello-world)
5 5
  * [Reading Gradle output](#reading-gradle-output)
@@ -93,7 +93,7 @@ FAILURE: Build failed with an exception.
93 93
 
94 94
 * What went wrong:
95 95
 Execution failed for task ':test'.
96
-> There were failing tests. See the report at: file:///Users/jtigger/projects/exercism/xjava/build/exercism/java/hello-world/build/reports/tests/index.html
96
+> There were failing tests. See the report at: file:///Users/jtigger/projects/exercism/java/build/exercism/java/hello-world/build/reports/tests/index.html
97 97
 
98 98
 * Try:
99 99
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
@@ -562,7 +562,7 @@ The entire of Exercism is Open Source and is the labor of love for over
562 562
 
563 563
 A starting point to jumping in can be found here:
564 564
 
565
-https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md
565
+https://github.com/exercism/problem-specifications/blob/master/CONTRIBUTING.md
566 566
 
567 567
 
568 568
 ----

+ 1
- 0
exercises/hexadecimal/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 10
- 0
exercises/isogram/HINT.md Просмотреть файл

@@ -0,0 +1,10 @@
1
+If you find that `testWorksWithGermanLetters` fails even though you think you've implemented it correctly,
2
+this could be because of the [JVM encoding](https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_61/rzaha/international.htm). 
3
+Try setting the `JAVA_TOOL_OPTIONS` environment variable to `-Dfile.encoding=UTF8` to fix this.
4
+- To set an environment variable on Windows:
5
+    1. Go to Computer -> Properties -> Advanced System Settings
6
+    2. Add a new environment variable
7
+
8
+- [To set an environment variable on a mac](http://blog.lidalia.org.uk/2011/04/setting-default-java-file-encoding-to.html)
9
+
10
+- [To set an environment variable on linux](https://unix.stackexchange.com/questions/151733/where-can-i-set-global-java-options)

+ 1
- 0
exercises/isogram/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/kindergarten-garden/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
     testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
     testLogging {
14 15
         exceptionFormat = 'full'

+ 4
- 4
exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java Просмотреть файл

@@ -126,7 +126,7 @@ public class KindergartenGardenTest {
126 126
 
127 127
     @Ignore("Remove to run test")
128 128
     @Test
129
-    public void customStudentGardenFirstStudent() {
129
+    public void customStudentGardenFirstStudentInAlphabeticalOrder() {
130 130
         String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"};
131 131
         String student = "Patricia";
132 132
         String plants = "VCRRGVRG\nRVGCCGCV";
@@ -140,7 +140,7 @@ public class KindergartenGardenTest {
140 140
 
141 141
     @Ignore("Remove to run test")
142 142
     @Test
143
-    public void customStudentGardenSecondStudent() {
143
+    public void customStudentGardenSecondStudentInAlphabeticalOrder() {
144 144
         String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"};
145 145
         String student = "Roger";
146 146
         String plants = "VCRRGVRG\nRVGCCGCV";
@@ -154,7 +154,7 @@ public class KindergartenGardenTest {
154 154
 
155 155
     @Ignore("Remove to run test")
156 156
     @Test
157
-    public void customStudentGardenThirdStudent() {
157
+    public void customStudentGardenThirdStudentInAlphabeticalOrder() {
158 158
         String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"};
159 159
         String student = "Samantha";
160 160
         String plants = "VCRRGVRG\nRVGCCGCV";
@@ -168,7 +168,7 @@ public class KindergartenGardenTest {
168 168
 
169 169
     @Ignore("Remove to run test")
170 170
     @Test
171
-    public void customStudentGardenFourthStudent() {
171
+    public void customStudentGardenFourthStudentInAlphabeticalOrder() {
172 172
         String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"};
173 173
         String student = "Xander";
174 174
         String plants = "VCRRGVRG\nRVGCCGCV";

+ 1
- 0
exercises/largest-series-product/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/linked-list/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/luhn/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/luhn/src/main/java/LuhnValidator.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class LuhnValidator {
1
+class LuhnValidator {
2 2
 
3 3
     boolean isValid(String candidate) {
4 4
         throw new UnsupportedOperationException("Delete this statement and write your own implementation.");

+ 2
- 1
exercises/matrix/build.gradle Просмотреть файл

@@ -9,9 +9,10 @@ repositories {
9 9
 dependencies {
10 10
     testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
     testLogging {
14 15
         exceptionFormat = 'full'
15 16
         events = ["passed", "failed", "skipped"]
16 17
     }
17
-}
18
+}

+ 1
- 0
exercises/meetup/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/minesweeper/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/minesweeper/src/main/java/MinesweeperBoard.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-public final class MinesweeperBoard {
1
+public class MinesweeperBoard {
2 2
 
3 3
 
4 4
 

+ 1
- 0
exercises/nth-prime/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/ocr-numbers/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 3
- 3
exercises/ocr-numbers/src/example/java/OpticalCharacterReader.java Просмотреть файл

@@ -8,7 +8,7 @@ import java.util.List;
8 8
  */
9 9
 final class OpticalCharacterReader {
10 10
 
11
-    private static final int ROWS_PER_LINE  = 4;
11
+    private static final int ROWS_PER_LINE = 4;
12 12
 
13 13
     private static final int COLS_PER_SSD = 3;
14 14
 
@@ -56,9 +56,9 @@ final class OpticalCharacterReader {
56 56
                     "Number of input rows must be a positive multiple of " + ROWS_PER_LINE);
57 57
         }
58 58
 
59
-        final int inputColumnCount = input.get(0).length();
59
+        final int inputColCount = input.get(0).length();
60 60
 
61
-        if (inputColumnCount == 0 || inputColumnCount % 3 != 0) {
61
+        if (inputColCount == 0 || inputColCount % 3 != 0) {
62 62
             throw new IllegalArgumentException(
63 63
                     "Number of input columns must be a positive multiple of " + COLS_PER_SSD);
64 64
         }

+ 1
- 1
exercises/ocr-numbers/src/main/java/OpticalCharacterReader.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class OpticalCharacterReader {
1
+class OpticalCharacterReader {
2 2
 
3 3
 
4 4
 

+ 1
- 0
exercises/octal/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/pangram/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/pascals-triangle/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/perfect-numbers/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/perfect-numbers/src/main/java/NaturalNumber.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class NaturalNumber {
1
+class NaturalNumber {
2 2
 
3 3
 
4 4
 

+ 0
- 1
exercises/perfect-numbers/src/test/java/NaturalNumberTest.java Просмотреть файл

@@ -7,7 +7,6 @@ import static org.junit.Assert.assertEquals;
7 7
 
8 8
 /*
9 9
  * version: 1.0.0
10
- * https://github.com/exercism/x-common/blob/19d0c7714ce664a1ad762af624c17f8e269fa8b2/exercises/perfect-numbers/canonical-data.json
11 10
  */
12 11
 public class NaturalNumberTest {
13 12
 

+ 1
- 0
exercises/phone-number/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/pig-latin/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 8
- 8
exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java Просмотреть файл

@@ -14,33 +14,33 @@ public class PythagoreanTripletTest {
14 14
 
15 15
     @Test
16 16
     public void shouldCalculateSum() {
17
-        PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
17
+        PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
18 18
         final int expected = 12;
19
-        final int actual = sut.calculateSum();
19
+        final int actual = triplet.calculateSum();
20 20
         assertEquals(expected, actual);
21 21
     }
22 22
 
23 23
     @Test
24 24
     @Ignore("Remove to run test")
25 25
     public void shouldCalculateProduct() {
26
-        PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
26
+        PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
27 27
         final long expected = 60l;
28
-        final long actual = sut.calculateProduct();
28
+        final long actual = triplet.calculateProduct();
29 29
         assertEquals(expected, actual);
30 30
     }
31 31
 
32 32
     @Test
33 33
     @Ignore("Remove to run test")
34 34
     public void testIsPythagoreanOK() {
35
-        PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
36
-        assertTrue(sut.isPythagorean());
35
+        PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
36
+        assertTrue(triplet.isPythagorean());
37 37
     }
38 38
 
39 39
     @Test
40 40
     @Ignore("Remove to run test")
41 41
     public void testIsPythagoreanFail() {
42
-        PythagoreanTriplet sut = new PythagoreanTriplet(5, 6, 7);
43
-        assertFalse(sut.isPythagorean());
42
+        PythagoreanTriplet triplet = new PythagoreanTriplet(5, 6, 7);
43
+        assertFalse(triplet.isPythagorean());
44 44
     }
45 45
 
46 46
     @Test

+ 1
- 0
exercises/queen-attack/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/queen-attack/src/main/java/BoardCoordinate.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-public final class BoardCoordinate {
1
+public class BoardCoordinate {
2 2
 
3 3
 
4 4
 

+ 1
- 1
exercises/queen-attack/src/main/java/QueenAttackCalculator.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-public final class QueenAttackCalculator {
1
+public class QueenAttackCalculator {
2 2
 
3 3
 
4 4
 

+ 1
- 0
exercises/raindrops/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 0
exercises/rectangles/build.gradle Просмотреть файл

@@ -9,6 +9,7 @@ repositories {
9 9
 dependencies {
10 10
   testCompile "junit:junit:4.12"
11 11
 }
12
+
12 13
 test {
13 14
   testLogging {
14 15
     exceptionFormat = 'full'

+ 1
- 1
exercises/rectangles/src/main/java/RectangleCounter.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-final class RectangleCounter {
1
+class RectangleCounter {
2 2
 
3 3
 
4 4
 

+ 0
- 0
exercises/rna-transcription/build.gradle Просмотреть файл


Некоторые файлы не были показаны из-за большого количества измененных файлов