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

Merge branch 'master' into two-fer

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

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

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
 *.iml
8
 *.iml
9
 bin/configlet
9
 bin/configlet
10
 bin/configlet.exe
10
 bin/configlet.exe
11
-gradle/
12
 /exercises/.nb-gradle/
11
 /exercises/.nb-gradle/

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

3
 jdk:
3
 jdk:
4
   - oraclejdk8
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
 # http://docs.travis-ci.com/user/migrating-from-legacy
6
 # http://docs.travis-ci.com/user/migrating-from-legacy
15
 sudo: false
7
 sudo: false
16
-cache: bundler
8
+
17
 addons:
9
 addons:
18
   apt:
10
   apt:
19
     packages:
11
     packages:
24
   - rvm use 2.2.5
16
   - rvm use 2.2.5
25
   - bin/build-jq.sh  # we want jq 1.5 features; not avail through pkg repo.
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
 before_script:
22
 before_script:
28
   - export PATH=$TRAVIS_BUILD_DIR/bin:$PATH  # ensure our tools are prefered over included ones.
23
   - export PATH=$TRAVIS_BUILD_DIR/bin:$PATH  # ensure our tools are prefered over included ones.
29
 
24
 
30
 script:
25
 script:
31
   - bin/unit-tests.sh
26
   - bin/unit-tests.sh
32
   - bin/journey-test.sh
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

+ 8
- 0
CONTRIBUTING.md Просмотреть файл

1
+Hi! Thanks for contributing to the Exercism Java track!
2
+
3
+Before opening your pull request, please review the track policies linked below and make sure your changes comply with them all. This helps us focus our review time on the more important aspects of your changes.
4
+
5
+- [Prefer instance methods](https://github.com/exercism/java/blob/master/POLICIES.md#prefer-instance-methods)
6
+- [Starter implementations](https://github.com/exercism/java/blob/master/POLICIES.md#starter-implementations)
7
+- [Ignore noninitial tests](https://github.com/exercism/java/blob/master/POLICIES.md#ignore-noninitial-tests)
8
+- [Multiple file submissions](https://github.com/exercism/java/blob/master/POLICIES.md#multiple-file-submissions)

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

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
 Permission is hereby granted, free of charge, to any person obtaining a copy
5
 Permission is hereby granted, free of charge, to any person obtaining a copy
6
 of this software and associated documentation files (the "Software"), to deal
6
 of this software and associated documentation files (the "Software"), to deal

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

30
 
30
 
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.
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
 ### Starter implementations
35
 ### Starter implementations
36
 
36
 
40
     `throw new UnsupportedOperationException("Delete this statement and provide your own implementation.");`
40
     `throw new UnsupportedOperationException("Delete this statement and provide your own implementation.");`
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).
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
 ### Ignore noninitial tests
49
 ### Ignore noninitial tests
46
 
50
 
47
 > 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).
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
 ### Multiple file submissions
55
 ### Multiple file submissions
52
 
56
 
53
 > 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.
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
 ### Good first patches
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
 ### Simple onboarding
67
 ### Simple onboarding
64
 
68
 
65
 > 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.
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
-# 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
 Source for Exercism Exercises in Java.
3
 Source for Exercism Exercises in Java.
4
 
4
 
5
 ## Contributing Guide
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
 ## Table of Contents
9
 ## Table of Contents
10
 
10
 
32
 1. **Ensure you have the basic Java tooling installed:**  JDK 1.8+, an editor and Gradle 2.x.
32
 1. **Ensure you have the basic Java tooling installed:**  JDK 1.8+, an editor and Gradle 2.x.
33
 
33
 
34
    (see [exercism.io: Installing Java](http://exercism.io/languages/java/installing))
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
    * "fork" a repository on GitHub;
38
    * "fork" a repository on GitHub;
39
    - install `git`;
39
    - install `git`;
40
    - "clone" a copy of your fork;
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
    - create a branch to house your work
42
    - create a branch to house your work
43
 -  **Write the codes.**  Do your work on that branch you just created.
43
 -  **Write the codes.**  Do your work on that branch you just created.
44
 
44
 
52
    $ git push
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
 -  **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.
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
 ## Getting Familiar With the Codebase
58
 ## Getting Familiar With the Codebase
59
 
59
 
60
 There are two objectives to the design of this build:
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
 This repo is a multi-project gradle build.
65
 This repo is a multi-project gradle build.
66
 
66
 
68
 
68
 
69
 This is the top-level module, contained in the `exercises` directory.  It is a container for the problem sub-modules.
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
 ### The Problem Submodules
74
 ### The Problem Submodules
75
 
75
 
76
 The `exercises` subdirectory contains all of the problem submodules.
76
 The `exercises` subdirectory contains all of the problem submodules.
77
 Each problem/submodule is a subdirectory of the same name as its slug.
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
 Each problem/submodule has three source sets:
81
 Each problem/submodule has three source sets:
82
 
82
 
109
 2015-09-06 15:21:01 - JSON::GeneratorError - source sequence is illegal/malformed utf-8:
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
 gradle clean
116
 gradle clean
117
 cd ~/workspace/exercism/exercises
117
 cd ~/workspace/exercism/exercises
118
 exercism fetch java bob
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

+ 18
- 0
_template/build.gradle Просмотреть файл

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
+}

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
-#!/bin/bash
1
+#!/usr/bin/env bash
2
 
2
 
3
 LATEST=https://github.com/exercism/configlet/releases/latest
3
 LATEST=https://github.com/exercism/configlet/releases/latest
4
 
4
 

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

1
 #!/usr/bin/env bash
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
 on_exit() {
9
 on_exit() {
4
   echo ">>> on_exit()"
10
   echo ">>> on_exit()"
5
   if [[ "$xapi_pid" != "" ]] ; then
11
   if [[ "$xapi_pid" != "" ]] ; then
16
 
22
 
17
   if [[ "`which $binary`" == "" ]]; then
23
   if [[ "`which $binary`" == "" ]]; then
18
     echo "${binary} not found; it is required to perform this test."
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
     echo "PATH=${PATH}"
26
     echo "PATH=${PATH}"
21
     echo "aborting."
27
     echo "aborting."
22
     exit 1
28
     exit 1
35
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
41
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
36
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
42
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
37
     echo -e "Ruby used: `which ruby`.\n"
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
     echo "PATH=${PATH}"
45
     echo "PATH=${PATH}"
40
     echo "aborting."
46
     echo "aborting."
41
     exit 1
47
     exit 1
59
     rm -rf "${build_path}"
65
     rm -rf "${build_path}"
60
   fi
66
   fi
61
   cd exercises
67
   cd exercises
62
-  gradle clean
68
+  "$EXECPATH"/gradlew clean
63
   cd ..
69
   cd ..
64
   echo "<<< clean()"
70
   echo "<<< clean()"
65
 }
71
 }
141
   local xapi_home="$2"
147
   local xapi_home="$2"
142
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
148
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
143
 
149
 
144
-  local xjava=$( pwd )
150
+  local track_root=$( pwd )
145
   pushd ${trackler}
151
   pushd ${trackler}
146
 
152
 
147
   # Get the version of Trackler x-api is currently using
153
   # Get the version of Trackler x-api is currently using
151
   git submodule init -- common
157
   git submodule init -- common
152
   git submodule update
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
   gem install bundler
166
   gem install bundler
161
   bundle install
167
   bundle install
208
   local exercism_configfile="$2"
214
   local exercism_configfile="$2"
209
   echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
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
   local exercism_cli="./exercism --config ${exercism_configfile}"
218
   local exercism_cli="./exercism --config ${exercism_configfile}"
213
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
219
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
214
   local total_exercises=`cat config.json | jq '.exercises | length'`
220
   local total_exercises=`cat config.json | jq '.exercises | length'`
222
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
228
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
223
     echo "=================================================="
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
     # Check that tests compile before we strip @Ignore annotations
235
     # Check that tests compile before we strip @Ignore annotations
230
-    gradle compileTestJava
236
+    "$EXECPATH"/gradlew compileTestJava
231
     # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
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
     done
243
     done
235
-    gradle test
244
+    "$EXECPATH"/gradlew test
236
     popd
245
     popd
237
 
246
 
238
     current_exercise_number=$((current_exercise_number + 1))
247
     current_exercise_number=$((current_exercise_number + 1))
244
   # all functions assume current working directory is repository root.
253
   # all functions assume current working directory is repository root.
245
   cd "${SCRIPTPATH}/.."
254
   cd "${SCRIPTPATH}/.."
246
 
255
 
247
-  local xjava=$( pwd )
256
+  local track_root=$( pwd )
248
   local build_dir="build"
257
   local build_dir="build"
249
-  local build_path="${xjava}/${build_dir}"
258
+  local build_path="${track_root}/${build_dir}"
250
 
259
 
251
   local xapi_home="${build_path}/x-api"
260
   local xapi_home="${build_path}/x-api"
252
   local trackler_home="${build_path}/trackler"
261
   local trackler_home="${build_path}/trackler"
256
   local xapi_port=9292
265
   local xapi_port=9292
257
 
266
 
258
   # fail fast if required binaries are not installed.
267
   # fail fast if required binaries are not installed.
259
-  assert_installed "gradle"
260
   assert_installed "jq"
268
   assert_installed "jq"
261
 
269
 
262
   clean "${build_dir}"
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
   git_clone "x-api" "${xapi_home}"
273
   git_clone "x-api" "${xapi_home}"
266
   git_clone "trackler" "${trackler_home}"
274
   git_clone "trackler" "${trackler_home}"
267
   assert_ruby_installed "${trackler_home}"
275
   assert_ruby_installed "${trackler_home}"

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

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

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

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

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


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

4
 
4
 
5
 - [Your Permissions](#your-permissions)
5
 - [Your Permissions](#your-permissions)
6
 - [Maintainer Guides](#maintainer-guides)
6
 - [Maintainer Guides](#maintainer-guides)
7
-- [The Project Board](#the-project-board)
8
 - [Miscellaneous](#miscellaneous)
7
 - [Miscellaneous](#miscellaneous)
9
 
8
 
10
 ## Your Permissions 
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
 ### Track-specific
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
 ### Exercism-wide
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
 - [discussions](https://github.com/exercism/discussions) — the place where project-wide conversations happen. 
20
 - [discussions](https://github.com/exercism/discussions) — the place where project-wide conversations happen. 
22
   [issues sorted by most recently updated.](https://github.com/exercism/discussions/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
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
 ## Maintainer Guides
24
 ## Maintainer Guides
26
 
25
 
28
 - [exercism.io/docs/getting-involved-in-a-track.md](https://github.com/exercism/exercism.io/blob/master/docs/getting-involved-in-a-track.md)
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
 - [exercism.io/docs/reviewing-a-pull-request.md](https://github.com/exercism/exercism.io/blob/master/docs/reviewing-a-pull-request.md)
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
 ## Miscellaneous
30
 ## Miscellaneous
48
 
31
 
49
 - Issues marked with "policy" are current "team agreements": [exercism?label:policy](https://github.com/search?q=org%3Aexercism+label%3Apolicy).
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
    C:\Users\JohnDoe>gradle test
37
    C:\Users\JohnDoe>gradle test
38
    ```
38
    ```
39
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
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
 Good luck!  Have fun!
43
 Good luck!  Have fun!
70
   $ gradle test
70
   $ gradle test
71
   ```
71
   ```
72
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
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
 Good luck!  Have fun!
75
 Good luck!  Have fun!
76
 
76
 
102
   $ gradle test
102
   $ gradle test
103
   ```
103
   ```
104
    *(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
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
 Good luck!  Have fun!
107
 Good luck!  Have fun!
108
 
108
 

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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
 
7
 
8
 import static org.junit.Assert.assertArrayEquals;
8
 import static org.junit.Assert.assertArrayEquals;
9
 
9
 
10
+/*
11
+ * version: 1.1.0
12
+ */
10
 public class BaseConverterTest {
13
 public class BaseConverterTest {
11
 
14
 
12
     /*
15
     /*
197
 
200
 
198
     @Ignore("Remove to run test")
201
     @Ignore("Remove to run test")
199
     @Test
202
     @Test
200
-    public void testNegativeDigit() {
203
+    public void testFirstBaseIsOne() {
201
         expectedException.expect(IllegalArgumentException.class);
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
     @Ignore("Remove to run test")
210
     @Ignore("Remove to run test")
208
     @Test
211
     @Test
209
-    public void testInvalidPositiveDigit() {
212
+    public void testFirstBaseIsZero() {
210
         expectedException.expect(IllegalArgumentException.class);
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
     @Ignore("Remove to run test")
219
     @Ignore("Remove to run test")
217
     @Test
220
     @Test
218
-    public void testFirstBaseIsOne() {
221
+    public void testFirstBaseIsNegative() {
219
         expectedException.expect(IllegalArgumentException.class);
222
         expectedException.expect(IllegalArgumentException.class);
220
         expectedException.expectMessage("Bases must be at least 2.");
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
     @Ignore("Remove to run test")
228
     @Ignore("Remove to run test")
226
     @Test
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
         expectedException.expect(IllegalArgumentException.class);
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
     @Ignore("Remove to run test")
237
     @Ignore("Remove to run test")
237
     @Test
238
     @Test
238
-    public void testFirstBaseIsZero() {
239
+    public void testInvalidPositiveDigit() {
239
         expectedException.expect(IllegalArgumentException.class);
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
     @Ignore("Remove to run test")
246
     @Ignore("Remove to run test")
246
     @Test
247
     @Test
247
-    public void testSecondBaseIsZero() {
248
+    public void testSecondBaseIsOne() {
248
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
249
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
249
 
250
 
250
         expectedException.expect(IllegalArgumentException.class);
251
         expectedException.expect(IllegalArgumentException.class);
251
         expectedException.expectMessage("Bases must be at least 2.");
252
         expectedException.expectMessage("Bases must be at least 2.");
252
 
253
 
253
-        baseConverter.convertToBase(0);
254
+        baseConverter.convertToBase(1);
254
     }
255
     }
255
 
256
 
256
     @Ignore("Remove to run test")
257
     @Ignore("Remove to run test")
257
     @Test
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
         expectedException.expect(IllegalArgumentException.class);
262
         expectedException.expect(IllegalArgumentException.class);
260
         expectedException.expectMessage("Bases must be at least 2.");
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
     @Ignore("Remove to run test")
268
     @Ignore("Remove to run test")

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

11
 
11
 
12
     @Test
12
     @Test
13
     public void dataIsRetained() {
13
     public void dataIsRetained() {
14
-        BST<Integer> sut = new BST();
14
+        BST<Integer> bst = new BST();
15
         final int actual = 4;
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
         assertNotNull(root);
18
         assertNotNull(root);
19
         final int expected = root.getData();
19
         final int expected = root.getData();
20
         assertEquals(expected, actual);
20
         assertEquals(expected, actual);
23
     @Test
23
     @Test
24
     @Ignore("Remove to run test")
24
     @Ignore("Remove to run test")
25
     public void insertsLess() {
25
     public void insertsLess() {
26
-        BST<Integer> sut = new BST();
26
+        BST<Integer> bst = new BST();
27
         final int expectedRoot = 4;
27
         final int expectedRoot = 4;
28
         final int expectedLeft = 2;
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
         assertNotNull(root);
34
         assertNotNull(root);
35
         final BST.Node<Integer> left = root.getLeft();
35
         final BST.Node<Integer> left = root.getLeft();
36
         assertNotNull(left);
36
         assertNotNull(left);
44
     @Test
44
     @Test
45
     @Ignore("Remove to run test")
45
     @Ignore("Remove to run test")
46
     public void insertsSame() {
46
     public void insertsSame() {
47
-        BST<Integer> sut = new BST();
47
+        BST<Integer> bst = new BST();
48
         final int expectedRoot = 4;
48
         final int expectedRoot = 4;
49
         final int expectedLeft = 4;
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
         assertNotNull(root);
55
         assertNotNull(root);
56
         final BST.Node<Integer> left = root.getLeft();
56
         final BST.Node<Integer> left = root.getLeft();
57
         assertNotNull(left);
57
         assertNotNull(left);
65
     @Test
65
     @Test
66
     @Ignore("Remove to run test")
66
     @Ignore("Remove to run test")
67
     public void insertsRight() {
67
     public void insertsRight() {
68
-        BST<Integer> sut = new BST();
68
+        BST<Integer> bst = new BST();
69
         final int expectedRoot = 4;
69
         final int expectedRoot = 4;
70
         final int expectedRight = 5;
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
         assertNotNull(root);
76
         assertNotNull(root);
77
         final BST.Node<Integer> right = root.getRight();
77
         final BST.Node<Integer> right = root.getRight();
78
         assertNotNull(right);
78
         assertNotNull(right);
86
     @Test
86
     @Test
87
     @Ignore("Remove to run test")
87
     @Ignore("Remove to run test")
88
     public void createsComplexTree() {
88
     public void createsComplexTree() {
89
-        BST<Integer> sut = new BST<>();
89
+        BST<Integer> bst = new BST<>();
90
         List<Integer> expected = Collections.unmodifiableList(
90
         List<Integer> expected = Collections.unmodifiableList(
91
                 Arrays.asList(4, 2, 6, 1, 3, 5, 7)
91
                 Arrays.asList(4, 2, 6, 1, 3, 5, 7)
92
         );
92
         );
94
         List<Integer> treeData = Collections.unmodifiableList(
94
         List<Integer> treeData = Collections.unmodifiableList(
95
                 Arrays.asList(4, 2, 6, 1, 3, 7, 5)
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
         assertEquals(expected, actual);
100
         assertEquals(expected, actual);
101
     }
101
     }
102
 
102
 
103
     @Test
103
     @Test
104
     @Ignore("Remove to run test")
104
     @Ignore("Remove to run test")
105
     public void sortsSingleElement() {
105
     public void sortsSingleElement() {
106
-        BST<Integer> sut = new BST<>();
106
+        BST<Integer> bst = new BST<>();
107
         List<Integer> expected = Collections.unmodifiableList(
107
         List<Integer> expected = Collections.unmodifiableList(
108
                 Collections.singletonList(4)
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
         assertEquals(expected, actual);
114
         assertEquals(expected, actual);
115
     }
115
     }
116
 
116
 
117
     @Test
117
     @Test
118
     @Ignore("Remove to run test")
118
     @Ignore("Remove to run test")
119
     public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
119
     public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
120
-        BST<Integer> sut = new BST<>();
120
+        BST<Integer> bst = new BST<>();
121
         List<Integer> expected = Collections.unmodifiableList(
121
         List<Integer> expected = Collections.unmodifiableList(
122
                 Arrays.asList(2, 4)
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
         assertEquals(expected, actual);
129
         assertEquals(expected, actual);
130
     }
130
     }
131
 
131
 
132
     @Test
132
     @Test
133
     @Ignore("Remove to run test")
133
     @Ignore("Remove to run test")
134
     public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
134
     public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
135
-        BST<Integer> sut = new BST<>();
135
+        BST<Integer> bst = new BST<>();
136
         List<Integer> expected = Collections.unmodifiableList(
136
         List<Integer> expected = Collections.unmodifiableList(
137
                 Arrays.asList(4, 5)
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
         assertEquals(expected, actual);
144
         assertEquals(expected, actual);
145
     }
145
     }
146
 
146
 
147
     @Test
147
     @Test
148
     @Ignore("Remove to run test")
148
     @Ignore("Remove to run test")
149
     public void iteratesOverComplexTree() {
149
     public void iteratesOverComplexTree() {
150
-        BST<Integer> sut = new BST<>();
150
+        BST<Integer> bst = new BST<>();
151
         List<Integer> expected = Collections.unmodifiableList(
151
         List<Integer> expected = Collections.unmodifiableList(
152
                 Arrays.asList(1, 2, 3, 4, 5, 6, 7)
152
                 Arrays.asList(1, 2, 3, 4, 5, 6, 7)
153
         );
153
         );
155
         List<Integer> treeData = Collections.unmodifiableList(
155
         List<Integer> treeData = Collections.unmodifiableList(
156
                 Arrays.asList(4, 2, 1, 3, 6, 7, 5)
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
         assertEquals(expected, actual);
161
         assertEquals(expected, actual);
162
     }
162
     }
163
 }
163
 }

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

1
 
1
 
2
+import org.junit.Ignore;
3
+import org.junit.Test;
4
+
2
 import java.util.ArrayList;
5
 import java.util.ArrayList;
3
 import java.util.Arrays;
6
 import java.util.Arrays;
4
 import java.util.Collections;
7
 import java.util.Collections;
5
 import java.util.List;
8
 import java.util.List;
9
+
6
 import static org.junit.Assert.assertEquals;
10
 import static org.junit.Assert.assertEquals;
7
-import org.junit.Ignore;
8
-import org.junit.Test;
9
 
11
 
10
 public class BinarySearchTest {
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
     @Test
14
     @Test
38
     public void findsAValueInAnArrayWithOneElement() {
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
     @Ignore("Remove to run test")
23
     @Ignore("Remove to run test")
47
     @Test
24
     @Test
48
     public void findsAValueInTheMiddleOfAnArray() {
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
     @Ignore("Remove to run test")
35
     @Ignore("Remove to run test")
57
     @Test
36
     @Test
58
     public void findsAValueAtTheBeginningOfAnArray() {
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
     @Ignore("Remove to run test")
47
     @Ignore("Remove to run test")
67
     @Test
48
     @Test
68
     public void findsAValueAtTheEndOfAnArray() {
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
     @Ignore("Remove to run test")
59
     @Ignore("Remove to run test")
77
     @Test
60
     @Test
78
     public void findsAValueInAnArrayOfOddLength() {
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
     @Ignore("Remove to run test")
71
     @Ignore("Remove to run test")
87
     @Test
72
     @Test
88
     public void findsAValueInAnArrayOfEvenLength() {
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
     @Ignore("Remove to run test")
83
     @Ignore("Remove to run test")
98
     @Test
84
     @Test
99
     public void identifiesThatAValueIsNotIncludedInTheArray() {
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
     @Ignore("Remove to run test")
95
     @Ignore("Remove to run test")
108
     @Test
96
     @Test
109
     public void aValueSmallerThanTheArraysSmallestValueIsNotIncluded() {
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
     @Ignore("Remove to run test")
107
     @Ignore("Remove to run test")
118
     @Test
108
     @Test
119
     public void aValueLargerThanTheArraysSmallestValueIsNotIncluded() {
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
     @Ignore("Remove to run test")
119
     @Ignore("Remove to run test")
128
     @Test
120
     @Test
129
     public void nothingIsIncludedInAnEmptyArray() {
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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

2
 import java.util.List;
2
 import java.util.List;
3
 import java.util.stream.Collectors;
3
 import java.util.stream.Collectors;
4
 
4
 
5
-class Bookstore {
5
+class BookStore {
6
 
6
 
7
   private static final int BOOK_PRICE = 8, MAX_GROUP_SIZE = 5;
7
   private static final int BOOK_PRICE = 8, MAX_GROUP_SIZE = 5;
8
 
8
 
9
   private static double[] DISCOUNT_TIERS = {0, 5, 10, 20, 25};
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
     if (books.size() == 0) {
16
     if (books.size() == 0) {
23
       return priceSoFar;
17
       return priceSoFar;
24
     }
18
     }
38
         remainingBooks.remove(newGroupBook);
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
       minPrice = Math.min(minPrice, price);
36
       minPrice = Math.min(minPrice, price);
44
     }
37
     }
45
 
38
 

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

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
-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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

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
   task copyTestsFilteringIgnores(type: Copy) {
20
   task copyTestsFilteringIgnores(type: Copy) {
33
     from "src/test/java"
21
     from "src/test/java"
34
-    into "build/gen/test/java"
22
+    into generatedTestSourceDir
35
     filter { line ->
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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

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

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

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
 dependencies {
9
 dependencies {
10
     testCompile "junit:junit:4.12"
10
     testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
     testLogging {
14
     testLogging {
14
         exceptionFormat = 'full'
15
         exceptionFormat = 'full'
15
         events = ["passed", "failed", "skipped"]
16
         events = ["passed", "failed", "skipped"]
16
     }
17
     }
17
-}
18
+}

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

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

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

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

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

1
 import org.junit.Ignore;
1
 import org.junit.Ignore;
2
 import org.junit.Test;
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
 public class ClockEqualTest {
10
 public class ClockEqualTest {
8
 
11
 
9
     @Ignore("Remove to run test")
12
     @Ignore("Remove to run test")
10
     @Test
13
     @Test
11
     public void clocksWithSameTimeAreEqual() {
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
     @Ignore("Remove to run test")
18
     @Ignore("Remove to run test")
16
     @Test
19
     @Test
17
     public void clocksAMinuteApartAreNotEqual() {
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
     @Ignore("Remove to run test")
24
     @Ignore("Remove to run test")
22
     @Test
25
     @Test
23
     public void clocksAnHourApartAreNotEqual() {
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
     @Ignore("Remove to run test")
30
     @Ignore("Remove to run test")
28
     @Test
31
     @Test
29
     public void clocksWithHourOverflow() {
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
     @Ignore("Remove to run test")
36
     @Ignore("Remove to run test")
34
     @Test
37
     @Test
35
     public void clocksWithHourOverflowBySeveralDays() {
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
     @Ignore("Remove to run test")
42
     @Ignore("Remove to run test")
40
     @Test
43
     @Test
41
     public void clocksWithNegateHour() {
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
     @Ignore("Remove to run test")
48
     @Ignore("Remove to run test")
46
     @Test
49
     @Test
47
     public void clocksWithNegativeHourThatWraps() {
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
     @Ignore("Remove to run test")
54
     @Ignore("Remove to run test")
52
     @Test
55
     @Test
53
     public void clocksWithNegativeHourThatWrapsMultipleTimes() {
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
     @Ignore("Remove to run test")
60
     @Ignore("Remove to run test")
58
     @Test
61
     @Test
59
     public void clocksWithMinuteOverflow() {
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
     @Ignore("Remove to run test")
66
     @Ignore("Remove to run test")
64
     @Test
67
     @Test
65
     public void clocksWithMinuteOverflowBySeveralDays() {
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
     @Ignore("Remove to run test")
72
     @Ignore("Remove to run test")
70
     @Test
73
     @Test
71
     public void clocksWithNegativeMinutes() {
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
     @Ignore("Remove to run test")
78
     @Ignore("Remove to run test")
76
     @Test
79
     @Test
77
     public void clocksWithNegativeMinutesThatWraps() {
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
     @Ignore("Remove to run test")
84
     @Ignore("Remove to run test")
82
     @Test
85
     @Test
83
     public void clocksWithNegativeMinutesThatWrapsMultipleTimes() {
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
     @Ignore("Remove to run test")
90
     @Ignore("Remove to run test")
88
     @Test
91
     @Test
89
     public void clocksWithNegativeHoursAndMinutes() {
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
     @Ignore("Remove to run test")
96
     @Ignore("Remove to run test")
94
     @Test
97
     @Test
95
     public void clocksWithNegativeHoursAndMinutesThatWrap() {
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 Просмотреть файл

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 Просмотреть файл

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 Просмотреть файл

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 Просмотреть файл

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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

17
     List<String> printToList(final char chr) {
17
     List<String> printToList(final char chr) {
18
         final int nRows = 2 * ((int) chr - A_INT) + 1;
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
         // Populate the top rows.
22
         // Populate the top rows.
23
         for (int nRow = 0; nRow < (nRows + 1) / 2; nRow++) {
23
         for (int nRow = 0; nRow < (nRows + 1) / 2; nRow++) {
27
             final String rightHalfOfRow = reverse(leftHalfOfRow.substring(0, leftHalfOfRow.length() - 1));
27
             final String rightHalfOfRow = reverse(leftHalfOfRow.substring(0, leftHalfOfRow.length() - 1));
28
             final String fullRow        = leftHalfOfRow + rightHalfOfRow;
28
             final String fullRow        = leftHalfOfRow + rightHalfOfRow;
29
 
29
 
30
-            topRows.add(fullRow);
30
+            result.add(fullRow);
31
         }
31
         }
32
 
32
 
33
         // Populate the bottom rows by 'reflecting' the top rows.
33
         // Populate the bottom rows by 'reflecting' the top rows.
34
         for (int nRow = (nRows - 1) / 2 - 1; nRow >= 0; nRow--) {
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
-final class DiamondPrinter {
1
+class DiamondPrinter {
2
 
2
 
3
 
3
 
4
 
4
 

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
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
-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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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


+ 77
- 0
exercises/food-chain/src/example/java/FoodChain.java Просмотреть файл

1
+import java.util.stream.IntStream;
2
+
3
+public class FoodChain {
4
+
5
+    private static final String[] ANIMALS = {
6
+        "fly",
7
+        "spider",
8
+        "bird",
9
+        "cat",
10
+        "dog",
11
+        "goat",
12
+        "cow"
13
+    };
14
+
15
+    private static final String[] FOLLOWUPS = {
16
+        "It wriggled and jiggled and tickled inside her.",
17
+        "How absurd to swallow a bird!",
18
+        "Imagine that, to swallow a cat!",
19
+        "What a hog, to swallow a dog!",
20
+        "Just opened her throat and swallowed a goat!",
21
+        "I don't know how she swallowed a cow!"
22
+    };
23
+
24
+    public String verse(int verse) {
25
+        return verseBeginning(verse) + verseMiddle(verse) + verseEnding(verse);
26
+    }
27
+
28
+    public String verses(int startVerse, int endVerse) {
29
+
30
+        String[] verses = new String[endVerse - startVerse + 1];
31
+
32
+        for (int i = 0; i <= endVerse - startVerse; i++) {
33
+            verses[i] = verse(i + 1);
34
+        }
35
+
36
+        return String.join("\n\n", verses);
37
+    }
38
+
39
+    private String verseBeginning(int verse) {
40
+
41
+        if (verse == 1) {
42
+            return "I know an old lady who swallowed a fly.\n";
43
+        }
44
+
45
+        if (verse == 8) {
46
+            return "I know an old lady who swallowed a horse.\n";
47
+        }
48
+
49
+        return "I know an old lady who swallowed a " + ANIMALS[verse - 1] + ".\n" + FOLLOWUPS[verse - 2] + "\n";
50
+    }
51
+
52
+    private String verseMiddle(int verse) {
53
+
54
+        if (verse == 1 || verse == 8) {
55
+            return "";
56
+        }
57
+
58
+        String[] lines = new String[verse - 1];
59
+
60
+        for (int i = verse - 1; i >= 1; i--) {
61
+            lines[lines.length - i] = "She swallowed the " +
62
+                    ANIMALS[i] + " to catch the " + ANIMALS[i - 1] +
63
+                    (i == 2 ? " that wriggled and jiggled and tickled inside her." : ".");
64
+        }
65
+
66
+        return String.join("\n", lines) + "\n";
67
+    }
68
+
69
+    private String verseEnding(int verse) {
70
+
71
+        if (verse == 8) {
72
+            return "She's dead, of course!";
73
+        }
74
+
75
+        return "I don't know why she swallowed the fly. Perhaps she'll die.";
76
+    }
77
+}

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


+ 204
- 0
exercises/food-chain/src/test/java/FoodChainTest.java Просмотреть файл

1
+import org.junit.Before;
2
+import org.junit.Test;
3
+import org.junit.Ignore;
4
+
5
+import static org.junit.Assert.assertEquals;
6
+
7
+public class FoodChainTest {
8
+    private FoodChain foodChain;
9
+
10
+    @Before
11
+    public void setup() {
12
+        foodChain = new FoodChain();
13
+    }
14
+
15
+    @Test
16
+    public void fly() {
17
+        int verse = 1;
18
+        String expected = "I know an old lady who swallowed a fly.\n" +
19
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
20
+
21
+        assertEquals(expected, foodChain.verse(verse));
22
+    }
23
+
24
+    @Test
25
+    @Ignore("Remove to run test.")
26
+    public void spider() {
27
+        int verse = 2;
28
+        String expected = "I know an old lady who swallowed a spider.\n" +
29
+                          "It wriggled and jiggled and tickled inside her.\n" +
30
+                          "She swallowed the spider to catch the fly.\n" +
31
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
32
+
33
+        assertEquals(expected, foodChain.verse(verse));
34
+    }
35
+
36
+    @Test
37
+    @Ignore("Remove to run test.")
38
+    public void bird() {
39
+        int verse = 3;
40
+        String expected = "I know an old lady who swallowed a bird.\n" +
41
+                          "How absurd to swallow a bird!\n" +
42
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
43
+                          "She swallowed the spider to catch the fly.\n" +
44
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
45
+
46
+        assertEquals(expected, foodChain.verse(verse));
47
+    }
48
+
49
+    @Test
50
+    @Ignore("Remove to run test.")
51
+    public void cat() {
52
+        int verse = 4;
53
+        String expected = "I know an old lady who swallowed a cat.\n" +
54
+                          "Imagine that, to swallow a cat!\n" +
55
+                          "She swallowed the cat to catch the bird.\n" +
56
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
57
+                          "She swallowed the spider to catch the fly.\n" +
58
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
59
+
60
+        assertEquals(expected, foodChain.verse(verse));
61
+    }
62
+
63
+
64
+    @Test
65
+    @Ignore("Remove to run test.")
66
+    public void dog() {
67
+        int verse = 5;
68
+        String expected = "I know an old lady who swallowed a dog.\n" +
69
+                          "What a hog, to swallow a dog!\n" +
70
+                          "She swallowed the dog to catch the cat.\n" +
71
+                          "She swallowed the cat to catch the bird.\n" +
72
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
73
+                          "She swallowed the spider to catch the fly.\n" +
74
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
75
+
76
+        assertEquals(expected, foodChain.verse(verse));
77
+    }
78
+
79
+    @Test
80
+    @Ignore("Remove to run test.")
81
+    public void goat() {
82
+        int verse = 6;
83
+        String expected = "I know an old lady who swallowed a goat.\n" +
84
+                          "Just opened her throat and swallowed a goat!\n" +
85
+                          "She swallowed the goat to catch the dog.\n" +
86
+                          "She swallowed the dog to catch the cat.\n" +
87
+                          "She swallowed the cat to catch the bird.\n" +
88
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
89
+                          "She swallowed the spider to catch the fly.\n" +
90
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
91
+
92
+        assertEquals(expected, foodChain.verse(verse));
93
+    }
94
+
95
+    @Test
96
+    @Ignore("Remove to run test.")
97
+    public void cow() {
98
+        int verse = 7;
99
+        String expected = "I know an old lady who swallowed a cow.\n" +
100
+                          "I don't know how she swallowed a cow!\n" +
101
+                          "She swallowed the cow to catch the goat.\n" +
102
+                          "She swallowed the goat to catch the dog.\n" +
103
+                          "She swallowed the dog to catch the cat.\n" +
104
+                          "She swallowed the cat to catch the bird.\n" +
105
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
106
+                          "She swallowed the spider to catch the fly.\n" +
107
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
108
+
109
+        assertEquals(expected, foodChain.verse(verse));
110
+    }
111
+
112
+    @Test
113
+    @Ignore("Remove to run test.")
114
+    public void horse() {
115
+        int verse = 8;
116
+        String expected = "I know an old lady who swallowed a horse.\n" +
117
+                          "She's dead, of course!";
118
+
119
+        assertEquals(expected, foodChain.verse(verse));
120
+    }
121
+
122
+
123
+    @Test
124
+    @Ignore("Remove to run test.")
125
+    public void multipleVerses() {
126
+        int startVerse = 1;
127
+        int endVerse = 3;
128
+        String expected = "I know an old lady who swallowed a fly.\n" +
129
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
130
+                          "\n" +
131
+                          "I know an old lady who swallowed a spider.\n" +
132
+                          "It wriggled and jiggled and tickled inside her.\n" +
133
+                          "She swallowed the spider to catch the fly.\n" +
134
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
135
+                          "\n" +
136
+                          "I know an old lady who swallowed a bird.\n" +
137
+                          "How absurd to swallow a bird!\n" +
138
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
139
+                          "She swallowed the spider to catch the fly.\n" +
140
+                          "I don't know why she swallowed the fly. Perhaps she'll die.";
141
+
142
+        assertEquals(expected, foodChain.verses(startVerse, endVerse));
143
+    }
144
+
145
+
146
+    @Test
147
+    @Ignore("Remove to run test.")
148
+    public void wholeSong() {
149
+        int startVerse = 1;
150
+        int endVerse = 8;
151
+        String expected = "I know an old lady who swallowed a fly.\n" +
152
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
153
+                          "\n" +
154
+                          "I know an old lady who swallowed a spider.\n" +
155
+                          "It wriggled and jiggled and tickled inside her.\n" +
156
+                          "She swallowed the spider to catch the fly.\n" +
157
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
158
+                          "\n" +
159
+                          "I know an old lady who swallowed a bird.\n" +
160
+                          "How absurd to swallow a bird!\n" +
161
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
162
+                          "She swallowed the spider to catch the fly.\n" +
163
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
164
+                          "\n" +
165
+                          "I know an old lady who swallowed a cat.\n" +
166
+                          "Imagine that, to swallow a cat!\n" +
167
+                          "She swallowed the cat to catch the bird.\n" +
168
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
169
+                          "She swallowed the spider to catch the fly.\n" +
170
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
171
+                          "\n" +
172
+                          "I know an old lady who swallowed a dog.\n" +
173
+                          "What a hog, to swallow a dog!\n" +
174
+                          "She swallowed the dog to catch the cat.\n" +
175
+                          "She swallowed the cat to catch the bird.\n" +
176
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
177
+                          "She swallowed the spider to catch the fly.\n" +
178
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
179
+                          "\n" +
180
+                          "I know an old lady who swallowed a goat.\n" +
181
+                          "Just opened her throat and swallowed a goat!\n" +
182
+                          "She swallowed the goat to catch the dog.\n" +
183
+                          "She swallowed the dog to catch the cat.\n" +
184
+                          "She swallowed the cat to catch the bird.\n" +
185
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
186
+                          "She swallowed the spider to catch the fly.\n" +
187
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
188
+                          "\n" +
189
+                          "I know an old lady who swallowed a cow.\n" +
190
+                          "I don't know how she swallowed a cow!\n" +
191
+                          "She swallowed the cow to catch the goat.\n" +
192
+                          "She swallowed the goat to catch the dog.\n" +
193
+                          "She swallowed the dog to catch the cat.\n" +
194
+                          "She swallowed the cat to catch the bird.\n" +
195
+                          "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
196
+                          "She swallowed the spider to catch the fly.\n" +
197
+                          "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
198
+                          "\n" +
199
+                          "I know an old lady who swallowed a horse.\n" +
200
+                          "She's dead, of course!";
201
+
202
+        assertEquals(expected, foodChain.verses(startVerse, endVerse));
203
+    }
204
+}

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

5
 left off.  If you haven't reviewed those instructions, do so now.
5
 left off.  If you haven't reviewed those instructions, do so now.
6
 
6
 
7
 Need more information?  A **step-by-step tutorial** is available in this directory at TUTORIAL.md or you can read 
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
 The following instructions work equally well on Windows, Mac OS X and Linux.
10
 The following instructions work equally well on Windows, Mac OS X and Linux.
11
 
11
 
18
 $ gradle test
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
 ## Iterate through the tests
25
 ## Iterate through the tests
22
 
26
 
23
 After your first test passes, iterate on your solution, testing after each change.
27
 After your first test passes, iterate on your solution, testing after each change.

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

1
 NOTE: You can also view the HTML version of this file here:
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
 * [Solving "Hello, World!"](#solving-hello-world)
4
 * [Solving "Hello, World!"](#solving-hello-world)
5
  * [Reading Gradle output](#reading-gradle-output)
5
  * [Reading Gradle output](#reading-gradle-output)
527
 
527
 
528
 A starting point to jumping in can be found here:
528
 A starting point to jumping in can be found here:
529
 
529
 
530
-https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md
530
+https://github.com/exercism/problem-specifications/blob/master/CONTRIBUTING.md
531
 
531
 
532
 
532
 
533
 ----
533
 ----

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
     testCompile "junit:junit:4.12"
10
     testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
     testLogging {
14
     testLogging {
14
         exceptionFormat = 'full'
15
         exceptionFormat = 'full'

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

8
  */
8
  */
9
 final class OpticalCharacterReader {
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
     private static final int COLS_PER_SSD = 3;
13
     private static final int COLS_PER_SSD = 3;
14
 
14
 
56
                     "Number of input rows must be a positive multiple of " + ROWS_PER_LINE);
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
             throw new IllegalArgumentException(
62
             throw new IllegalArgumentException(
63
                     "Number of input columns must be a positive multiple of " + COLS_PER_SSD);
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
-final class OpticalCharacterReader {
1
+class OpticalCharacterReader {
2
 
2
 
3
 
3
 
4
 
4
 

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

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
 
8
 /*
8
 /*
9
  * version: 1.0.0
9
  * version: 1.0.0
10
- * https://github.com/exercism/x-common/blob/19d0c7714ce664a1ad762af624c17f8e269fa8b2/exercises/perfect-numbers/canonical-data.json
11
  */
10
  */
12
 public class NaturalNumberTest {
11
 public class NaturalNumberTest {
13
 
12
 

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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

14
 
14
 
15
     @Test
15
     @Test
16
     public void shouldCalculateSum() {
16
     public void shouldCalculateSum() {
17
-        PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
17
+        PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
18
         final int expected = 12;
18
         final int expected = 12;
19
-        final int actual = sut.calculateSum();
19
+        final int actual = triplet.calculateSum();
20
         assertEquals(expected, actual);
20
         assertEquals(expected, actual);
21
     }
21
     }
22
 
22
 
23
     @Test
23
     @Test
24
     @Ignore("Remove to run test")
24
     @Ignore("Remove to run test")
25
     public void shouldCalculateProduct() {
25
     public void shouldCalculateProduct() {
26
-        PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
26
+        PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
27
         final long expected = 60l;
27
         final long expected = 60l;
28
-        final long actual = sut.calculateProduct();
28
+        final long actual = triplet.calculateProduct();
29
         assertEquals(expected, actual);
29
         assertEquals(expected, actual);
30
     }
30
     }
31
 
31
 
32
     @Test
32
     @Test
33
     @Ignore("Remove to run test")
33
     @Ignore("Remove to run test")
34
     public void testIsPythagoreanOK() {
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
     @Test
39
     @Test
40
     @Ignore("Remove to run test")
40
     @Ignore("Remove to run test")
41
     public void testIsPythagoreanFail() {
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
     @Test
46
     @Test

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

9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
 }
11
 }
12
+
12
 test {
13
 test {
13
   testLogging {
14
   testLogging {
14
     exceptionFormat = 'full'
15
     exceptionFormat = 'full'

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


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