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

Merge branch 'master' into poker

Mehdi El Houti 9 лет назад
Родитель
Сommit
eba02913db
100 измененных файлов: 1486 добавлений и 813 удалений
  1. 0
    0
      .Rhistory
  2. 10
    0
      .gitattributes
  3. 10
    0
      .github/PULL_REQUEST_TEMPLATE.md
  4. 0
    1
      .gitignore
  5. 23
    9
      .travis.yml
  6. 2
    2
      LICENSE
  7. 71
    0
      POLICIES.md
  8. 13
    20
      README.md
  9. 1
    0
      _template/build.gradle
  10. 0
    0
      _template/src/example/java/.keep
  11. 0
    0
      _template/src/main/java/.keep
  12. 0
    0
      _template/src/test/java/.keep
  13. 1
    1
      bin/fetch-configlet
  14. 35
    24
      bin/journey-test.sh
  15. 3
    3
      bin/unit-tests.sh
  16. 249
    96
      config.json
  17. 0
    0
      docs/EXERCISE_README_INSERT.md
  18. 2
    2
      docs/INSTALLATION.md
  19. 4
    21
      docs/MAINTAINING.md
  20. 3
    3
      docs/TESTS.md
  21. 0
    0
      exercises/_template/src/example/java/.keep
  22. 0
    0
      exercises/_template/src/main/java/.keep
  23. 0
    0
      exercises/_template/src/test/java/.keep
  24. 1
    0
      exercises/accumulate/build.gradle
  25. 4
    4
      exercises/accumulate/src/test/java/AccumulateTest.java
  26. 1
    0
      exercises/acronym/build.gradle
  27. 15
    3
      exercises/acronym/src/example/java/Acronym.java
  28. 11
    0
      exercises/acronym/src/main/java/Acronym.java
  29. 14
    28
      exercises/acronym/src/test/java/AcronymTest.java
  30. 1
    0
      exercises/all-your-base/build.gradle
  31. 1
    1
      exercises/all-your-base/src/main/java/BaseConverter.java
  32. 43
    40
      exercises/all-your-base/src/test/java/BaseConverterTest.java
  33. 1
    0
      exercises/allergies/build.gradle
  34. 18
    18
      exercises/allergies/src/test/java/AllergiesTest.java
  35. 1
    0
      exercises/anagram/build.gradle
  36. 15
    15
      exercises/anagram/src/test/java/AnagramTest.java
  37. 1
    0
      exercises/atbash-cipher/build.gradle
  38. 5
    5
      exercises/atbash-cipher/src/example/java/Atbash.java
  39. 19
    19
      exercises/atbash-cipher/src/test/java/AtbashTest.java
  40. 1
    0
      exercises/beer-song/build.gradle
  41. 4
    7
      exercises/beer-song/src/example/java/BeerSong.java
  42. 21
    13
      exercises/beer-song/src/test/java/BeerSongTest.java
  43. 41
    41
      exercises/binary-search-tree/src/test/java/BSTTest.java
  44. 1
    0
      exercises/binary-search/build.gradle
  45. 79
    87
      exercises/binary-search/src/test/java/BinarySearchTest.java
  46. 1
    0
      exercises/binary/build.gradle
  47. 1
    0
      exercises/bob/build.gradle
  48. 17
    17
      exercises/bob/src/test/java/BobTest.java
  49. 18
    0
      exercises/book-store/build.gradle
  50. 0
    0
      exercises/book-store/src/example/java/.keep
  51. 50
    0
      exercises/book-store/src/example/java/BookStore.java
  52. 0
    0
      exercises/book-store/src/main/java/.keep
  53. 0
    0
      exercises/book-store/src/test/java/.keep
  54. 113
    0
      exercises/book-store/src/test/java/BookStoreTest.java
  55. 1
    0
      exercises/bracket-push/build.gradle
  56. 1
    1
      exercises/bracket-push/src/main/java/BracketChecker.java
  57. 13
    13
      exercises/bracket-push/src/test/java/BracketCheckerTest.java
  58. 57
    31
      exercises/build.gradle
  59. 1
    0
      exercises/change/build.gradle
  60. 1
    1
      exercises/change/src/main/java/ChangeCalculator.java
  61. 9
    9
      exercises/change/src/test/java/ChangeCalculatorTest.java
  62. 3
    0
      exercises/clock/HINT.md
  63. 2
    1
      exercises/clock/build.gradle
  64. 19
    16
      exercises/clock/src/test/java/ClockAddTest.java
  65. 21
    18
      exercises/clock/src/test/java/ClockCreationTest.java
  66. 36
    32
      exercises/clock/src/test/java/ClockEqualTest.java
  67. 18
    0
      exercises/collatz-conjecture/build.gradle
  68. 19
    0
      exercises/collatz-conjecture/src/example/java/CollatzCalculator.java
  69. 7
    0
      exercises/collatz-conjecture/src/main/java/CollatzCalculator.java
  70. 65
    0
      exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java
  71. 1
    0
      exercises/crypto-square/build.gradle
  72. 14
    14
      exercises/crypto-square/src/test/java/CryptoSquareTest.java
  73. 36
    36
      exercises/custom-set/src/test/java/CustomSetTest.java
  74. 1
    0
      exercises/diamond/build.gradle
  75. 4
    4
      exercises/diamond/src/example/java/DiamondPrinter.java
  76. 1
    1
      exercises/diamond/src/main/java/DiamondPrinter.java
  77. 21
    10
      exercises/diamond/src/test/java/DiamondPrinterTest.java
  78. 1
    0
      exercises/difference-of-squares/build.gradle
  79. 4
    4
      exercises/difference-of-squares/src/example/java/DifferenceOfSquaresCalculator.java
  80. 0
    0
      exercises/difference-of-squares/src/main/java/.keep
  81. 0
    5
      exercises/difference-of-squares/src/main/java/Difference.java
  82. 90
    0
      exercises/difference-of-squares/src/test/java/DifferenceOfSquaresCalculatorTest.java
  83. 0
    87
      exercises/difference-of-squares/src/test/java/DifferenceTest.java
  84. 1
    0
      exercises/etl/build.gradle
  85. 3
    3
      exercises/etl/src/test/java/EtlTest.java
  86. 1
    0
      exercises/flatten-array/build.gradle
  87. 1
    1
      exercises/flatten-array/src/main/java/Flattener.java
  88. 20
    5
      exercises/flatten-array/src/test/java/FlattenerTest.java
  89. 1
    0
      exercises/gigasecond/build.gradle
  90. 7
    6
      exercises/gigasecond/src/example/java/Gigasecond.java
  91. 18
    0
      exercises/gigasecond/src/main/java/Gigasecond.java
  92. 4
    5
      exercises/gigasecond/src/test/java/GigasecondTest.java
  93. 1
    0
      exercises/grade-school/build.gradle
  94. 15
    9
      exercises/grade-school/src/test/java/SchoolTest.java
  95. 1
    0
      exercises/hamming/build.gradle
  96. 11
    2
      exercises/hamming/src/example/java/Hamming.java
  97. 9
    0
      exercises/hamming/src/main/java/Hamming.java
  98. 17
    18
      exercises/hamming/src/test/java/HammingTest.java
  99. 5
    1
      exercises/hello-world/GETTING_STARTED.md
  100. 0
    0
      exercises/hello-world/HINT.md

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


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

1
+# Autodetect text files
2
+* text=auto
3
+
4
+# Force the following filetypes to have unix eols, so Windows does not break them
5
+*.* text eol=lf
6
+
7
+# Force images/fonts to be handled as binaries
8
+*.jpg binary
9
+*.jpeg binary
10
+*.png binary

+ 10
- 0
.github/PULL_REQUEST_TEMPLATE.md Просмотреть файл

1
+<!-- Your content goes here: -->
2
+
3
+
4
+
5
+<!-- DO NOT EDIT BELOW THIS LINE! -->
6
+---
7
+
8
+Reviewer Resources:
9
+
10
+[Track Policies](https://github.com/exercism/xjava/blob/master/POLICIES.md#event-checklist)

+ 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

+ 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

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

1
+# Track Policies
2
+
3
+This document:
4
+
5
+- describes all current track-wide policies; and
6
+- lists all policies that should be reviewed in response to any given track event.
7
+
8
+Maintainers should refer to this document each time they review a pull request.
9
+
10
+Our policies are not set-in-stone. They represent directions chosen at a point in time with the information/context available at that time. We actively encourage contributors to review and critique them. If you have read through the references that informed an existing policy and still feel it should be improved or removed, please comment and describe:
11
+
12
+1. your alternative perspective;
13
+2. your proposed changes; and
14
+3. how your proposal balances your own perspective with those already raised during prior discussions.
15
+
16
+## Event Checklist
17
+
18
+| Track Event | Policies to review |
19
+|:------------|:-----------------|
20
+| Exercise added | [Prefer instance methods](#prefer-instance-methods); [Starter implementations](#starter-implementations); [Ignore noninitial tests](#ignore-noninitial-tests) |
21
+| Exercise updated | [Ignore noninitial tests](#ignore-noninitial-tests); [Multiple file submissions](#multiple-file-submissions) |
22
+| Track order changed | [Starter implementations](#starter-implementations); [Multiple file submissions](#multiple-file-submissions) |
23
+| New issue observed in track | [Good first patches](#good-first-patches) |
24
+| "Good first patch" issue completed | [Good first patches](#good-first-patches) |
25
+| Installing Java instructions updated | [Simple onboarding](#simple-onboarding) |
26
+
27
+## Policy Descriptions
28
+
29
+### Prefer instance methods
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.
32
+
33
+References: [[1](https://github.com/exercism/java/issues/177#issuecomment-261291741)]
34
+
35
+### Starter implementations
36
+
37
+> - Exercises 1-10: provide stubs for all required constructors and methods. Stubs should include the following body:
38
+    `throw new UnsupportedOperationException("Delete this statement and write your own implementation.");`
39
+> - Exercises 11-20: provide stubs for all constructors and methods required by the first test; comment-out the bodies of any tests that require non-stubbed constructors or methods. Stubs should include the following body:
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).
42
+
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.
48
+
49
+### Ignore noninitial tests
50
+
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).
52
+
53
+References: [[1](https://github.com/exercism/java/issues/101#issuecomment-249349204)]
54
+
55
+### Multiple file submissions
56
+
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.
58
+
59
+References: [[1](https://github.com/exercism/java/issues/365#issuecomment-292533120)]
60
+
61
+### Good first patches
62
+
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).
64
+
65
+References: [[1](https://github.com/exercism/java/issues/220#issue-196447088)]
66
+
67
+### Simple onboarding
68
+
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.
70
+
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

exercises/_template/build.gradle → _template/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/scrabble-score/src/main/java/.keep → _template/src/example/java/.keep Просмотреть файл


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


exercises/luhn/src/main/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
 

+ 35
- 24
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}
152
+
153
+  # Get the version of Trackler x-api is currently using
154
+  local version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
155
+
156
+  git checkout v${version}
146
   git submodule init -- common
157
   git submodule init -- common
147
   git submodule update
158
   git submodule update
148
 
159
 
149
-  # Bake in local copy of xjava; this is what we are testing.
150
-  rmdir tracks/java
151
-  mkdir -p tracks/java/exercises
152
-  cp ${xjava}/config.json tracks/java
153
-  cp -r ${xjava}/exercises tracks/java
154
-
155
-  # Set the version to that expected by x-api
156
-  version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
157
-  echo "module Trackler VERSION = \"${version}\" end" > lib/trackler/version.rb
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}
158
 
165
 
159
   gem install bundler
166
   gem install bundler
160
   bundle install
167
   bundle install
207
   local exercism_configfile="$2"
214
   local exercism_configfile="$2"
208
   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}\")"
209
 
216
 
210
-  local xjava=$( pwd )
217
+  local track_root=$( pwd )
211
   local exercism_cli="./exercism --config ${exercism_configfile}"
218
   local exercism_cli="./exercism --config ${exercism_configfile}"
212
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
219
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
213
   local total_exercises=`cat config.json | jq '.exercises | length'`
220
   local total_exercises=`cat config.json | jq '.exercises | length'`
221
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
228
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
222
     echo "=================================================="
229
     echo "=================================================="
223
 
230
 
224
-    ${exercism_cli} fetch java $exercise
225
-    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}/
226
 
233
 
227
-    pushd ${exercism_exercises_dir}/java/${exercise}
234
+    pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
235
+    # Check that tests compile before we strip @Ignore annotations
236
+    "$EXECPATH"/gradlew compileTestJava
228
     # 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)
229
-    for testfile in `find . -name "*Test.java"`; do
230
-      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}"
231
     done
243
     done
232
-    gradle test
244
+    "$EXECPATH"/gradlew test
233
     popd
245
     popd
234
 
246
 
235
     current_exercise_number=$((current_exercise_number + 1))
247
     current_exercise_number=$((current_exercise_number + 1))
241
   # all functions assume current working directory is repository root.
253
   # all functions assume current working directory is repository root.
242
   cd "${SCRIPTPATH}/.."
254
   cd "${SCRIPTPATH}/.."
243
 
255
 
244
-  local xjava=$( pwd )
256
+  local track_root=$( pwd )
245
   local build_dir="build"
257
   local build_dir="build"
246
-  local build_path="${xjava}/${build_dir}"
258
+  local build_path="${track_root}/${build_dir}"
247
 
259
 
248
   local xapi_home="${build_path}/x-api"
260
   local xapi_home="${build_path}/x-api"
249
   local trackler_home="${build_path}/trackler"
261
   local trackler_home="${build_path}/trackler"
253
   local xapi_port=9292
265
   local xapi_port=9292
254
 
266
 
255
   # fail fast if required binaries are not installed.
267
   # fail fast if required binaries are not installed.
256
-  assert_installed "gradle"
257
   assert_installed "jq"
268
   assert_installed "jq"
258
 
269
 
259
   clean "${build_dir}"
270
   clean "${build_dir}"
260
 
271
 
261
-  # 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.
262
   git_clone "x-api" "${xapi_home}"
273
   git_clone "x-api" "${xapi_home}"
263
   git_clone "trackler" "${trackler_home}"
274
   git_clone "trackler" "${trackler_home}"
264
   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
 

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

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


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

12
 * [Linux](#linux)
12
 * [Linux](#linux)
13
 
13
 
14
 ... or ...
14
 ... or ...
15
-* if you prefer to not use a package maanger, you can [install manually](#install-manually).
15
+* if you prefer to not use a package manager, you can [install manually](#install-manually).
16
 
16
 
17
 Optionally, you can also use a [Java IDE](#java-ides).
17
 Optionally, you can also use a [Java IDE](#java-ides).
18
 
18
 
42
    ...
42
    ...
43
    ```
43
    ```
44
 
44
 
45
-We recommend closing the administrative command prompt and opening a new command prompt -- you do not require administrator priviledges to practice Exercism exercises.
45
+We recommend closing the administrative command prompt and opening a new command prompt -- you do not require administrator privileges to practice Exercism exercises.
46
 
46
 
47
 You now are ready to get started with the Java track of Exercism!
47
 You now are ready to get started with the Java track of Exercism!
48
 
48
 

+ 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
 

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


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


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


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

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

17
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
17
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
18
     }
18
     }
19
 
19
 
20
-    @Ignore
20
+    @Ignore("Remove to run test")
21
     @Test
21
     @Test
22
     public void accumulateSquares() {
22
     public void accumulateSquares() {
23
         List<Integer> input = Arrays.asList(1, 2, 3);
23
         List<Integer> input = Arrays.asList(1, 2, 3);
25
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
25
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
26
     }
26
     }
27
 
27
 
28
-    @Ignore
28
+    @Ignore("Remove to run test")
29
     @Test
29
     @Test
30
     public void accumulateUpperCases() {
30
     public void accumulateUpperCases() {
31
         List<String> input = Arrays.asList("hello", "world");
31
         List<String> input = Arrays.asList("hello", "world");
33
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x.toUpperCase()));
33
         assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x.toUpperCase()));
34
     }
34
     }
35
 
35
 
36
-    @Ignore
36
+    @Ignore("Remove to run test")
37
     @Test
37
     @Test
38
     public void accumulateReversedStrings() {
38
     public void accumulateReversedStrings() {
39
         List<String> input = Arrays.asList("the quick brown fox etc".split(" "));
39
         List<String> input = Arrays.asList("the quick brown fox etc".split(" "));
45
         return new StringBuilder(input).reverse().toString();
45
         return new StringBuilder(input).reverse().toString();
46
     }
46
     }
47
 
47
 
48
-    @Ignore
48
+    @Ignore("Remove to run test")
49
     @Test
49
     @Test
50
     public void accumulateWithinAccumulate() {
50
     public void accumulateWithinAccumulate() {
51
         List<String> input1 = Arrays.asList("a", "b", "c");
51
         List<String> input1 = Arrays.asList("a", "b", "c");

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

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

1
 import java.util.regex.Matcher;
1
 import java.util.regex.Matcher;
2
 import java.util.regex.Pattern;
2
 import java.util.regex.Pattern;
3
 
3
 
4
-public class Acronym {
5
-    public static String generate(String phrase){
4
+final class Acronym {
5
+
6
+    private final String acronym;
7
+
8
+    Acronym(String phrase) {
9
+        acronym = generateAcronym(phrase);
10
+    }
11
+
12
+    String get() {
13
+        return acronym;
14
+    }
15
+
16
+    private String generateAcronym(String phrase){
6
         final Pattern BREAK_WORDS = Pattern.compile("[A-Z]+[a-z]*|[a-z]+");
17
         final Pattern BREAK_WORDS = Pattern.compile("[A-Z]+[a-z]*|[a-z]+");
7
         final Matcher matcher = BREAK_WORDS.matcher(phrase);
18
         final Matcher matcher = BREAK_WORDS.matcher(phrase);
8
         final StringBuilder b = new StringBuilder();
19
         final StringBuilder b = new StringBuilder();
11
         }
22
         }
12
         return b.toString().toUpperCase();
23
         return b.toString().toUpperCase();
13
     }
24
     }
14
-}
25
+
26
+}

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

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

+ 14
- 28
exercises/acronym/src/test/java/AcronymTest.java Просмотреть файл

3
 
3
 
4
 import static org.junit.Assert.assertEquals;
4
 import static org.junit.Assert.assertEquals;
5
 
5
 
6
+/*
7
+ * version: 1.1.0
8
+ */
6
 public class AcronymTest {
9
 public class AcronymTest {
7
 
10
 
8
-
9
     @Test
11
     @Test
10
     public void fromTitleCasedPhrases() {
12
     public void fromTitleCasedPhrases() {
11
         final String phrase = "Portable Network Graphics";
13
         final String phrase = "Portable Network Graphics";
12
         final String expected = "PNG";
14
         final String expected = "PNG";
13
-        assertEquals(expected, Acronym.generate(phrase));
15
+        assertEquals(expected, new Acronym(phrase).get());
14
     }
16
     }
15
 
17
 
16
-    @Ignore
18
+    @Ignore("Remove to run test")
17
     @Test
19
     @Test
18
     public void fromOtherTitleCasedPhrases() {
20
     public void fromOtherTitleCasedPhrases() {
19
         final String phrase = "Ruby on Rails";
21
         final String phrase = "Ruby on Rails";
20
         final String expected = "ROR";
22
         final String expected = "ROR";
21
-        assertEquals(expected, Acronym.generate(phrase));
22
-    }
23
-
24
-    @Ignore
25
-    @Test
26
-    public void fromInconsistentlyCasedPhrases() {
27
-        final String phrase = "HyperText Markup Language";
28
-        final String expected = "HTML";
29
-        assertEquals(expected, Acronym.generate(phrase));
23
+        assertEquals(expected, new Acronym(phrase).get());
30
     }
24
     }
31
 
25
 
32
-    @Ignore
26
+    @Ignore("Remove to run test")
33
     @Test
27
     @Test
34
     public void fromPhrasesWithPunctuation() {
28
     public void fromPhrasesWithPunctuation() {
35
         final String phrase = "First In, First Out";
29
         final String phrase = "First In, First Out";
36
         final String expected = "FIFO";
30
         final String expected = "FIFO";
37
-        assertEquals(expected, Acronym.generate(phrase));
31
+        assertEquals(expected, new Acronym(phrase).get());
38
     }
32
     }
39
 
33
 
40
-    @Ignore
34
+    @Ignore("Remove to run test")
41
     @Test
35
     @Test
42
     public void fromOtherPhrasesWithPunctuation() {
36
     public void fromOtherPhrasesWithPunctuation() {
43
         final String phrase = "PHP: Hypertext Preprocessor";
37
         final String phrase = "PHP: Hypertext Preprocessor";
44
         final String expected = "PHP";
38
         final String expected = "PHP";
45
-        assertEquals(expected, Acronym.generate(phrase));
39
+        assertEquals(expected, new Acronym(phrase).get());
46
     }
40
     }
47
 
41
 
48
-    @Ignore
42
+    @Ignore("Remove to run test")
49
     @Test
43
     @Test
50
     public void fromPhrasesWithNonAcronymAllCapsWord() {
44
     public void fromPhrasesWithNonAcronymAllCapsWord() {
51
         final String phrase = "GNU Image Manipulation Program";
45
         final String phrase = "GNU Image Manipulation Program";
52
         final String expected = "GIMP";
46
         final String expected = "GIMP";
53
-        assertEquals(expected, Acronym.generate(phrase));
47
+        assertEquals(expected, new Acronym(phrase).get());
54
     }
48
     }
55
 
49
 
56
-    @Ignore
50
+    @Ignore("Remove to run test")
57
     @Test
51
     @Test
58
     public void fromPhrasesWithPunctuationAndSentenceCasing() {
52
     public void fromPhrasesWithPunctuationAndSentenceCasing() {
59
         final String phrase = "Complementary metal-oxide semiconductor";
53
         final String phrase = "Complementary metal-oxide semiconductor";
60
         final String expected = "CMOS";
54
         final String expected = "CMOS";
61
-        assertEquals(expected, Acronym.generate(phrase));
62
-    }
63
-
64
-    @Ignore
65
-    @Test
66
-    public void fromPhraseWithSingleLetterWord() {
67
-        final String phrase = "Cat in a Hat";
68
-        final String expected = "CIAH";
69
-        assertEquals(expected, Acronym.generate(phrase));
55
+        assertEquals(expected, new Acronym(phrase).get());
70
     }
56
     }
71
 
57
 
72
 }
58
 }

+ 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
 

+ 43
- 40
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
-public final class BaseConverterTest {
10
+/*
11
+ * version: 1.1.0
12
+ */
13
+public class BaseConverterTest {
11
 
14
 
12
     /*
15
     /*
13
      * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
16
      * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
32
                 actualDigits);
35
                 actualDigits);
33
     }
36
     }
34
 
37
 
35
-    @Ignore
38
+    @Ignore("Remove to run test")
36
     @Test
39
     @Test
37
     public void testBinaryToSingleDecimal() {
40
     public void testBinaryToSingleDecimal() {
38
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1});
41
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1});
49
                 actualDigits);
52
                 actualDigits);
50
     }
53
     }
51
 
54
 
52
-    @Ignore
55
+    @Ignore("Remove to run test")
53
     @Test
56
     @Test
54
     public void testSingleDecimalToBinary() {
57
     public void testSingleDecimalToBinary() {
55
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{5});
58
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{5});
66
                 actualDigits);
69
                 actualDigits);
67
     }
70
     }
68
 
71
 
69
-    @Ignore
72
+    @Ignore("Remove to run test")
70
     @Test
73
     @Test
71
     public void testBinaryToMultipleDecimal() {
74
     public void testBinaryToMultipleDecimal() {
72
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
75
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
83
                 actualDigits);
86
                 actualDigits);
84
     }
87
     }
85
 
88
 
86
-    @Ignore
89
+    @Ignore("Remove to run test")
87
     @Test
90
     @Test
88
     public void testDecimalToBinary() {
91
     public void testDecimalToBinary() {
89
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{4, 2});
92
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{4, 2});
100
                 actualDigits);
103
                 actualDigits);
101
     }
104
     }
102
 
105
 
103
-    @Ignore
106
+    @Ignore("Remove to run test")
104
     @Test
107
     @Test
105
     public void testTrinaryToHexadecimal() {
108
     public void testTrinaryToHexadecimal() {
106
         final BaseConverter baseConverter = new BaseConverter(3, new int[]{1, 1, 2, 0});
109
         final BaseConverter baseConverter = new BaseConverter(3, new int[]{1, 1, 2, 0});
117
                 actualDigits);
120
                 actualDigits);
118
     }
121
     }
119
 
122
 
120
-    @Ignore
123
+    @Ignore("Remove to run test")
121
     @Test
124
     @Test
122
     public void testHexadecimalToTrinary() {
125
     public void testHexadecimalToTrinary() {
123
         final BaseConverter baseConverter = new BaseConverter(16, new int[]{2, 10});
126
         final BaseConverter baseConverter = new BaseConverter(16, new int[]{2, 10});
134
                 actualDigits);
137
                 actualDigits);
135
     }
138
     }
136
 
139
 
137
-    @Ignore
140
+    @Ignore("Remove to run test")
138
     @Test
141
     @Test
139
     public void test15BitInteger() {
142
     public void test15BitInteger() {
140
         final BaseConverter baseConverter = new BaseConverter(97, new int[]{3, 46, 60});
143
         final BaseConverter baseConverter = new BaseConverter(97, new int[]{3, 46, 60});
151
                 actualDigits);
154
                 actualDigits);
152
     }
155
     }
153
 
156
 
154
-    @Ignore
157
+    @Ignore("Remove to run test")
155
     @Test
158
     @Test
156
     public void testEmptyDigits() {
159
     public void testEmptyDigits() {
157
         expectedException.expect(IllegalArgumentException.class);
160
         expectedException.expect(IllegalArgumentException.class);
160
         new BaseConverter(2, new int[]{});
163
         new BaseConverter(2, new int[]{});
161
     }
164
     }
162
 
165
 
163
-    @Ignore
166
+    @Ignore("Remove to run test")
164
     @Test
167
     @Test
165
     public void testSingleZero() {
168
     public void testSingleZero() {
166
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{0});
169
         final BaseConverter baseConverter = new BaseConverter(10, new int[]{0});
177
                 actualDigits);
180
                 actualDigits);
178
     }
181
     }
179
 
182
 
180
-    @Ignore
183
+    @Ignore("Remove to run test")
181
     @Test
184
     @Test
182
     public void testMultipleZeros() {
185
     public void testMultipleZeros() {
183
         expectedException.expect(IllegalArgumentException.class);
186
         expectedException.expect(IllegalArgumentException.class);
186
         new BaseConverter(10, new int[]{0, 0, 0});
189
         new BaseConverter(10, new int[]{0, 0, 0});
187
     }
190
     }
188
 
191
 
189
-    @Ignore
192
+    @Ignore("Remove to run test")
190
     @Test
193
     @Test
191
     public void testLeadingZeros() {
194
     public void testLeadingZeros() {
192
         expectedException.expect(IllegalArgumentException.class);
195
         expectedException.expect(IllegalArgumentException.class);
195
         new BaseConverter(7, new int[]{0, 6, 0});
198
         new BaseConverter(7, new int[]{0, 6, 0});
196
     }
199
     }
197
 
200
 
198
-    @Ignore
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
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
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
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
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
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
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
268
+    @Ignore("Remove to run test")
266
     @Test
269
     @Test
267
     public void testSecondBaseIsNegative() {
270
     public void testSecondBaseIsNegative() {
268
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1});
271
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1});

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

+ 18
- 18
exercises/allergies/src/test/java/AllergiesTest.java Просмотреть файл

20
         assertEquals(false, allergies.isAllergicTo(Allergen.CATS));
20
         assertEquals(false, allergies.isAllergicTo(Allergen.CATS));
21
     }
21
     }
22
 
22
 
23
-    @Ignore
23
+    @Ignore("Remove to run test")
24
     @Test
24
     @Test
25
     public void allergicToEggs() {
25
     public void allergicToEggs() {
26
         Allergies allergies = new Allergies(1);
26
         Allergies allergies = new Allergies(1);
28
         assertEquals(true, allergies.isAllergicTo(Allergen.EGGS));
28
         assertEquals(true, allergies.isAllergicTo(Allergen.EGGS));
29
     }
29
     }
30
 
30
 
31
-    @Ignore
31
+    @Ignore("Remove to run test")
32
     @Test
32
     @Test
33
     public void allergicToPeanuts() {
33
     public void allergicToPeanuts() {
34
         Allergies allergies = new Allergies(2);
34
         Allergies allergies = new Allergies(2);
36
         assertEquals(true, allergies.isAllergicTo(Allergen.PEANUTS));
36
         assertEquals(true, allergies.isAllergicTo(Allergen.PEANUTS));
37
     }
37
     }
38
 
38
 
39
-    @Ignore
39
+    @Ignore("Remove to run test")
40
     @Test
40
     @Test
41
     public void allergicToShellfish() {
41
     public void allergicToShellfish() {
42
         Allergies allergies = new Allergies(4);
42
         Allergies allergies = new Allergies(4);
44
         assertEquals(true, allergies.isAllergicTo(Allergen.SHELLFISH));
44
         assertEquals(true, allergies.isAllergicTo(Allergen.SHELLFISH));
45
     }
45
     }
46
 
46
 
47
-    @Ignore
47
+    @Ignore("Remove to run test")
48
     @Test
48
     @Test
49
     public void allergicToStrawberries() {
49
     public void allergicToStrawberries() {
50
         Allergies allergies = new Allergies(8);
50
         Allergies allergies = new Allergies(8);
52
         assertEquals(true, allergies.isAllergicTo(Allergen.STRAWBERRIES));
52
         assertEquals(true, allergies.isAllergicTo(Allergen.STRAWBERRIES));
53
     }
53
     }
54
 
54
 
55
-    @Ignore
55
+    @Ignore("Remove to run test")
56
     @Test
56
     @Test
57
     public void allergicToTomatoes() {
57
     public void allergicToTomatoes() {
58
         Allergies allergies = new Allergies(16);
58
         Allergies allergies = new Allergies(16);
60
         assertEquals(true, allergies.isAllergicTo(Allergen.TOMATOES));
60
         assertEquals(true, allergies.isAllergicTo(Allergen.TOMATOES));
61
     }
61
     }
62
 
62
 
63
-    @Ignore
63
+    @Ignore("Remove to run test")
64
     @Test
64
     @Test
65
     public void allergicToChocolate() {
65
     public void allergicToChocolate() {
66
         Allergies allergies = new Allergies(32);
66
         Allergies allergies = new Allergies(32);
68
         assertEquals(true, allergies.isAllergicTo(Allergen.CHOCOLATE));
68
         assertEquals(true, allergies.isAllergicTo(Allergen.CHOCOLATE));
69
     }
69
     }
70
 
70
 
71
-    @Ignore
71
+    @Ignore("Remove to run test")
72
     @Test
72
     @Test
73
     public void allergicToPollen() {
73
     public void allergicToPollen() {
74
         Allergies allergies = new Allergies(64);
74
         Allergies allergies = new Allergies(64);
76
         assertEquals(true, allergies.isAllergicTo(Allergen.POLLEN));
76
         assertEquals(true, allergies.isAllergicTo(Allergen.POLLEN));
77
     }
77
     }
78
 
78
 
79
-    @Ignore
79
+    @Ignore("Remove to run test")
80
     @Test
80
     @Test
81
     public void allergicToCats() {
81
     public void allergicToCats() {
82
         Allergies allergies = new Allergies(128);
82
         Allergies allergies = new Allergies(128);
84
         assertEquals(true, allergies.isAllergicTo(Allergen.CATS));
84
         assertEquals(true, allergies.isAllergicTo(Allergen.CATS));
85
     }
85
     }
86
 
86
 
87
-    @Ignore
87
+    @Ignore("Remove to run test")
88
     @Test
88
     @Test
89
     public void isAllergicToEggsInAdditionToOtherStuff() {
89
     public void isAllergicToEggsInAdditionToOtherStuff() {
90
         Allergies allergies = new Allergies(5);
90
         Allergies allergies = new Allergies(5);
94
         assertEquals(false, allergies.isAllergicTo(Allergen.STRAWBERRIES));
94
         assertEquals(false, allergies.isAllergicTo(Allergen.STRAWBERRIES));
95
     }
95
     }
96
 
96
 
97
-    @Ignore
97
+    @Ignore("Remove to run test")
98
     @Test
98
     @Test
99
     public void noAllergies() {
99
     public void noAllergies() {
100
         Allergies allergies = new Allergies(0);
100
         Allergies allergies = new Allergies(0);
102
         assertEquals(0, allergies.getList().size());
102
         assertEquals(0, allergies.getList().size());
103
     }
103
     }
104
 
104
 
105
-    @Ignore
105
+    @Ignore("Remove to run test")
106
     @Test
106
     @Test
107
     public void isAllergicToJustEggs() {
107
     public void isAllergicToJustEggs() {
108
         Allergies allergies = new Allergies(1);
108
         Allergies allergies = new Allergies(1);
111
         assertEquals(expectedAllergens, allergies.getList());
111
         assertEquals(expectedAllergens, allergies.getList());
112
     }
112
     }
113
 
113
 
114
-    @Ignore
114
+    @Ignore("Remove to run test")
115
     @Test
115
     @Test
116
     public void isAllergicToJustPeanuts() {
116
     public void isAllergicToJustPeanuts() {
117
         Allergies allergies = new Allergies(2);
117
         Allergies allergies = new Allergies(2);
120
         assertEquals(expectedAllergens, allergies.getList());
120
         assertEquals(expectedAllergens, allergies.getList());
121
     }
121
     }
122
 
122
 
123
-    @Ignore
123
+    @Ignore("Remove to run test")
124
     @Test
124
     @Test
125
     public void isAllergicToJustStrawberries() {
125
     public void isAllergicToJustStrawberries() {
126
         Allergies allergies = new Allergies(8);
126
         Allergies allergies = new Allergies(8);
129
         assertEquals(expectedAllergens, allergies.getList());
129
         assertEquals(expectedAllergens, allergies.getList());
130
     }
130
     }
131
 
131
 
132
-    @Ignore
132
+    @Ignore("Remove to run test")
133
     @Test
133
     @Test
134
     public void isAllergicToEggsAndPeanuts() {
134
     public void isAllergicToEggsAndPeanuts() {
135
         Allergies allergies = new Allergies(3);
135
         Allergies allergies = new Allergies(3);
141
         assertEquals(expectedAllergens, allergies.getList());
141
         assertEquals(expectedAllergens, allergies.getList());
142
     }
142
     }
143
 
143
 
144
-    @Ignore
144
+    @Ignore("Remove to run test")
145
     @Test
145
     @Test
146
     public void isAllergicToEggsAndShellfish() {
146
     public void isAllergicToEggsAndShellfish() {
147
         Allergies allergies = new Allergies(5);
147
         Allergies allergies = new Allergies(5);
153
         assertEquals(expectedAllergens, allergies.getList());
153
         assertEquals(expectedAllergens, allergies.getList());
154
     }
154
     }
155
 
155
 
156
-    @Ignore
156
+    @Ignore("Remove to run test")
157
     @Test
157
     @Test
158
     public void isAllergicToLotsOfStuff() {
158
     public void isAllergicToLotsOfStuff() {
159
         Allergies allergies = new Allergies(248);
159
         Allergies allergies = new Allergies(248);
168
         assertEquals(expectedAllergens, allergies.getList());
168
         assertEquals(expectedAllergens, allergies.getList());
169
     }
169
     }
170
 
170
 
171
-    @Ignore
171
+    @Ignore("Remove to run test")
172
     @Test
172
     @Test
173
     public void isAllergicToEverything() {
173
     public void isAllergicToEverything() {
174
         Allergies allergies = new Allergies(255);
174
         Allergies allergies = new Allergies(255);
186
         assertEquals(expectedAllergens, allergies.getList());
186
         assertEquals(expectedAllergens, allergies.getList());
187
     }
187
     }
188
 
188
 
189
-    @Ignore
189
+    @Ignore("Remove to run test")
190
     @Test
190
     @Test
191
     public void ignoreNonAllergenScoreParts() {
191
     public void ignoreNonAllergenScoreParts() {
192
         Allergies allergies = new Allergies(509);
192
         Allergies allergies = new Allergies(509);

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

+ 15
- 15
exercises/anagram/src/test/java/AnagramTest.java Просмотреть файл

16
         assertTrue(detector.match(Arrays.asList("hello", "world", "zombies", "pants")).isEmpty());
16
         assertTrue(detector.match(Arrays.asList("hello", "world", "zombies", "pants")).isEmpty());
17
     }
17
     }
18
 
18
 
19
-    @Ignore
19
+    @Ignore("Remove to run test")
20
     @Test
20
     @Test
21
     public void testDetectSimpleAnagram() {
21
     public void testDetectSimpleAnagram() {
22
         Anagram detector = new Anagram("ant");
22
         Anagram detector = new Anagram("ant");
25
         assertThat(anagram.size(), is(1));
25
         assertThat(anagram.size(), is(1));
26
     }
26
     }
27
 
27
 
28
-    @Ignore
28
+    @Ignore("Remove to run test")
29
     @Test
29
     @Test
30
     public void testDetectLongerAnagram() {
30
     public void testDetectLongerAnagram() {
31
         Anagram detector = new Anagram("listen");
31
         Anagram detector = new Anagram("listen");
33
         assertThat(anagrams, hasItem("inlets"));
33
         assertThat(anagrams, hasItem("inlets"));
34
     }
34
     }
35
 
35
 
36
-    @Ignore
36
+    @Ignore("Remove to run test")
37
     @Test
37
     @Test
38
     public void testDetectMultipleAnagrams() {
38
     public void testDetectMultipleAnagrams() {
39
         Anagram detector = new Anagram("master");
39
         Anagram detector = new Anagram("master");
41
         assertThat(anagrams, allOf(hasItem("maters"), hasItem("stream")));
41
         assertThat(anagrams, allOf(hasItem("maters"), hasItem("stream")));
42
     }
42
     }
43
 
43
 
44
-    @Ignore
44
+    @Ignore("Remove to run test")
45
     @Test
45
     @Test
46
     public void testDetectMultipleAnagramsForLongerWord() {
46
     public void testDetectMultipleAnagramsForLongerWord() {
47
         Anagram detector = new Anagram("allergy");
47
         Anagram detector = new Anagram("allergy");
49
         assertThat(anagrams, allOf(hasItem("gallery"), hasItem("largely"), hasItem("regally")));
49
         assertThat(anagrams, allOf(hasItem("gallery"), hasItem("largely"), hasItem("regally")));
50
     }
50
     }
51
 
51
 
52
-    @Ignore
52
+    @Ignore("Remove to run test")
53
     @Test
53
     @Test
54
     public void testDoesNotConfuseDifferentDuplicates() {
54
     public void testDoesNotConfuseDifferentDuplicates() {
55
         Anagram detector = new Anagram("galea");
55
         Anagram detector = new Anagram("galea");
56
         assertTrue(detector.match(Arrays.asList("eagle")).isEmpty());
56
         assertTrue(detector.match(Arrays.asList("eagle")).isEmpty());
57
     }
57
     }
58
 
58
 
59
-    @Ignore
59
+    @Ignore("Remove to run test")
60
     @Test
60
     @Test
61
     public void testIdenticalWordIsNotAnagram() {
61
     public void testIdenticalWordIsNotAnagram() {
62
         Anagram detector = new Anagram("corn");
62
         Anagram detector = new Anagram("corn");
65
         assertThat(anagrams.size(), is(1));
65
         assertThat(anagrams.size(), is(1));
66
     }
66
     }
67
 
67
 
68
-    @Ignore
68
+    @Ignore("Remove to run test")
69
     @Test
69
     @Test
70
     public void testIdenticalWordRepeatedIsNotAnagram() {
70
     public void testIdenticalWordRepeatedIsNotAnagram() {
71
         Anagram detector = new Anagram("go");
71
         Anagram detector = new Anagram("go");
72
         assertTrue(detector.match(Arrays.asList("go Go GO")).isEmpty());
72
         assertTrue(detector.match(Arrays.asList("go Go GO")).isEmpty());
73
     }
73
     }
74
 
74
 
75
-    @Ignore
75
+    @Ignore("Remove to run test")
76
     @Test
76
     @Test
77
     public void testCapitalWordIsNotOwnAnagram() {
77
     public void testCapitalWordIsNotOwnAnagram() {
78
         Anagram detector = new Anagram("BANANA");
78
         Anagram detector = new Anagram("BANANA");
79
         assertTrue(detector.match(Arrays.asList("Banana")).isEmpty());
79
         assertTrue(detector.match(Arrays.asList("Banana")).isEmpty());
80
     }
80
     }
81
 
81
 
82
-    @Ignore
82
+    @Ignore("Remove to run test")
83
     @Test
83
     @Test
84
     public void testEliminateAnagramsWithSameChecksum() {
84
     public void testEliminateAnagramsWithSameChecksum() {
85
         Anagram detector = new Anagram("mass");
85
         Anagram detector = new Anagram("mass");
86
         assertTrue(detector.match(Arrays.asList("last")).isEmpty());
86
         assertTrue(detector.match(Arrays.asList("last")).isEmpty());
87
     }
87
     }
88
 
88
 
89
-    @Ignore
89
+    @Ignore("Remove to run test")
90
     @Test
90
     @Test
91
     public void testEliminateAnagramSubsets() {
91
     public void testEliminateAnagramSubsets() {
92
         Anagram detector = new Anagram("good");
92
         Anagram detector = new Anagram("good");
93
         assertTrue(detector.match(Arrays.asList("dog", "goody")).isEmpty());
93
         assertTrue(detector.match(Arrays.asList("dog", "goody")).isEmpty());
94
     }
94
     }
95
 
95
 
96
-    @Ignore
96
+    @Ignore("Remove to run test")
97
     @Test
97
     @Test
98
     public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
98
     public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
99
         Anagram detector = new Anagram("Orchestra");
99
         Anagram detector = new Anagram("Orchestra");
101
         assertThat(anagrams, hasItem("carthorse"));
101
         assertThat(anagrams, hasItem("carthorse"));
102
     }
102
     }
103
 
103
 
104
-    @Ignore
104
+    @Ignore("Remove to run test")
105
     @Test
105
     @Test
106
     public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
106
     public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
107
         Anagram detector = new Anagram("orchestra");
107
         Anagram detector = new Anagram("orchestra");
109
         assertThat(anagrams, hasItem("Carthorse"));
109
         assertThat(anagrams, hasItem("Carthorse"));
110
     }
110
     }
111
 
111
 
112
-    @Ignore
112
+    @Ignore("Remove to run test")
113
     @Test
113
     @Test
114
     public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() {
114
     public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() {
115
         Anagram detector = new Anagram("Orchestra");
115
         Anagram detector = new Anagram("Orchestra");
117
         assertThat(anagrams, hasItem("Carthorse"));
117
         assertThat(anagrams, hasItem("Carthorse"));
118
     }
118
     }
119
 
119
 
120
-    @Ignore
120
+    @Ignore("Remove to run test")
121
     @Test
121
     @Test
122
     public void testWordIsNotItsOwnAnagram() {
122
     public void testWordIsNotItsOwnAnagram() {
123
         Anagram detector = new Anagram("banana");
123
         Anagram detector = new Anagram("banana");
124
         assertTrue(detector.match(Arrays.asList("Banana")).isEmpty());
124
         assertTrue(detector.match(Arrays.asList("Banana")).isEmpty());
125
     }
125
     }
126
 
126
 
127
-    @Ignore
127
+    @Ignore("Remove to run test")
128
     @Test
128
     @Test
129
     public void testAnagramMustUseAllLettersExactlyOnce() {
129
     public void testAnagramMustUseAllLettersExactlyOnce() {
130
         Anagram detector = new Anagram("tapper");
130
         Anagram detector = new Anagram("tapper");

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

+ 5
- 5
exercises/atbash-cipher/src/example/java/Atbash.java Просмотреть файл

7
     private static final String PLAIN = "abcdefghijklmnopqrstuvwxyz";
7
     private static final String PLAIN = "abcdefghijklmnopqrstuvwxyz";
8
     private static final String CIPHER = "zyxwvutsrqponmlkjihgfedcba";
8
     private static final String CIPHER = "zyxwvutsrqponmlkjihgfedcba";
9
 
9
 
10
-    public static String encode(String input) {
10
+    public String encode(String input) {
11
         String encoded = stripInvalidCharacters(input).toLowerCase();
11
         String encoded = stripInvalidCharacters(input).toLowerCase();
12
         String cyphered = "";
12
         String cyphered = "";
13
 
13
 
18
         return splitIntoFiveLetterWords(cyphered);
18
         return splitIntoFiveLetterWords(cyphered);
19
     }
19
     }
20
 
20
 
21
-    public static String decode(String input) {
21
+    public String decode(String input) {
22
         String encoded = stripInvalidCharacters(input).toLowerCase();
22
         String encoded = stripInvalidCharacters(input).toLowerCase();
23
         String deciphered = "";
23
         String deciphered = "";
24
 
24
 
29
         return deciphered;
29
         return deciphered;
30
     }
30
     }
31
 
31
 
32
-    private static String stripInvalidCharacters(String input) {
32
+    private String stripInvalidCharacters(String input) {
33
         String filteredValue = "";
33
         String filteredValue = "";
34
 
34
 
35
         for (char c : input.toCharArray()) {
35
         for (char c : input.toCharArray()) {
41
         return filteredValue;
41
         return filteredValue;
42
     }
42
     }
43
 
43
 
44
-    private static char applyCipher(char input) {
44
+    private char applyCipher(char input) {
45
         int idx = PLAIN.indexOf(input);
45
         int idx = PLAIN.indexOf(input);
46
 
46
 
47
         return idx >= 0 ? CIPHER.toCharArray()[idx] : input;
47
         return idx >= 0 ? CIPHER.toCharArray()[idx] : input;
48
     }
48
     }
49
 
49
 
50
-    private static String splitIntoFiveLetterWords(String value) {
50
+    private String splitIntoFiveLetterWords(String value) {
51
         List<String> words = new ArrayList<>();
51
         List<String> words = new ArrayList<>();
52
 
52
 
53
         for (int i = 0; i < value.length(); i += GROUP_SIZE) {
53
         for (int i = 0; i < value.length(); i += GROUP_SIZE) {

+ 19
- 19
exercises/atbash-cipher/src/test/java/AtbashTest.java Просмотреть файл

1
-import org.junit.Test;
2
 import org.junit.Ignore;
1
 import org.junit.Ignore;
2
+import org.junit.Test;
3
 import org.junit.experimental.runners.Enclosed;
3
 import org.junit.experimental.runners.Enclosed;
4
 import org.junit.runner.RunWith;
4
 import org.junit.runner.RunWith;
5
 import org.junit.runners.Parameterized;
5
 import org.junit.runners.Parameterized;
20
 
20
 
21
         @Parameters(name = "{index}: expected plaintext \"{0}\" to encode to ciphertext \"{1}\".")
21
         @Parameters(name = "{index}: expected plaintext \"{0}\" to encode to ciphertext \"{1}\".")
22
         public static Collection<Object[]> data() {
22
         public static Collection<Object[]> data() {
23
-            return Arrays.asList(new Object[][] {
24
-                    { "no", "ml" },
25
-                    { "yes", "bvh" },
26
-                    { "OMG", "lnt" },
27
-                    { "mindblowingly", "nrmwy oldrm tob" },
28
-                    { "Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt" },
29
-                    { "Truth is fiction.", "gifgs rhurx grlm" },
30
-                    { "The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" }
23
+            return Arrays.asList(new Object[][]{
24
+                    {"no", "ml"},
25
+                    {"yes", "bvh"},
26
+                    {"OMG", "lnt"},
27
+                    {"mindblowingly", "nrmwy oldrm tob"},
28
+                    {"Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt"},
29
+                    {"Truth is fiction.", "gifgs rhurx grlm"},
30
+                    {"The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"}
31
             });
31
             });
32
         }
32
         }
33
 
33
 
37
         }
37
         }
38
 
38
 
39
 
39
 
40
-    @Test
40
+        @Test
41
         public void test() {
41
         public void test() {
42
-            assertEquals(ciphertext, Atbash.encode(plaintext));
42
+            assertEquals(ciphertext, new Atbash().encode(plaintext));
43
         }
43
         }
44
     }
44
     }
45
 
45
 
50
 
50
 
51
         @Parameters(name = "{index}: expected ciphertext \"{0}\" to decode to plaintext \"{1}\".")
51
         @Parameters(name = "{index}: expected ciphertext \"{0}\" to decode to plaintext \"{1}\".")
52
         public static Collection<Object[]> data() {
52
         public static Collection<Object[]> data() {
53
-            return Arrays.asList(new Object[][] {
54
-                    { "vcvix rhn", "exercism" },
55
-                    { "zmlyh gzxov rhlug vmzhg vkkrm thglm v", "anobstacleisoftenasteppingstone" },
56
-                    { "gvhgr mt123 gvhgr mt", "testing123testing" },
57
-                    { "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", "thequickbrownfoxjumpsoverthelazydog" }
53
+            return Arrays.asList(new Object[][]{
54
+                    {"vcvix rhn", "exercism"},
55
+                    {"zmlyh gzxov rhlug vmzhg vkkrm thglm v", "anobstacleisoftenasteppingstone"},
56
+                    {"gvhgr mt123 gvhgr mt", "testing123testing"},
57
+                    {"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", "thequickbrownfoxjumpsoverthelazydog"}
58
             });
58
             });
59
         }
59
         }
60
 
60
 
63
             this.plaintext = plaintext;
63
             this.plaintext = plaintext;
64
         }
64
         }
65
 
65
 
66
-        @Ignore
67
-    @Test
66
+        @Ignore("Remove to run tests")
67
+        @Test
68
         public void test() {
68
         public void test() {
69
-            assertEquals(plaintext, Atbash.decode(ciphertext));
69
+            assertEquals(plaintext, new Atbash().decode(ciphertext));
70
         }
70
         }
71
     }
71
     }
72
 }
72
 }

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

+ 4
- 7
exercises/beer-song/src/example/java/BeerSong.java Просмотреть файл

1
 public class BeerSong {
1
 public class BeerSong {
2
-    public static String verse(int number)
3
-    {
4
-        switch (number)
5
-        {
2
+    public String verse(int number) {
3
+        switch (number) {
6
             case 0:
4
             case 0:
7
                 return "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n";
5
                 return "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n";
8
             case 1:
6
             case 1:
14
         }
12
         }
15
     }
13
     }
16
 
14
 
17
-    public static String sing(int start, int stop)
18
-    {
15
+    public String sing(int start, int stop) {
19
         StringBuilder songOutput = new StringBuilder();
16
         StringBuilder songOutput = new StringBuilder();
20
 
17
 
21
         for (int i=start; i>=stop; i--) {
18
         for (int i=start; i>=stop; i--) {
25
         return songOutput.toString();
22
         return songOutput.toString();
26
     }
23
     }
27
 
24
 
28
-    public static String singSong() {
25
+    public String singSong() {
29
         return sing(99,0);
26
         return sing(99,0);
30
     }
27
     }
31
 }
28
 }

+ 21
- 13
exercises/beer-song/src/test/java/BeerSongTest.java Просмотреть файл

1
 import org.junit.Test;
1
 import org.junit.Test;
2
 import org.junit.Ignore;
2
 import org.junit.Ignore;
3
+import org.junit.Before;
3
 
4
 
4
 import static org.junit.Assert.assertEquals;
5
 import static org.junit.Assert.assertEquals;
5
 
6
 
6
 public class BeerSongTest {
7
 public class BeerSongTest {
7
 
8
 
9
+    private BeerSong beerSong;
10
+
11
+    @Before
12
+    public void setup(){
13
+        beerSong = new BeerSong();
14
+    }
15
+
8
     @Test
16
     @Test
9
     public void singFirstVerse() {
17
     public void singFirstVerse() {
10
         assertEquals("99 bottles of beer on the wall, 99 bottles of beer.\n" +
18
         assertEquals("99 bottles of beer on the wall, 99 bottles of beer.\n" +
11
                         "Take one down and pass it around, 98 bottles of beer on the wall.\n\n",
19
                         "Take one down and pass it around, 98 bottles of beer on the wall.\n\n",
12
-                BeerSong.verse(99));
20
+                beerSong.verse(99));
13
     }
21
     }
14
 
22
 
15
-    @Ignore
23
+    @Ignore("Remove to run test")
16
     @Test
24
     @Test
17
     public void singMiddleVerse() {
25
     public void singMiddleVerse() {
18
         assertEquals("44 bottles of beer on the wall, 44 bottles of beer.\n" +
26
         assertEquals("44 bottles of beer on the wall, 44 bottles of beer.\n" +
19
                         "Take one down and pass it around, 43 bottles of beer on the wall.\n\n",
27
                         "Take one down and pass it around, 43 bottles of beer on the wall.\n\n",
20
-                BeerSong.verse(44));
28
+                beerSong.verse(44));
21
     }
29
     }
22
 
30
 
23
-    @Ignore
31
+    @Ignore("Remove to run test")
24
     @Test
32
     @Test
25
     public void singThirdToLastVerse() {
33
     public void singThirdToLastVerse() {
26
         assertEquals("2 bottles of beer on the wall, 2 bottles of beer.\n" +
34
         assertEquals("2 bottles of beer on the wall, 2 bottles of beer.\n" +
27
                         "Take one down and pass it around, 1 bottle of beer on the wall.\n\n",
35
                         "Take one down and pass it around, 1 bottle of beer on the wall.\n\n",
28
-                BeerSong.verse(2));
36
+                beerSong.verse(2));
29
     }
37
     }
30
 
38
 
31
-    @Ignore
39
+    @Ignore("Remove to run test")
32
     @Test
40
     @Test
33
     public void singPenultimateVerse() {
41
     public void singPenultimateVerse() {
34
         assertEquals("1 bottle of beer on the wall, 1 bottle of beer.\n" +
42
         assertEquals("1 bottle of beer on the wall, 1 bottle of beer.\n" +
35
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n",
43
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n",
36
-                BeerSong.verse(1));
44
+                beerSong.verse(1));
37
     }
45
     }
38
 
46
 
39
-    @Ignore
47
+    @Ignore("Remove to run test")
40
     @Test
48
     @Test
41
     public void singLastVerse() {
49
     public void singLastVerse() {
42
         assertEquals("No more bottles of beer on the wall, no more bottles of beer.\n" +
50
         assertEquals("No more bottles of beer on the wall, no more bottles of beer.\n" +
43
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
51
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
44
-                BeerSong.verse(0));
52
+                beerSong.verse(0));
45
     }
53
     }
46
 
54
 
47
-    @Ignore
55
+    @Ignore("Remove to run test")
48
     @Test
56
     @Test
49
     public void singLastFourVerses() {
57
     public void singLastFourVerses() {
50
         assertEquals("3 bottles of beer on the wall, 3 bottles of beer.\n" +
58
         assertEquals("3 bottles of beer on the wall, 3 bottles of beer.\n" +
55
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n" +
63
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n" +
56
                         "No more bottles of beer on the wall, no more bottles of beer.\n" +
64
                         "No more bottles of beer on the wall, no more bottles of beer.\n" +
57
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
65
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
58
-                BeerSong.sing(3,0));
66
+                beerSong.sing(3,0));
59
     }
67
     }
60
 
68
 
61
-    @Ignore
69
+    @Ignore("Remove to run test")
62
     @Test
70
     @Test
63
     public void singEntireSong() {
71
     public void singEntireSong() {
64
         assertEquals("99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n\n" +
72
         assertEquals("99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n\n" +
161
                         "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n" +
169
                         "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n" +
162
                         "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\n" +
170
                         "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\n" +
163
                         "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n",
171
                         "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n",
164
-                BeerSong.singSong());
172
+                beerSong.singSong());
165
     }
173
     }
166
 
174
 
167
 }
175
 }

+ 41
- 41
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);
21
     }
21
     }
22
 
22
 
23
     @Test
23
     @Test
24
-    @Ignore
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);
42
     }
42
     }
43
 
43
 
44
     @Test
44
     @Test
45
-    @Ignore
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);
63
     }
63
     }
64
 
64
 
65
     @Test
65
     @Test
66
-    @Ignore
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);
84
     }
84
     }
85
 
85
 
86
     @Test
86
     @Test
87
-    @Ignore
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(value -> sut.insert(value));
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
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
-                Arrays.asList(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
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
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
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(value -> sut.insert(value));
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'

+ 79
- 87
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
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
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
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
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
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
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
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
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
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'

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

15
         );
15
         );
16
     }
16
     }
17
 
17
 
18
-    @Ignore
18
+    @Ignore("Remove to run test")
19
     @Test
19
     @Test
20
     public void shouting() {
20
     public void shouting() {
21
         assertEquals(
21
         assertEquals(
24
         );
24
         );
25
     }
25
     }
26
 
26
 
27
-    @Ignore
27
+    @Ignore("Remove to run test")
28
     @Test
28
     @Test
29
     public void askingAQuestion() {
29
     public void askingAQuestion() {
30
         assertEquals(
30
         assertEquals(
33
         );
33
         );
34
     }
34
     }
35
 
35
 
36
-    @Ignore
36
+    @Ignore("Remove to run test")
37
     @Test
37
     @Test
38
     public void askingANumericQuestion() {
38
     public void askingANumericQuestion() {
39
         assertEquals(
39
         assertEquals(
42
         );
42
         );
43
     }
43
     }
44
 
44
 
45
-    @Ignore
45
+    @Ignore("Remove to run test")
46
     @Test
46
     @Test
47
     public void talkingForcefully() {
47
     public void talkingForcefully() {
48
         assertEquals(
48
         assertEquals(
51
         );
51
         );
52
     }
52
     }
53
 
53
 
54
-    @Ignore
54
+    @Ignore("Remove to run test")
55
     @Test
55
     @Test
56
     public void usingAcronymsInRegularSpeech() {
56
     public void usingAcronymsInRegularSpeech() {
57
         assertEquals(
57
         assertEquals(
59
         );
59
         );
60
     }
60
     }
61
 
61
 
62
-    @Ignore
62
+    @Ignore("Remove to run test")
63
     @Test
63
     @Test
64
     public void forcefulQuestions() {
64
     public void forcefulQuestions() {
65
         assertEquals(
65
         assertEquals(
67
         );
67
         );
68
     }
68
     }
69
 
69
 
70
-    @Ignore
70
+    @Ignore("Remove to run test")
71
     @Test
71
     @Test
72
     public void shoutingNumbers() {
72
     public void shoutingNumbers() {
73
         assertEquals(
73
         assertEquals(
75
         );
75
         );
76
     }
76
     }
77
 
77
 
78
-    @Ignore
78
+    @Ignore("Remove to run test")
79
     @Test
79
     @Test
80
     public void onlyNumbers() {
80
     public void onlyNumbers() {
81
         assertEquals(
81
         assertEquals(
83
         );
83
         );
84
     }
84
     }
85
 
85
 
86
-    @Ignore
86
+    @Ignore("Remove to run test")
87
     @Test
87
     @Test
88
     public void questionWithOnlyNumbers() {
88
     public void questionWithOnlyNumbers() {
89
         assertEquals(
89
         assertEquals(
91
         );
91
         );
92
     }
92
     }
93
 
93
 
94
-    @Ignore
94
+    @Ignore("Remove to run test")
95
     @Test
95
     @Test
96
     public void shoutingWithSpecialCharacters() {
96
     public void shoutingWithSpecialCharacters() {
97
         assertEquals(
97
         assertEquals(
99
         );
99
         );
100
     }
100
     }
101
 
101
 
102
-    @Ignore
102
+    @Ignore("Remove to run test")
103
     @Test
103
     @Test
104
     public void shoutingWithUmlauts() {
104
     public void shoutingWithUmlauts() {
105
         assertEquals(
105
         assertEquals(
107
         );
107
         );
108
     }
108
     }
109
 
109
 
110
-    @Ignore
110
+    @Ignore("Remove to run test")
111
     @Test
111
     @Test
112
     public void calmlySpeakingWithUmlauts() {
112
     public void calmlySpeakingWithUmlauts() {
113
         assertEquals(
113
         assertEquals(
115
         );
115
         );
116
     }
116
     }
117
 
117
 
118
-    @Ignore
118
+    @Ignore("Remove to run test")
119
     @Test
119
     @Test
120
     public void shoutingWithNoExclamationMark() {
120
     public void shoutingWithNoExclamationMark() {
121
         assertEquals(
121
         assertEquals(
123
         );
123
         );
124
     }
124
     }
125
 
125
 
126
-    @Ignore
126
+    @Ignore("Remove to run test")
127
     @Test
127
     @Test
128
     public void statementContainingQuestionMark() {
128
     public void statementContainingQuestionMark() {
129
         assertEquals(
129
         assertEquals(
131
         );
131
         );
132
     }
132
     }
133
 
133
 
134
-    @Ignore
134
+    @Ignore("Remove to run test")
135
     @Test
135
     @Test
136
     public void prattlingOn() {
136
     public void prattlingOn() {
137
         assertEquals(
137
         assertEquals(
139
         );
139
         );
140
     }
140
     }
141
 
141
 
142
-    @Ignore
142
+    @Ignore("Remove to run test")
143
     @Test
143
     @Test
144
     public void silence() {
144
     public void silence() {
145
         assertEquals(
145
         assertEquals(
147
         );
147
         );
148
     }
148
     }
149
 
149
 
150
-    @Ignore
150
+    @Ignore("Remove to run test")
151
     @Test
151
     @Test
152
     public void prolongedSilence() {
152
     public void prolongedSilence() {
153
         assertEquals(
153
         assertEquals(

+ 18
- 0
exercises/book-store/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/gigasecond/src/main/java/.keep → exercises/book-store/src/example/java/.keep Просмотреть файл


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

1
+import java.util.ArrayList;
2
+import java.util.List;
3
+import java.util.stream.Collectors;
4
+
5
+class BookStore {
6
+
7
+  private static final int BOOK_PRICE = 8, MAX_GROUP_SIZE = 5;
8
+
9
+  private static double[] DISCOUNT_TIERS = {0, 5, 10, 20, 25};
10
+
11
+  double calculateBasketCost(final List<Integer> books) {
12
+    return calculateBasketCost(books, 0);
13
+  }
14
+
15
+  private double calculateBasketCost(final List<Integer> books, final double priceSoFar) {
16
+    if (books.size() == 0) {
17
+      return priceSoFar;
18
+    }
19
+
20
+    List<Integer> availableBookNumbers = books.stream()
21
+        .distinct()
22
+        .collect(Collectors.toList());
23
+
24
+    double minPrice = Double.MAX_VALUE;
25
+
26
+    for (int i = 0; i < availableBookNumbers.size(); i++) {
27
+      List<Integer> newGroupBooks = new ArrayList<>(availableBookNumbers.subList(0, i + 1));
28
+      List<Integer> remainingBooks = new ArrayList<>(books);
29
+
30
+      for (final Integer newGroupBook : newGroupBooks) {
31
+        //noinspection UseBulkOperation - we want to remove _one_ of each book number, not _all_ of each book number.
32
+        remainingBooks.remove(newGroupBook);
33
+      }
34
+
35
+      double price = calculateBasketCost(remainingBooks, priceSoFar + costOfGroupSize(newGroupBooks.size()));
36
+      minPrice = Math.min(minPrice, price);
37
+    }
38
+
39
+    return minPrice;
40
+  }
41
+
42
+  private double costOfGroupSize(int groupSize) {
43
+    if (groupSize < 1 || groupSize > MAX_GROUP_SIZE) {
44
+      throw new IllegalStateException("Invalid group size : " + groupSize);
45
+    }
46
+
47
+    return BOOK_PRICE * groupSize * (100 - DISCOUNT_TIERS[groupSize - 1]) / 100;
48
+  }
49
+
50
+}

exercises/binary-search/src/main/java/.keep → exercises/book-store/src/main/java/.keep Просмотреть файл


exercises/binary-search-tree/src/test/java/.keep → exercises/book-store/src/test/java/.keep Просмотреть файл


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

+ 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
 

+ 13
- 13
exercises/bracket-push/src/test/java/BracketCheckerTest.java Просмотреть файл

5
 import static org.junit.Assert.assertFalse;
5
 import static org.junit.Assert.assertFalse;
6
 import static org.junit.Assert.assertTrue;
6
 import static org.junit.Assert.assertTrue;
7
 
7
 
8
-public final class BracketCheckerTest {
8
+public class BracketCheckerTest {
9
 
9
 
10
     @Test
10
     @Test
11
     public void testPairedSquareBrackets() {
11
     public void testPairedSquareBrackets() {
13
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
13
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
14
     }
14
     }
15
 
15
 
16
-    @Ignore
16
+    @Ignore("Remove to run test")
17
     @Test
17
     @Test
18
     public void testEmptyString() {
18
     public void testEmptyString() {
19
         final BracketChecker bracketChecker = new BracketChecker("");
19
         final BracketChecker bracketChecker = new BracketChecker("");
20
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
20
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
21
     }
21
     }
22
 
22
 
23
-    @Ignore
23
+    @Ignore("Remove to run test")
24
     @Test
24
     @Test
25
     public void testUnpairedBrackets() {
25
     public void testUnpairedBrackets() {
26
         final BracketChecker bracketChecker = new BracketChecker("[[");
26
         final BracketChecker bracketChecker = new BracketChecker("[[");
27
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
27
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
28
     }
28
     }
29
 
29
 
30
-    @Ignore
30
+    @Ignore("Remove to run test")
31
     @Test
31
     @Test
32
     public void testIncorrectlyOrderedBrackets() {
32
     public void testIncorrectlyOrderedBrackets() {
33
         final BracketChecker bracketChecker = new BracketChecker("}{");
33
         final BracketChecker bracketChecker = new BracketChecker("}{");
34
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
34
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
35
     }
35
     }
36
 
36
 
37
-    @Ignore
37
+    @Ignore("Remove to run test")
38
     @Test
38
     @Test
39
     public void testPairedBracketsWithWhitespace() {
39
     public void testPairedBracketsWithWhitespace() {
40
         final BracketChecker bracketChecker = new BracketChecker("{ }");
40
         final BracketChecker bracketChecker = new BracketChecker("{ }");
41
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
41
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
42
     }
42
     }
43
 
43
 
44
-    @Ignore
44
+    @Ignore("Remove to run test")
45
     @Test
45
     @Test
46
     public void testSimpleNestedBrackets() {
46
     public void testSimpleNestedBrackets() {
47
         final BracketChecker bracketChecker = new BracketChecker("{[]}");
47
         final BracketChecker bracketChecker = new BracketChecker("{[]}");
48
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
48
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
49
     }
49
     }
50
 
50
 
51
-    @Ignore
51
+    @Ignore("Remove to run test")
52
     @Test
52
     @Test
53
     public void testSeveralPairedBrackets() {
53
     public void testSeveralPairedBrackets() {
54
         final BracketChecker bracketChecker = new BracketChecker("{}[]");
54
         final BracketChecker bracketChecker = new BracketChecker("{}[]");
55
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
55
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
56
     }
56
     }
57
 
57
 
58
-    @Ignore
58
+    @Ignore("Remove to run test")
59
     @Test
59
     @Test
60
     public void testPairedAndNestedBrackets() {
60
     public void testPairedAndNestedBrackets() {
61
         final BracketChecker bracketChecker = new BracketChecker("([{}({}[])])");
61
         final BracketChecker bracketChecker = new BracketChecker("([{}({}[])])");
62
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
62
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
63
     }
63
     }
64
 
64
 
65
-    @Ignore
65
+    @Ignore("Remove to run test")
66
     @Test
66
     @Test
67
     public void testUnopenedClosingBracket() {
67
     public void testUnopenedClosingBracket() {
68
         final BracketChecker bracketChecker = new BracketChecker("{[)][]}");
68
         final BracketChecker bracketChecker = new BracketChecker("{[)][]}");
69
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
69
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
70
     }
70
     }
71
 
71
 
72
-    @Ignore
72
+    @Ignore("Remove to run test")
73
     @Test
73
     @Test
74
     public void testUnpairedAndNestedBracket() {
74
     public void testUnpairedAndNestedBracket() {
75
         final BracketChecker bracketChecker = new BracketChecker("([{])");
75
         final BracketChecker bracketChecker = new BracketChecker("([{])");
76
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
76
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
77
     }
77
     }
78
 
78
 
79
-    @Ignore
79
+    @Ignore("Remove to run test")
80
     @Test
80
     @Test
81
     public void testPairedAndIncorrectlyNestedBrackets() {
81
     public void testPairedAndIncorrectlyNestedBrackets() {
82
         final BracketChecker bracketChecker = new BracketChecker("[({]})");
82
         final BracketChecker bracketChecker = new BracketChecker("[({]})");
83
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
83
         assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
84
     }
84
     }
85
 
85
 
86
-    @Ignore
86
+    @Ignore("Remove to run test")
87
     @Test
87
     @Test
88
     public void testValidMathExpression() {
88
     public void testValidMathExpression() {
89
         final BracketChecker bracketChecker = new BracketChecker("(((185 + 223.85) * 15) - 543)/2");
89
         final BracketChecker bracketChecker = new BracketChecker("(((185 + 223.85) * 15) - 543)/2");
90
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
90
         assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
91
     }
91
     }
92
 
92
 
93
-    @Ignore
93
+    @Ignore("Remove to run test")
94
     @Test
94
     @Test
95
     public void testValidComplexLaTeXExpression() {
95
     public void testValidComplexLaTeXExpression() {
96
         final BracketChecker bracketChecker = new BracketChecker(
96
         final BracketChecker bracketChecker = new BracketChecker(

+ 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
 

+ 9
- 9
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
26
                 changeCalculator.computeMostEfficientChange(25));
26
                 changeCalculator.computeMostEfficientChange(25));
27
     }
27
     }
28
 
28
 
29
-    @Ignore
29
+    @Ignore("Remove to run test")
30
     @Test
30
     @Test
31
     public void testChangeThatMustBeGivenInMultipleCoins() {
31
     public void testChangeThatMustBeGivenInMultipleCoins() {
32
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 5, 10, 25, 100));
32
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 5, 10, 25, 100));
36
                 changeCalculator.computeMostEfficientChange(15));
36
                 changeCalculator.computeMostEfficientChange(15));
37
     }
37
     }
38
 
38
 
39
-    @Ignore
39
+    @Ignore("Remove to run test")
40
     @Test
40
     @Test
41
     // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
41
     // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
42
     public void testLilliputianCurrencyForWhichGreedyAlgorithmFails() {
42
     public void testLilliputianCurrencyForWhichGreedyAlgorithmFails() {
47
                 changeCalculator.computeMostEfficientChange(23));
47
                 changeCalculator.computeMostEfficientChange(23));
48
     }
48
     }
49
 
49
 
50
-    @Ignore
50
+    @Ignore("Remove to run test")
51
     @Test
51
     @Test
52
     // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
52
     // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
53
     public void testLowerElbonianCurrencyForWhichGreedyAlgorithmFails() {
53
     public void testLowerElbonianCurrencyForWhichGreedyAlgorithmFails() {
58
                 changeCalculator.computeMostEfficientChange(63));
58
                 changeCalculator.computeMostEfficientChange(63));
59
     }
59
     }
60
 
60
 
61
-    @Ignore
61
+    @Ignore("Remove to run test")
62
     @Test
62
     @Test
63
     public void testLargeAmountOfChange() {
63
     public void testLargeAmountOfChange() {
64
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 2, 5, 10, 20, 50, 100));
64
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 2, 5, 10, 20, 50, 100));
68
                 changeCalculator.computeMostEfficientChange(999));
68
                 changeCalculator.computeMostEfficientChange(999));
69
     }
69
     }
70
 
70
 
71
-    @Ignore
71
+    @Ignore("Remove to run test")
72
     @Test
72
     @Test
73
     public void testZeroChange() {
73
     public void testZeroChange() {
74
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 5, 10, 21, 25));
74
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 5, 10, 21, 25));
78
                 changeCalculator.computeMostEfficientChange(0));
78
                 changeCalculator.computeMostEfficientChange(0));
79
     }
79
     }
80
 
80
 
81
-    @Ignore
81
+    @Ignore("Remove to run test")
82
     @Test
82
     @Test
83
     public void testChangeLessThanSmallestCoinInCurrencyCannotBeRepresented() {
83
     public void testChangeLessThanSmallestCoinInCurrencyCannotBeRepresented() {
84
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(5, 10));
84
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(5, 10));
89
         changeCalculator.computeMostEfficientChange(3);
89
         changeCalculator.computeMostEfficientChange(3);
90
     }
90
     }
91
 
91
 
92
-    @Ignore
92
+    @Ignore("Remove to run test")
93
     @Test
93
     @Test
94
     public void testChangeLargerThanAllCoinsInCurrencyThatCannotBeRepresented() {
94
     public void testChangeLargerThanAllCoinsInCurrencyThatCannotBeRepresented() {
95
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(5, 10));
95
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(5, 10));
100
         changeCalculator.computeMostEfficientChange(94);
100
         changeCalculator.computeMostEfficientChange(94);
101
     }
101
     }
102
 
102
 
103
-    @Ignore
103
+    @Ignore("Remove to run test")
104
     @Test
104
     @Test
105
     public void testNegativeChangeIsRejected() {
105
     public void testNegativeChangeIsRejected() {
106
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 2, 5));
106
         ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 2, 5));

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

+ 19
- 16
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
11
+    @Ignore("Remove to run test")
9
     @Test
12
     @Test
10
     public void addMinutes() {
13
     public void addMinutes() {
11
         Clock clock = new Clock(10, 0);
14
         Clock clock = new Clock(10, 0);
13
         assertEquals("10:03", clock.toString());
16
         assertEquals("10:03", clock.toString());
14
     }
17
     }
15
 
18
 
16
-    @Ignore
19
+    @Ignore("Remove to run test")
17
     @Test
20
     @Test
18
     public void addNoMinutes() {
21
     public void addNoMinutes() {
19
         Clock clock = new Clock(6, 41);
22
         Clock clock = new Clock(6, 41);
21
         assertEquals("06:41", clock.toString());
24
         assertEquals("06:41", clock.toString());
22
     }
25
     }
23
 
26
 
24
-    @Ignore
27
+    @Ignore("Remove to run test")
25
     @Test
28
     @Test
26
     public void addToNextHour() {
29
     public void addToNextHour() {
27
         Clock clock = new Clock(0, 45);
30
         Clock clock = new Clock(0, 45);
29
         assertEquals("01:25", clock.toString());
32
         assertEquals("01:25", clock.toString());
30
     }
33
     }
31
 
34
 
32
-    @Ignore
35
+    @Ignore("Remove to run test")
33
     @Test
36
     @Test
34
     public void addMoreThanOneHour() {
37
     public void addMoreThanOneHour() {
35
         Clock clock = new Clock(10, 0);
38
         Clock clock = new Clock(10, 0);
37
         assertEquals("11:01", clock.toString());
40
         assertEquals("11:01", clock.toString());
38
     }
41
     }
39
 
42
 
40
-    @Ignore
43
+    @Ignore("Remove to run test")
41
     @Test
44
     @Test
42
     public void addMoreThanTwoHoursWithCarry() {
45
     public void addMoreThanTwoHoursWithCarry() {
43
         Clock clock = new Clock(0, 45);
46
         Clock clock = new Clock(0, 45);
45
         assertEquals("03:25", clock.toString());
48
         assertEquals("03:25", clock.toString());
46
     }
49
     }
47
 
50
 
48
-    @Ignore
51
+    @Ignore("Remove to run test")
49
     @Test
52
     @Test
50
     public void addAcrossMidnight() {
53
     public void addAcrossMidnight() {
51
         Clock clock = new Clock(23, 59);
54
         Clock clock = new Clock(23, 59);
53
         assertEquals("00:01", clock.toString());
56
         assertEquals("00:01", clock.toString());
54
     }
57
     }
55
 
58
 
56
-    @Ignore
59
+    @Ignore("Remove to run test")
57
     @Test
60
     @Test
58
     public void addMoreThanOneDay() {
61
     public void addMoreThanOneDay() {
59
         Clock clock = new Clock(5, 32);
62
         Clock clock = new Clock(5, 32);
61
         assertEquals("06:32", clock.toString());
64
         assertEquals("06:32", clock.toString());
62
     }
65
     }
63
 
66
 
64
-    @Ignore
67
+    @Ignore("Remove to run test")
65
     @Test
68
     @Test
66
     public void addMoreThanTwoDays() {
69
     public void addMoreThanTwoDays() {
67
         Clock clock = new Clock(1, 1);
70
         Clock clock = new Clock(1, 1);
69
         assertEquals("11:21", clock.toString());
72
         assertEquals("11:21", clock.toString());
70
     }
73
     }
71
 
74
 
72
-    @Ignore
75
+    @Ignore("Remove to run test")
73
     @Test
76
     @Test
74
     public void subtractMinutes() {
77
     public void subtractMinutes() {
75
         Clock clock = new Clock(10, 3);
78
         Clock clock = new Clock(10, 3);
77
         assertEquals("10:00", clock.toString());
80
         assertEquals("10:00", clock.toString());
78
     }
81
     }
79
 
82
 
80
-    @Ignore
83
+    @Ignore("Remove to run test")
81
     @Test
84
     @Test
82
     public void subtractToPreviousHour() {
85
     public void subtractToPreviousHour() {
83
         Clock clock = new Clock(10, 3);
86
         Clock clock = new Clock(10, 3);
85
         assertEquals("09:33", clock.toString());
88
         assertEquals("09:33", clock.toString());
86
     }
89
     }
87
 
90
 
88
-    @Ignore
91
+    @Ignore("Remove to run test")
89
     @Test
92
     @Test
90
     public void subtractMoreThanAnHour() {
93
     public void subtractMoreThanAnHour() {
91
         Clock clock = new Clock(10, 3);
94
         Clock clock = new Clock(10, 3);
93
         assertEquals("08:53", clock.toString());
96
         assertEquals("08:53", clock.toString());
94
     }
97
     }
95
 
98
 
96
-    @Ignore
99
+    @Ignore("Remove to run test")
97
     @Test
100
     @Test
98
     public void subtractAcrossMidnight() {
101
     public void subtractAcrossMidnight() {
99
         Clock clock = new Clock(0, 3);
102
         Clock clock = new Clock(0, 3);
101
         assertEquals("23:59", clock.toString());
104
         assertEquals("23:59", clock.toString());
102
     }
105
     }
103
 
106
 
104
-    @Ignore
107
+    @Ignore("Remove to run test")
105
     @Test
108
     @Test
106
     public void subtractMoreThanTwoHours() {
109
     public void subtractMoreThanTwoHours() {
107
         Clock clock = new Clock(0, 0);
110
         Clock clock = new Clock(0, 0);
109
         assertEquals("21:20", clock.toString());
112
         assertEquals("21:20", clock.toString());
110
     }
113
     }
111
 
114
 
112
-    @Ignore
115
+    @Ignore("Remove to run test")
113
     @Test
116
     @Test
114
     public void subtractMoreThanTwoHoursWithBorrow() {
117
     public void subtractMoreThanTwoHoursWithBorrow() {
115
         Clock clock = new Clock(6, 15);
118
         Clock clock = new Clock(6, 15);
117
         assertEquals("03:35", clock.toString());
120
         assertEquals("03:35", clock.toString());
118
     }
121
     }
119
 
122
 
120
-    @Ignore
123
+    @Ignore("Remove to run test")
121
     @Test
124
     @Test
122
     public void subtractMoreThanOneDay() {
125
     public void subtractMoreThanOneDay() {
123
         Clock clock = new Clock(5, 32);
126
         Clock clock = new Clock(5, 32);
125
         assertEquals("04:32", clock.toString());
128
         assertEquals("04:32", clock.toString());
126
     }
129
     }
127
 
130
 
128
-    @Ignore
131
+    @Ignore("Remove to run test")
129
     @Test
132
     @Test
130
     public void subtractMoreThanTwoDays() {
133
     public void subtractMoreThanTwoDays() {
131
         Clock clock = new Clock(2, 20);
134
         Clock clock = new Clock(2, 20);

+ 21
- 18
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
10
         assertEquals("08:00", new Clock(8, 0).toString());
13
         assertEquals("08:00", new Clock(8, 0).toString());
11
     }
14
     }
12
 
15
 
13
-    @Ignore
16
+    @Ignore("Remove to run test")
14
     @Test
17
     @Test
15
     public void canPrintTimeWithMinutes() {
18
     public void canPrintTimeWithMinutes() {
16
         assertEquals("11:09", new Clock(11, 9).toString());
19
         assertEquals("11:09", new Clock(11, 9).toString());
17
     }
20
     }
18
 
21
 
19
-    @Ignore
22
+    @Ignore("Remove to run test")
20
     @Test
23
     @Test
21
     public void midnightPrintsAsZero() {
24
     public void midnightPrintsAsZero() {
22
         assertEquals("00:00", new Clock(24, 0).toString());
25
         assertEquals("00:00", new Clock(24, 0).toString());
23
     }
26
     }
24
 
27
 
25
-    @Ignore
28
+    @Ignore("Remove to run test")
26
     @Test
29
     @Test
27
     public void hourRollsOver() {
30
     public void hourRollsOver() {
28
         assertEquals("01:00", new Clock(25, 0).toString());
31
         assertEquals("01:00", new Clock(25, 0).toString());
29
     }
32
     }
30
 
33
 
31
-    @Ignore
34
+    @Ignore("Remove to run test")
32
     @Test
35
     @Test
33
     public void hourRollsOverContinuously() {
36
     public void hourRollsOverContinuously() {
34
         assertEquals("04:00", new Clock(100, 0).toString());
37
         assertEquals("04:00", new Clock(100, 0).toString());
35
     }
38
     }
36
 
39
 
37
-    @Ignore
40
+    @Ignore("Remove to run test")
38
     @Test
41
     @Test
39
     public void sixtyMinutesIsNextHour() {
42
     public void sixtyMinutesIsNextHour() {
40
         assertEquals("02:00", new Clock(1, 60).toString());
43
         assertEquals("02:00", new Clock(1, 60).toString());
41
     }
44
     }
42
 
45
 
43
-    @Ignore
46
+    @Ignore("Remove to run test")
44
     @Test
47
     @Test
45
     public void minutesRollOver() {
48
     public void minutesRollOver() {
46
         assertEquals("02:40", new Clock(0, 160).toString());
49
         assertEquals("02:40", new Clock(0, 160).toString());
47
     }
50
     }
48
 
51
 
49
-    @Ignore
52
+    @Ignore("Remove to run test")
50
     @Test
53
     @Test
51
     public void minutesRollOverContinuously() {
54
     public void minutesRollOverContinuously() {
52
         assertEquals("04:43", new Clock(0, 1723).toString());
55
         assertEquals("04:43", new Clock(0, 1723).toString());
53
     }
56
     }
54
 
57
 
55
-    @Ignore
58
+    @Ignore("Remove to run test")
56
     @Test
59
     @Test
57
     public void hourAndMinutesRollOver() {
60
     public void hourAndMinutesRollOver() {
58
         assertEquals("03:40", new Clock(25, 160).toString());
61
         assertEquals("03:40", new Clock(25, 160).toString());
59
     }
62
     }
60
 
63
 
61
-    @Ignore
64
+    @Ignore("Remove to run test")
62
     @Test
65
     @Test
63
     public void hourAndMinutesRollOverContinuously() {
66
     public void hourAndMinutesRollOverContinuously() {
64
         assertEquals("11:01", new Clock(201, 3001).toString());
67
         assertEquals("11:01", new Clock(201, 3001).toString());
65
     }
68
     }
66
 
69
 
67
-    @Ignore
70
+    @Ignore("Remove to run test")
68
     @Test
71
     @Test
69
     public void hourAndMinutesRollOverToExactlyMidnight() {
72
     public void hourAndMinutesRollOverToExactlyMidnight() {
70
         assertEquals("00:00", new Clock(72, 8640).toString());
73
         assertEquals("00:00", new Clock(72, 8640).toString());
71
     }
74
     }
72
 
75
 
73
-    @Ignore
76
+    @Ignore("Remove to run test")
74
     @Test
77
     @Test
75
     public void negativeHour() {
78
     public void negativeHour() {
76
         assertEquals("23:15", new Clock(-1, 15).toString());
79
         assertEquals("23:15", new Clock(-1, 15).toString());
77
     }
80
     }
78
 
81
 
79
-    @Ignore
82
+    @Ignore("Remove to run test")
80
     @Test
83
     @Test
81
     public void negativeHourRollsOver() {
84
     public void negativeHourRollsOver() {
82
         assertEquals("23:00", new Clock(-25, 0).toString());
85
         assertEquals("23:00", new Clock(-25, 0).toString());
83
     }
86
     }
84
 
87
 
85
-    @Ignore
88
+    @Ignore("Remove to run test")
86
     @Test
89
     @Test
87
     public void negativeHourRollsOverContinuously() {
90
     public void negativeHourRollsOverContinuously() {
88
         assertEquals("05:00", new Clock(-91, 0).toString());
91
         assertEquals("05:00", new Clock(-91, 0).toString());
89
     }
92
     }
90
 
93
 
91
-    @Ignore
94
+    @Ignore("Remove to run test")
92
     @Test
95
     @Test
93
     public void negativeMinutes() {
96
     public void negativeMinutes() {
94
         assertEquals("00:20", new Clock(1, -40).toString());
97
         assertEquals("00:20", new Clock(1, -40).toString());
95
     }
98
     }
96
 
99
 
97
-    @Ignore
100
+    @Ignore("Remove to run test")
98
     @Test
101
     @Test
99
     public void negativeMinutesRollOver() {
102
     public void negativeMinutesRollOver() {
100
         assertEquals("22:20", new Clock(1, -160).toString());
103
         assertEquals("22:20", new Clock(1, -160).toString());
101
     }
104
     }
102
 
105
 
103
-    @Ignore
106
+    @Ignore("Remove to run test")
104
     @Test
107
     @Test
105
     public void negativeMinutesRollOverContinuously() {
108
     public void negativeMinutesRollOverContinuously() {
106
         assertEquals("16:40", new Clock(1, -4820).toString());
109
         assertEquals("16:40", new Clock(1, -4820).toString());
107
     }
110
     }
108
 
111
 
109
-    @Ignore
112
+    @Ignore("Remove to run test")
110
     @Test
113
     @Test
111
     public void negativeHourAndMinutesBothRollOver() {
114
     public void negativeHourAndMinutesBothRollOver() {
112
         assertEquals("20:20", new Clock(-25, -160).toString());
115
         assertEquals("20:20", new Clock(-25, -160).toString());
113
     }
116
     }
114
 
117
 
115
-    @Ignore
118
+    @Ignore("Remove to run test")
116
     @Test
119
     @Test
117
     public void negativeHourAndMinutesBothRollOverContinuously() {
120
     public void negativeHourAndMinutesBothRollOverContinuously() {
118
         assertEquals("22:10", new Clock(-121, -5810).toString());
121
         assertEquals("22:10", new Clock(-121, -5810).toString());

+ 36
- 32
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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'

+ 14
- 14
exercises/crypto-square/src/test/java/CryptoSquareTest.java Просмотреть файл

17
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
17
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
18
     }
18
     }
19
 
19
 
20
-    @Ignore
20
+    @Ignore("Remove to run test")
21
     @Test
21
     @Test
22
     public void lettersAreLowerCasedDuringNormalization() {
22
     public void lettersAreLowerCasedDuringNormalization() {
23
         Crypto crypto = new Crypto("WHOA HEY!");
23
         Crypto crypto = new Crypto("WHOA HEY!");
26
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
26
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
27
     }
27
     }
28
 
28
 
29
-    @Ignore
29
+    @Ignore("Remove to run test")
30
     @Test
30
     @Test
31
     public void numbersAreKeptDuringNormalization() {
31
     public void numbersAreKeptDuringNormalization() {
32
         Crypto crypto = new Crypto("1, 2, 3, GO!");
32
         Crypto crypto = new Crypto("1, 2, 3, GO!");
35
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
35
         assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
36
     }
36
     }
37
 
37
 
38
-    @Ignore
38
+    @Ignore("Remove to run test")
39
     @Test
39
     @Test
40
     public void smallestSquareSizeIs2() {
40
     public void smallestSquareSizeIs2() {
41
         Crypto crypto = new Crypto("1234");
41
         Crypto crypto = new Crypto("1234");
44
         assertEquals(expectedOutput, crypto.getSquareSize());
44
         assertEquals(expectedOutput, crypto.getSquareSize());
45
     }
45
     }
46
 
46
 
47
-    @Ignore
47
+    @Ignore("Remove to run test")
48
     @Test
48
     @Test
49
     public void sizeOfTextWhoseLengthIsPerfectSquareIsItsSquareRoot() {
49
     public void sizeOfTextWhoseLengthIsPerfectSquareIsItsSquareRoot() {
50
         Crypto crypto = new Crypto("123456789");
50
         Crypto crypto = new Crypto("123456789");
53
         assertEquals(expectedOutput, crypto.getSquareSize());
53
         assertEquals(expectedOutput, crypto.getSquareSize());
54
     }
54
     }
55
 
55
 
56
-    @Ignore
56
+    @Ignore("Remove to run test")
57
     @Test
57
     @Test
58
     public void sizeOfTextWhoseLengthIsNoPerfectSquareIsNextBiggestSquareRoot() {
58
     public void sizeOfTextWhoseLengthIsNoPerfectSquareIsNextBiggestSquareRoot() {
59
         Crypto crypto = new Crypto("123456789abc");
59
         Crypto crypto = new Crypto("123456789abc");
62
         assertEquals(expectedOutput, crypto.getSquareSize());
62
         assertEquals(expectedOutput, crypto.getSquareSize());
63
     }
63
     }
64
 
64
 
65
-    @Ignore
65
+    @Ignore("Remove to run test")
66
     @Test
66
     @Test
67
     public void sizeIsDeterminedByNormalizedText() {
67
     public void sizeIsDeterminedByNormalizedText() {
68
         Crypto crypto = new Crypto("Oh hey, this is nuts!");
68
         Crypto crypto = new Crypto("Oh hey, this is nuts!");
71
         assertEquals(expectedOutput, crypto.getSquareSize());
71
         assertEquals(expectedOutput, crypto.getSquareSize());
72
     }
72
     }
73
 
73
 
74
-    @Ignore
74
+    @Ignore("Remove to run test")
75
     @Test
75
     @Test
76
     public void segmentsAreSplitBySquareSize() {
76
     public void segmentsAreSplitBySquareSize() {
77
         Crypto crypto = new Crypto("Never vex thine heart with idle woes");
77
         Crypto crypto = new Crypto("Never vex thine heart with idle woes");
80
         assertEquals(expectedOutput, crypto.getPlaintextSegments());
80
         assertEquals(expectedOutput, crypto.getPlaintextSegments());
81
     }
81
     }
82
 
82
 
83
-    @Ignore
83
+    @Ignore("Remove to run test")
84
     @Test
84
     @Test
85
     public void segmentsAreSplitBySquareSizeUntilTextRunsOut() {
85
     public void segmentsAreSplitBySquareSizeUntilTextRunsOut() {
86
         Crypto crypto = new Crypto("ZOMG! ZOMBIES!!!");
86
         Crypto crypto = new Crypto("ZOMG! ZOMBIES!!!");
89
         assertEquals(expectedOutput, crypto.getPlaintextSegments());
89
         assertEquals(expectedOutput, crypto.getPlaintextSegments());
90
     }
90
     }
91
 
91
 
92
-    @Ignore
92
+    @Ignore("Remove to run test")
93
     @Test
93
     @Test
94
     public void cipherTextCombinesTextByColumn() {
94
     public void cipherTextCombinesTextByColumn() {
95
         Crypto crypto = new Crypto("First, solve the problem. Then, write the code.");
95
         Crypto crypto = new Crypto("First, solve the problem. Then, write the code.");
98
         assertEquals(expectedOutput, crypto.getCipherText());
98
         assertEquals(expectedOutput, crypto.getCipherText());
99
     }
99
     }
100
 
100
 
101
-    @Ignore
101
+    @Ignore("Remove to run test")
102
     @Test
102
     @Test
103
     public void cipherTextSkipsCellsWithNoText() {
103
     public void cipherTextSkipsCellsWithNoText() {
104
         Crypto crypto = new Crypto("Time is an illusion. Lunchtime doubly so.");
104
         Crypto crypto = new Crypto("Time is an illusion. Lunchtime doubly so.");
107
         assertEquals(expectedOutput, crypto.getCipherText());
107
         assertEquals(expectedOutput, crypto.getCipherText());
108
     }
108
     }
109
 
109
 
110
-    @Ignore
110
+    @Ignore("Remove to run test")
111
     @Test
111
     @Test
112
     public void normalizedCipherTextIsSplitByHeightOfSquare() {
112
     public void normalizedCipherTextIsSplitByHeightOfSquare() {
113
         Crypto crypto = new Crypto("Vampires are people too!");
113
         Crypto crypto = new Crypto("Vampires are people too!");
116
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
116
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
117
     }
117
     }
118
 
118
 
119
-    @Ignore
119
+    @Ignore("Remove to run test")
120
     @Test
120
     @Test
121
     public void normalizedCipherNotExactlyDivisibleBy5SpillsIntoSmallerSegment() {
121
     public void normalizedCipherNotExactlyDivisibleBy5SpillsIntoSmallerSegment() {
122
         Crypto crypto = new Crypto("Madness, and then illumination.");
122
         Crypto crypto = new Crypto("Madness, and then illumination.");
125
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
125
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
126
     }
126
     }
127
 
127
 
128
-    @Ignore
128
+    @Ignore("Remove to run test")
129
     @Test
129
     @Test
130
     public void normalizedCipherIsSplitIntoSegmentsOfCorrectSize() {
130
     public void normalizedCipherIsSplitIntoSegmentsOfCorrectSize() {
131
         Crypto crypto = new Crypto("If man was meant to stay on the ground god would have given us roots");
131
         Crypto crypto = new Crypto("If man was meant to stay on the ground god would have given us roots");
134
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
134
         assertEquals(expectedOutput, crypto.getNormalizedCipherText());
135
     }
135
     }
136
 
136
 
137
-    @Ignore
137
+    @Ignore("Remove to run test")
138
     @Test
138
     @Test
139
     public void normalizedCipherTextIsSplitIntoSegmentsOfCorrectSizeWithPunctuation() {
139
     public void normalizedCipherTextIsSplitIntoSegmentsOfCorrectSizeWithPunctuation() {
140
         Crypto crypto = new Crypto("Have a nice day. Feed the dog & chill out!");
140
         Crypto crypto = new Crypto("Have a nice day. Feed the dog & chill out!");

+ 36
- 36
exercises/custom-set/src/test/java/CustomSetTest.java Просмотреть файл

18
     }
18
     }
19
 
19
 
20
     @Test
20
     @Test
21
-    @Ignore
21
+    @Ignore("Remove to run test")
22
     public void setsWithElementsAreNotEmpty() {
22
     public void setsWithElementsAreNotEmpty() {
23
         final boolean actual
23
         final boolean actual
24
                 = new CustomSet<>(Arrays.asList(1))
24
                 = new CustomSet<>(Arrays.asList(1))
28
     }
28
     }
29
 
29
 
30
     @Test
30
     @Test
31
-    @Ignore
31
+    @Ignore("Remove to run test")
32
     public void nothingIsContainedInAnEmptySet() {
32
     public void nothingIsContainedInAnEmptySet() {
33
         final boolean actual
33
         final boolean actual
34
                 = new CustomSet<>(Collections.EMPTY_LIST)
34
                 = new CustomSet<>(Collections.EMPTY_LIST)
38
     }
38
     }
39
 
39
 
40
     @Test
40
     @Test
41
-    @Ignore
41
+    @Ignore("Remove to run test")
42
     public void whenTheElementIsInTheSet() {
42
     public void whenTheElementIsInTheSet() {
43
         final boolean actual
43
         final boolean actual
44
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
44
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
48
     }
48
     }
49
 
49
 
50
     @Test
50
     @Test
51
-    @Ignore
51
+    @Ignore("Remove to run test")
52
     public void whenTheElementIsNotInTheSet() {
52
     public void whenTheElementIsNotInTheSet() {
53
         final boolean actual
53
         final boolean actual
54
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
54
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
58
     }
58
     }
59
 
59
 
60
     @Test
60
     @Test
61
-    @Ignore
61
+    @Ignore("Remove to run test")
62
     public void emptySetIsASubsetOfAnotherEmptySet() {
62
     public void emptySetIsASubsetOfAnotherEmptySet() {
63
         final boolean actual
63
         final boolean actual
64
                 = new CustomSet<>(Collections.EMPTY_LIST)
64
                 = new CustomSet<>(Collections.EMPTY_LIST)
70
     }
70
     }
71
 
71
 
72
     @Test
72
     @Test
73
-    @Ignore
73
+    @Ignore("Remove to run test")
74
     public void emptySetIsASubsetOfNonEemptySet() {
74
     public void emptySetIsASubsetOfNonEemptySet() {
75
         final boolean actual
75
         final boolean actual
76
                 = new CustomSet<>(Arrays.asList(1))
76
                 = new CustomSet<>(Arrays.asList(1))
82
     }
82
     }
83
 
83
 
84
     @Test
84
     @Test
85
-    @Ignore
85
+    @Ignore("Remove to run test")
86
     public void nonEmptySetIsNotASubsetOfEmptySet() {
86
     public void nonEmptySetIsNotASubsetOfEmptySet() {
87
         final boolean actual
87
         final boolean actual
88
                 = new CustomSet<>(Collections.EMPTY_LIST)
88
                 = new CustomSet<>(Collections.EMPTY_LIST)
94
     }
94
     }
95
 
95
 
96
     @Test
96
     @Test
97
-    @Ignore
97
+    @Ignore("Remove to run test")
98
     public void setIsASubsetOfSetWithExactSameElements() {
98
     public void setIsASubsetOfSetWithExactSameElements() {
99
         final boolean actual
99
         final boolean actual
100
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
100
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
106
     }
106
     }
107
 
107
 
108
     @Test
108
     @Test
109
-    @Ignore
109
+    @Ignore("Remove to run test")
110
     public void setIsASubsetOfLargerSetWithSameElements() {
110
     public void setIsASubsetOfLargerSetWithSameElements() {
111
         final boolean actual
111
         final boolean actual
112
                 = new CustomSet<>(Arrays.asList(4, 1, 2, 3))
112
                 = new CustomSet<>(Arrays.asList(4, 1, 2, 3))
118
     }
118
     }
119
 
119
 
120
     @Test
120
     @Test
121
-    @Ignore
121
+    @Ignore("Remove to run test")
122
     public void setIsNotASubsetOfSetThatDoesNotContainItsElements() {
122
     public void setIsNotASubsetOfSetThatDoesNotContainItsElements() {
123
         final boolean actual
123
         final boolean actual
124
                 = new CustomSet<>(Arrays.asList(4, 1, 3))
124
                 = new CustomSet<>(Arrays.asList(4, 1, 3))
130
     }
130
     }
131
 
131
 
132
     @Test
132
     @Test
133
-    @Ignore
133
+    @Ignore("Remove to run test")
134
     public void theEmptySetIsDisjointWithItself() {
134
     public void theEmptySetIsDisjointWithItself() {
135
         final boolean actual
135
         final boolean actual
136
                 = new CustomSet<>(Collections.EMPTY_LIST)
136
                 = new CustomSet<>(Collections.EMPTY_LIST)
142
     }
142
     }
143
 
143
 
144
     @Test
144
     @Test
145
-    @Ignore
145
+    @Ignore("Remove to run test")
146
     public void emptySetIsDisjointWithNonEmptySet() {
146
     public void emptySetIsDisjointWithNonEmptySet() {
147
         final boolean actual
147
         final boolean actual
148
                 = new CustomSet<>(Collections.EMPTY_LIST)
148
                 = new CustomSet<>(Collections.EMPTY_LIST)
154
     }
154
     }
155
 
155
 
156
     @Test
156
     @Test
157
-    @Ignore
157
+    @Ignore("Remove to run test")
158
     public void nonEmptySetIsDisjointWithEmptySet() {
158
     public void nonEmptySetIsDisjointWithEmptySet() {
159
         final boolean actual
159
         final boolean actual
160
                 = new CustomSet<>(Arrays.asList(1))
160
                 = new CustomSet<>(Arrays.asList(1))
166
     }
166
     }
167
 
167
 
168
     @Test
168
     @Test
169
-    @Ignore
169
+    @Ignore("Remove to run test")
170
     public void setsAreNotDisjointIfTheyShareAnElement() {
170
     public void setsAreNotDisjointIfTheyShareAnElement() {
171
         final boolean actual
171
         final boolean actual
172
                 = new CustomSet<>(Arrays.asList(1, 2))
172
                 = new CustomSet<>(Arrays.asList(1, 2))
178
     }
178
     }
179
 
179
 
180
     @Test
180
     @Test
181
-    @Ignore
181
+    @Ignore("Remove to run test")
182
     public void setsAreDisjointIfTheyShareNoElements() {
182
     public void setsAreDisjointIfTheyShareNoElements() {
183
         final boolean actual
183
         final boolean actual
184
                 = new CustomSet<>(Arrays.asList(1, 2))
184
                 = new CustomSet<>(Arrays.asList(1, 2))
190
     }
190
     }
191
 
191
 
192
     @Test
192
     @Test
193
-    @Ignore
193
+    @Ignore("Remove to run test")
194
     public void emptySetsAreEqual() {
194
     public void emptySetsAreEqual() {
195
         final boolean actual
195
         final boolean actual
196
                 = new CustomSet<>(Collections.EMPTY_LIST)
196
                 = new CustomSet<>(Collections.EMPTY_LIST)
202
     }
202
     }
203
 
203
 
204
     @Test
204
     @Test
205
-    @Ignore
205
+    @Ignore("Remove to run test")
206
     public void emptySetIsNotEqualToNonEmptySet() {
206
     public void emptySetIsNotEqualToNonEmptySet() {
207
         final boolean actual
207
         final boolean actual
208
                 = new CustomSet<>(Collections.EMPTY_LIST)
208
                 = new CustomSet<>(Collections.EMPTY_LIST)
214
     }
214
     }
215
 
215
 
216
     @Test
216
     @Test
217
-    @Ignore
217
+    @Ignore("Remove to run test")
218
     public void nonEmptySetIsNotEqualToEmptySet() {
218
     public void nonEmptySetIsNotEqualToEmptySet() {
219
         final boolean actual
219
         final boolean actual
220
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
220
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
226
     }
226
     }
227
 
227
 
228
     @Test
228
     @Test
229
-    @Ignore
229
+    @Ignore("Remove to run test")
230
     public void setsWithTheSameElementsAreEqual() {
230
     public void setsWithTheSameElementsAreEqual() {
231
         final boolean actual
231
         final boolean actual
232
                 = new CustomSet<>(Arrays.asList(1, 2))
232
                 = new CustomSet<>(Arrays.asList(1, 2))
238
     }
238
     }
239
 
239
 
240
     @Test
240
     @Test
241
-    @Ignore
241
+    @Ignore("Remove to run test")
242
     public void setsWithDifferentElementsAreNotEqual() {
242
     public void setsWithDifferentElementsAreNotEqual() {
243
         final boolean actual
243
         final boolean actual
244
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
244
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
250
     }
250
     }
251
 
251
 
252
     @Test
252
     @Test
253
-    @Ignore
253
+    @Ignore("Remove to run test")
254
     public void addToEmptySet() {
254
     public void addToEmptySet() {
255
         final int element = 3;
255
         final int element = 3;
256
         final CustomSet<Integer> expected
256
         final CustomSet<Integer> expected
268
     }
268
     }
269
 
269
 
270
     @Test
270
     @Test
271
-    @Ignore
271
+    @Ignore("Remove to run test")
272
     public void addToNonEmptySet() {
272
     public void addToNonEmptySet() {
273
         final int element = 3;
273
         final int element = 3;
274
         final CustomSet<Integer> expected
274
         final CustomSet<Integer> expected
286
     }
286
     }
287
 
287
 
288
     @Test
288
     @Test
289
-    @Ignore
289
+    @Ignore("Remove to run test")
290
     public void addingAnExistingElementDoesNotChangeTheSet() {
290
     public void addingAnExistingElementDoesNotChangeTheSet() {
291
         final int element = 3;
291
         final int element = 3;
292
         final CustomSet<Integer> expected
292
         final CustomSet<Integer> expected
303
     }
303
     }
304
 
304
 
305
     @Test
305
     @Test
306
-    @Ignore
306
+    @Ignore("Remove to run test")
307
     public void intersectionOfTwoEmptySetsIsAnEmptySet() {
307
     public void intersectionOfTwoEmptySetsIsAnEmptySet() {
308
         final CustomSet<Integer> actual
308
         final CustomSet<Integer> actual
309
                 = new CustomSet<>(Collections.EMPTY_LIST)
309
                 = new CustomSet<>(Collections.EMPTY_LIST)
316
     }
316
     }
317
 
317
 
318
     @Test
318
     @Test
319
-    @Ignore
319
+    @Ignore("Remove to run test")
320
     public void intersectionOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
320
     public void intersectionOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
321
         final CustomSet<Integer> actual
321
         final CustomSet<Integer> actual
322
                 = new CustomSet<>(Collections.EMPTY_LIST)
322
                 = new CustomSet<>(Collections.EMPTY_LIST)
329
     }
329
     }
330
 
330
 
331
     @Test
331
     @Test
332
-    @Ignore
332
+    @Ignore("Remove to run test")
333
     public void intersectionOfANonEmptySetAndAnEmptySetIsAnEmptySet() {
333
     public void intersectionOfANonEmptySetAndAnEmptySetIsAnEmptySet() {
334
         final CustomSet<Integer> actual
334
         final CustomSet<Integer> actual
335
                 = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
335
                 = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
343
     }
343
     }
344
 
344
 
345
     @Test
345
     @Test
346
-    @Ignore
346
+    @Ignore("Remove to run test")
347
     public void intersectionOfTwoSetsWithNoSharedElementsIsAnEmptySet() {
347
     public void intersectionOfTwoSetsWithNoSharedElementsIsAnEmptySet() {
348
         final CustomSet<Integer> actual
348
         final CustomSet<Integer> actual
349
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
349
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
356
     }
356
     }
357
 
357
 
358
     @Test
358
     @Test
359
-    @Ignore
359
+    @Ignore("Remove to run test")
360
     public void intersectionOfTwoSetsWithSharedElementsIsASetOfTheSharedElements() {
360
     public void intersectionOfTwoSetsWithSharedElementsIsASetOfTheSharedElements() {
361
         final CustomSet<Integer> expected
361
         final CustomSet<Integer> expected
362
                 = new CustomSet<>(
362
                 = new CustomSet<>(
374
     }
374
     }
375
 
375
 
376
     @Test
376
     @Test
377
-    @Ignore
377
+    @Ignore("Remove to run test")
378
     public void differenceOfTwoEmptySetsIsAnEmptySet() {
378
     public void differenceOfTwoEmptySetsIsAnEmptySet() {
379
         final CustomSet<Integer> actual
379
         final CustomSet<Integer> actual
380
                 = new CustomSet<>(Collections.EMPTY_LIST)
380
                 = new CustomSet<>(Collections.EMPTY_LIST)
387
     }
387
     }
388
 
388
 
389
     @Test
389
     @Test
390
-    @Ignore
390
+    @Ignore("Remove to run test")
391
     public void differenceOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
391
     public void differenceOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
392
         final CustomSet<Integer> actual
392
         final CustomSet<Integer> actual
393
                 = new CustomSet<>(Collections.EMPTY_LIST)
393
                 = new CustomSet<>(Collections.EMPTY_LIST)
400
     }
400
     }
401
 
401
 
402
     @Test
402
     @Test
403
-    @Ignore
403
+    @Ignore("Remove to run test")
404
     public void differenceOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
404
     public void differenceOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
405
         final CustomSet<Integer> expected
405
         final CustomSet<Integer> expected
406
                 = new CustomSet<>(
406
                 = new CustomSet<>(
418
     }
418
     }
419
 
419
 
420
     @Test
420
     @Test
421
-    @Ignore
421
+    @Ignore("Remove to run test")
422
     public void differenceOfTwoNonEmptySetsIsASetOfElementsThatAreOnlyInTheFirstSet() {
422
     public void differenceOfTwoNonEmptySetsIsASetOfElementsThatAreOnlyInTheFirstSet() {
423
         final CustomSet<Integer> expected
423
         final CustomSet<Integer> expected
424
                 = new CustomSet<>(
424
                 = new CustomSet<>(
436
     }
436
     }
437
 
437
 
438
     @Test
438
     @Test
439
-    @Ignore
439
+    @Ignore("Remove to run test")
440
     public void unionOfTwoEmptySetsIsAnEmptySet() {
440
     public void unionOfTwoEmptySetsIsAnEmptySet() {
441
         final CustomSet<Integer> actual
441
         final CustomSet<Integer> actual
442
                 = new CustomSet<>(Collections.EMPTY_LIST)
442
                 = new CustomSet<>(Collections.EMPTY_LIST)
449
     }
449
     }
450
 
450
 
451
     @Test
451
     @Test
452
-    @Ignore
452
+    @Ignore("Remove to run test")
453
     public void unionOfAnEmptySetAndNonEmptySetIsTheNonEmptySet() {
453
     public void unionOfAnEmptySetAndNonEmptySetIsTheNonEmptySet() {
454
         final CustomSet<Integer> expected
454
         final CustomSet<Integer> expected
455
                 = new CustomSet<>(
455
                 = new CustomSet<>(
467
     }
467
     }
468
 
468
 
469
     @Test
469
     @Test
470
-    @Ignore
470
+    @Ignore("Remove to run test")
471
     public void unionOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
471
     public void unionOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
472
         final CustomSet<Integer> expected
472
         final CustomSet<Integer> expected
473
                 = new CustomSet<>(
473
                 = new CustomSet<>(
485
     }
485
     }
486
 
486
 
487
     @Test
487
     @Test
488
-    @Ignore
488
+    @Ignore("Remove to run test")
489
     public void unionOfTwoNonEmptySetsContainsAllUniqueElements() {
489
     public void unionOfTwoNonEmptySetsContainsAllUniqueElements() {
490
         final CustomSet<Integer> expected
490
         final CustomSet<Integer> expected
491
                 = new CustomSet<>(
491
                 = new CustomSet<>(

+ 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
 

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

1
 import org.junit.Ignore;
1
 import org.junit.Ignore;
2
+import org.junit.Before;
2
 import org.junit.Test;
3
 import org.junit.Test;
3
 
4
 
4
 import java.util.List;
5
 import java.util.List;
8
 import static org.hamcrest.CoreMatchers.is;
9
 import static org.hamcrest.CoreMatchers.is;
9
 import static org.junit.Assert.assertThat;
10
 import static org.junit.Assert.assertThat;
10
 
11
 
11
-public final class DiamondPrinterTest {
12
+/*
13
+ * version: 1.0.0
14
+ */
15
+public class DiamondPrinterTest {
16
+
17
+    private DiamondPrinter diamondPrinter;
18
+
19
+    @Before
20
+    public void setUp() {
21
+        diamondPrinter = new DiamondPrinter();
22
+    }
12
 
23
 
13
     @Test
24
     @Test
14
     public void testOneByOneDiamond() {
25
     public void testOneByOneDiamond() {
15
-        List<String> output = new DiamondPrinter().printToList('A');
26
+        List<String> output = diamondPrinter.printToList('A');
16
         assertThat(output, is(singletonList("A")));
27
         assertThat(output, is(singletonList("A")));
17
     }
28
     }
18
 
29
 
19
-    @Ignore
30
+    @Ignore("Remove to run test")
20
     @Test
31
     @Test
21
     public void testTwoByTwoDiamond() {
32
     public void testTwoByTwoDiamond() {
22
-        List<String> output = new DiamondPrinter().printToList('B');
33
+        List<String> output = diamondPrinter.printToList('B');
23
         assertThat(output, is(asList(" A ",
34
         assertThat(output, is(asList(" A ",
24
                                      "B B",
35
                                      "B B",
25
                                      " A ")));
36
                                      " A ")));
26
     }
37
     }
27
 
38
 
28
-    @Ignore
39
+    @Ignore("Remove to run test")
29
     @Test
40
     @Test
30
     public void testThreeByThreeDiamond() {
41
     public void testThreeByThreeDiamond() {
31
-        List<String> output = new DiamondPrinter().printToList('C');
42
+        List<String> output = diamondPrinter.printToList('C');
32
         assertThat(output, is(asList("  A  ",
43
         assertThat(output, is(asList("  A  ",
33
                                      " B B ",
44
                                      " B B ",
34
                                      "C   C",
45
                                      "C   C",
36
                                      "  A  ")));
47
                                      "  A  ")));
37
     }
48
     }
38
 
49
 
39
-    @Ignore
50
+    @Ignore("Remove to run test")
40
     @Test
51
     @Test
41
     public void testFiveByFiveDiamond() {
52
     public void testFiveByFiveDiamond() {
42
-        List<String> output = new DiamondPrinter().printToList('E');
53
+        List<String> output = diamondPrinter.printToList('E');
43
         assertThat(output, is(asList("    A    ",
54
         assertThat(output, is(asList("    A    ",
44
                                      "   B B   ",
55
                                      "   B B   ",
45
                                      "  C   C  ",
56
                                      "  C   C  ",
51
                                      "    A    ")));
62
                                      "    A    ")));
52
     }
63
     }
53
 
64
 
54
-    @Ignore
65
+    @Ignore("Remove to run test")
55
     @Test
66
     @Test
56
     public void testFullDiamond() {
67
     public void testFullDiamond() {
57
-        List<String> output = new DiamondPrinter().printToList('Z');
68
+        List<String> output = diamondPrinter.printToList('Z');
58
         assertThat(output, is(asList("                         A                         ",
69
         assertThat(output, is(asList("                         A                         ",
59
                                      "                        B B                        ",
70
                                      "                        B B                        ",
60
                                      "                       C   C                       ",
71
                                      "                       C   C                       ",

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

exercises/difference-of-squares/src/example/java/Difference.java → exercises/difference-of-squares/src/example/java/DifferenceOfSquaresCalculator.java Просмотреть файл

1
 import java.util.stream.IntStream;
1
 import java.util.stream.IntStream;
2
 
2
 
3
-public final class Difference {
3
+final class DifferenceOfSquaresCalculator {
4
 
4
 
5
-    public static int computeSquareOfSumTo(final int input) {
5
+    int computeSquareOfSumTo(final int input) {
6
         final int sum = input * (input + 1) / 2;
6
         final int sum = input * (input + 1) / 2;
7
         return (int) Math.pow(sum, 2);
7
         return (int) Math.pow(sum, 2);
8
     }
8
     }
9
 
9
 
10
-    public static int computeSumOfSquaresTo(final int input) {
10
+    int computeSumOfSquaresTo(final int input) {
11
         return IntStream.rangeClosed(1, input)
11
         return IntStream.rangeClosed(1, input)
12
                 .map(i -> (int) Math.pow(i, 2))
12
                 .map(i -> (int) Math.pow(i, 2))
13
                 .sum();
13
                 .sum();
14
     }
14
     }
15
 
15
 
16
-    public static int betweenSquareOfSumAndSumOfSquaresTo(final int input) {
16
+    int computeDifferenceOfSquares(final int input) {
17
         return computeSquareOfSumTo(input) - computeSumOfSquaresTo(input);
17
         return computeSquareOfSumTo(input) - computeSumOfSquaresTo(input);
18
     }
18
     }
19
 
19
 

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


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

1
-public final class Difference {
2
-    
3
-
4
-
5
-}

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

1
+import org.junit.Before;
2
+import org.junit.Ignore;
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.assertEquals;
6
+
7
+/*
8
+ * version: 1.1.0
9
+ */
10
+public class DifferenceOfSquaresCalculatorTest {
11
+
12
+    private DifferenceOfSquaresCalculator calculator;
13
+
14
+    @Before
15
+    public void setUp() {
16
+        calculator = new DifferenceOfSquaresCalculator();
17
+    }
18
+
19
+    @Test
20
+    public void testSquareOfSum1() {
21
+        final int expected = 1;
22
+        final int actual = calculator.computeSquareOfSumTo(1);
23
+        assertEquals(expected, actual);
24
+    }
25
+
26
+    @Ignore("Remove to run test")
27
+    @Test
28
+    public void testSquareOfSum5() {
29
+        final int expected = 225;
30
+        final int actual = calculator.computeSquareOfSumTo(5);
31
+        assertEquals(expected, actual);
32
+    }
33
+
34
+    @Ignore("Remove to run test")
35
+    @Test
36
+    public void testSquareOfSum100() {
37
+        final int expected = 25502500;
38
+        final int actual = calculator.computeSquareOfSumTo(100);
39
+        assertEquals(expected, actual);
40
+    }
41
+
42
+    @Ignore("Remove to run test")
43
+    @Test
44
+    public void testSumOfSquares1() {
45
+        final int expected = 1;
46
+        final int actual = calculator.computeSumOfSquaresTo(1);
47
+        assertEquals(expected, actual);
48
+    }
49
+
50
+    @Ignore("Remove to run test")
51
+    @Test
52
+    public void testSumOfSquares5() {
53
+        final int expected = 55;
54
+        final int actual = calculator.computeSumOfSquaresTo(5);
55
+        assertEquals(expected, actual);
56
+    }
57
+
58
+    @Ignore("Remove to run test")
59
+    @Test
60
+    public void testSumOfSquares100() {
61
+        final int expected = 338350;
62
+        final int actual = calculator.computeSumOfSquaresTo(100);
63
+        assertEquals(expected, actual);
64
+    }
65
+
66
+    @Ignore("Remove to run test")
67
+    @Test
68
+    public void testDifferenceOfSquares1() {
69
+        final int expected = 0;
70
+        final int actual = calculator.computeDifferenceOfSquares(1);
71
+        assertEquals(expected, actual);
72
+    }
73
+
74
+    @Ignore("Remove to run test")
75
+    @Test
76
+    public void testDifferenceOfSquares5() {
77
+        final int expected = 170;
78
+        final int actual = calculator.computeDifferenceOfSquares(5);
79
+        assertEquals(expected, actual);
80
+    }
81
+
82
+    @Ignore("Remove to run test")
83
+    @Test
84
+    public void testDifferenceOfSquares100() {
85
+        final int expected = 25164150;
86
+        final int actual = calculator.computeDifferenceOfSquares(100);
87
+        assertEquals(expected, actual);
88
+    }
89
+
90
+}

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

1
-import org.junit.Ignore;
2
-import org.junit.Test;
3
-
4
-import static org.junit.Assert.assertEquals;
5
-
6
-public final class DifferenceTest {
7
-
8
-    @Test
9
-    public void testSquareOfSum5() {
10
-        final int expected = 225;
11
-        final int actual = Difference.computeSquareOfSumTo(5);
12
-        assertEquals(expected, actual);
13
-    }
14
-
15
-    @Ignore
16
-    @Test
17
-    public void testSquareOfSum10() {
18
-        final int expected = 3025;
19
-        final int actual = Difference.computeSquareOfSumTo(10);
20
-        assertEquals(expected, actual);
21
-    }
22
-
23
-    @Ignore
24
-    @Test
25
-    public void testSquareOfSum100() {
26
-        final int expected = 25502500;
27
-        final int actual = Difference.computeSquareOfSumTo(100);
28
-        assertEquals(expected, actual);
29
-    }
30
-
31
-    @Ignore
32
-    @Test
33
-    public void testSumOfSquares5() {
34
-        final int expected = 55;
35
-        final int actual = Difference.computeSumOfSquaresTo(5);
36
-        assertEquals(expected, actual);
37
-    }
38
-
39
-    @Ignore
40
-    @Test
41
-    public void testSumOfSquares10() {
42
-        final int expected = 385;
43
-        final int actual = Difference.computeSumOfSquaresTo(10);
44
-        assertEquals(expected, actual);
45
-    }
46
-
47
-    @Ignore
48
-    @Test
49
-    public void testSumOfSquares100() {
50
-        final int expected = 338350;
51
-        final int actual = Difference.computeSumOfSquaresTo(100);
52
-        assertEquals(expected, actual);
53
-    }
54
-
55
-    @Ignore
56
-    @Test
57
-    public void testDifferenceOfSquares0() {
58
-        final int expected = 0;
59
-        final int actual = Difference.betweenSquareOfSumAndSumOfSquaresTo(0);
60
-        assertEquals(expected, actual);
61
-    }
62
-
63
-    @Ignore
64
-    @Test
65
-    public void testDifferenceOfSquares5() {
66
-        final int expected = 170;
67
-        final int actual = Difference.betweenSquareOfSumAndSumOfSquaresTo(5);
68
-        assertEquals(expected, actual);
69
-    }
70
-
71
-    @Ignore
72
-    @Test
73
-    public void testDifferenceOfSquares10() {
74
-        final int expected = 2640;
75
-        final int actual = Difference.betweenSquareOfSumAndSumOfSquaresTo(10);
76
-        assertEquals(expected, actual);
77
-    }
78
-
79
-    @Ignore
80
-    @Test
81
-    public void testDifferenceOfSquares100() {
82
-        final int expected = 25164150;
83
-        final int actual = Difference.betweenSquareOfSumAndSumOfSquaresTo(100);
84
-        assertEquals(expected, actual);
85
-    }
86
-
87
-}

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

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

28
         assertEquals(expected, etl.transform(old));
28
         assertEquals(expected, etl.transform(old));
29
     }
29
     }
30
 
30
 
31
-    @Ignore
31
+    @Ignore("Remove to run test")
32
     @Test
32
     @Test
33
     public void testTransformMoreValues() {
33
     public void testTransformMoreValues() {
34
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
34
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
52
         assertEquals(expected, etl.transform(old));
52
         assertEquals(expected, etl.transform(old));
53
     }
53
     }
54
 
54
 
55
-    @Ignore
55
+    @Ignore("Remove to run test")
56
     @Test
56
     @Test
57
     public void testMoreKeys() {
57
     public void testMoreKeys() {
58
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
58
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
76
         assertEquals(expected, etl.transform(old));
76
         assertEquals(expected, etl.transform(old));
77
     }
77
     }
78
 
78
 
79
-    @Ignore
79
+    @Ignore("Remove to run test")
80
     @Test
80
     @Test
81
     public void testFullDataset() {
81
     public void testFullDataset() {
82
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
82
         Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {

+ 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
 

+ 20
- 5
exercises/flatten-array/src/test/java/FlattenerTest.java Просмотреть файл

7
 import static java.util.Collections.singletonList;
7
 import static java.util.Collections.singletonList;
8
 import static org.junit.Assert.assertEquals;
8
 import static org.junit.Assert.assertEquals;
9
 
9
 
10
-public final class FlattenerTest {
10
+/*
11
+ * version: 1.1.0
12
+ */
13
+public class FlattenerTest {
11
 
14
 
12
     private Flattener flattener;
15
     private Flattener flattener;
13
 
16
 
17
     }
20
     }
18
 
21
 
19
     @Test
22
     @Test
23
+    public void testFlatListIsPreserved() {
24
+        assertEquals(
25
+          asList(0, '1', "two"),
26
+            flattener.flatten(
27
+              asList(
28
+                0,
29
+                '1',
30
+                "two")));
31
+    }
32
+
33
+    @Ignore("Remove to run test")
34
+    @Test
20
     public void testASingleLevelOfNestingWithNoNulls() {
35
     public void testASingleLevelOfNestingWithNoNulls() {
21
         assertEquals(
36
         assertEquals(
22
           asList(1, '2', 3, 4, 5, "six", "7", 8),
37
           asList(1, '2', 3, 4, 5, "six", "7", 8),
33
               8)));
48
               8)));
34
     }
49
     }
35
 
50
 
36
-    @Ignore
51
+    @Ignore("Remove to run test")
37
     @Test
52
     @Test
38
     public void testFiveLevelsOfNestingWithNoNulls() {
53
     public void testFiveLevelsOfNestingWithNoNulls() {
39
         assertEquals(
54
         assertEquals(
56
               "-2")));
71
               "-2")));
57
     }
72
     }
58
 
73
 
59
-    @Ignore
74
+    @Ignore("Remove to run test")
60
     @Test
75
     @Test
61
     public void testSixLevelsOfNestingWithNoNulls() {
76
     public void testSixLevelsOfNestingWithNoNulls() {
62
         assertEquals(
77
         assertEquals(
79
               "8")));
94
               "8")));
80
     }
95
     }
81
 
96
 
82
-    @Ignore
97
+    @Ignore("Remove to run test")
83
     @Test
98
     @Test
84
     public void testSixLevelsOfNestingWithNulls() {
99
     public void testSixLevelsOfNestingWithNulls() {
85
         assertEquals(
100
         assertEquals(
103
               "negative two")));
118
               "negative two")));
104
     }
119
     }
105
 
120
 
106
-    @Ignore
121
+    @Ignore("Remove to run test")
107
     @Test
122
     @Test
108
     public void testNestedListsFullOfNullsOnly() {
123
     public void testNestedListsFullOfNullsOnly() {
109
         assertEquals(
124
         assertEquals(

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

+ 7
- 6
exercises/gigasecond/src/example/java/Gigasecond.java Просмотреть файл

1
 import java.time.LocalDateTime;
1
 import java.time.LocalDateTime;
2
 import java.time.LocalDate;
2
 import java.time.LocalDate;
3
 
3
 
4
-public class Gigasecond {
4
+class Gigasecond {
5
 
5
 
6
     private LocalDateTime birthDateTime;
6
     private LocalDateTime birthDateTime;
7
 
7
 
8
-    public Gigasecond(LocalDateTime birthDateTime) {
9
-        this.birthDateTime = birthDateTime;
8
+    Gigasecond(LocalDate birthDate) {
9
+        this.birthDateTime = birthDate.atTime(0, 0);
10
     }
10
     }
11
 
11
 
12
-    public Gigasecond(LocalDate birthDate) {
13
-        this.birthDateTime = birthDate.atTime(0, 0);
12
+    Gigasecond(LocalDateTime birthDateTime) {
13
+        this.birthDateTime = birthDateTime;
14
     }
14
     }
15
 
15
 
16
-    public LocalDateTime getDate() {
16
+    LocalDateTime getDate() {
17
         return birthDateTime.plusSeconds(1000000000);
17
         return birthDateTime.plusSeconds(1000000000);
18
     }
18
     }
19
+
19
 }
20
 }

+ 18
- 0
exercises/gigasecond/src/main/java/Gigasecond.java Просмотреть файл

1
+import java.time.LocalDate;
2
+import java.time.LocalDateTime;
3
+
4
+class Gigasecond {
5
+
6
+    Gigasecond(LocalDate birthDate) {
7
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
8
+    }
9
+
10
+    Gigasecond(LocalDateTime birthDateTime) {
11
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
12
+    }
13
+
14
+    LocalDateTime getDate() {
15
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
16
+    }
17
+
18
+}

+ 4
- 5
exercises/gigasecond/src/test/java/GigasecondTest.java Просмотреть файл

9
 
9
 
10
 public class GigasecondTest {
10
 public class GigasecondTest {
11
 
11
 
12
-
13
     @Test
12
     @Test
14
     public void modernTime() {
13
     public void modernTime() {
15
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25));
14
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25));
17
         assertEquals(LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40), gigaSecond.getDate());
16
         assertEquals(LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40), gigaSecond.getDate());
18
     }
17
     }
19
 
18
 
20
-    @Ignore
19
+    @Ignore("Remove to run test")
21
     @Test
20
     @Test
22
     public void afterEpochTime() {
21
     public void afterEpochTime() {
23
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13));
22
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13));
25
         assertEquals(LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40), gigaSecond.getDate());
24
         assertEquals(LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40), gigaSecond.getDate());
26
     }
25
     }
27
 
26
 
28
-    @Ignore
27
+    @Ignore("Remove to run test")
29
     @Test
28
     @Test
30
     public void beforeEpochTime() {
29
     public void beforeEpochTime() {
31
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19));
30
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19));
33
         assertEquals(LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40), gigaSecond.getDate());
32
         assertEquals(LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40), gigaSecond.getDate());
34
     }
33
     }
35
 
34
 
36
-    @Ignore
35
+    @Ignore("Remove to run test")
37
     @Test
36
     @Test
38
     public void withFullTimeSpecified() {
37
     public void withFullTimeSpecified() {
39
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0));
38
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0));
41
         assertEquals(LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40), gigaSecond.getDate());
40
         assertEquals(LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40), gigaSecond.getDate());
42
     }
41
     }
43
 
42
 
44
-    @Ignore
43
+    @Ignore("Remove to run test")
45
     @Test
44
     @Test
46
     public void withFullTimeSpecifiedAndDayRollover() {
45
     public void withFullTimeSpecifiedAndDayRollover() {
47
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59));
46
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59));

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

+ 15
- 9
exercises/grade-school/src/test/java/SchoolTest.java Просмотреть файл

1
+import org.junit.Before;
1
 import org.junit.Ignore;
2
 import org.junit.Ignore;
2
 import org.junit.Test;
3
 import org.junit.Test;
3
 
4
 
15
 import static org.junit.Assert.assertEquals;
16
 import static org.junit.Assert.assertEquals;
16
 
17
 
17
 public class SchoolTest {
18
 public class SchoolTest {
18
-  private final School school = new School();
19
+  private School school;
20
+
21
+  @Before
22
+  public void setUp() {
23
+    school = new School();
24
+  }
19
 
25
 
20
   @Test
26
   @Test
21
   public void startsWithNoStudents() {
27
   public void startsWithNoStudents() {
22
     assertThat(school.numberOfStudents(), is(0));
28
     assertThat(school.numberOfStudents(), is(0));
23
   }
29
   }
24
 
30
 
25
-  @Ignore
31
+  @Ignore("Remove to run test")
26
   @Test
32
   @Test
27
   public void addsStudents() {
33
   public void addsStudents() {
28
     school.add("Aimee", 2);
34
     school.add("Aimee", 2);
29
     assertThat(school.grade(2), hasItem("Aimee"));
35
     assertThat(school.grade(2), hasItem("Aimee"));
30
   }
36
   }
31
 
37
 
32
-  @Ignore
38
+  @Ignore("Remove to run test")
33
   @Test
39
   @Test
34
   public void addsMoreStudentsInSameGrade() {
40
   public void addsMoreStudentsInSameGrade() {
35
     final int grade = 2;
41
     final int grade = 2;
41
     assertThat(school.grade(grade), allOf(hasItem("James"), hasItem("Blair"), hasItem("Paul")));
47
     assertThat(school.grade(grade), allOf(hasItem("James"), hasItem("Blair"), hasItem("Paul")));
42
   }
48
   }
43
 
49
 
44
-  @Ignore
50
+  @Ignore("Remove to run test")
45
   @Test
51
   @Test
46
   public void addsStudentsInMultipleGrades() {
52
   public void addsStudentsInMultipleGrades() {
47
     school.add("Chelsea", 3);
53
     school.add("Chelsea", 3);
54
     assertThat(school.grade(7), hasItem("Logan"));
60
     assertThat(school.grade(7), hasItem("Logan"));
55
   }
61
   }
56
 
62
 
57
-  @Ignore
63
+  @Ignore("Remove to run test")
58
   @Test
64
   @Test
59
   public void getsStudentsInEmptyGrade() {
65
   public void getsStudentsInEmptyGrade() {
60
     assertTrue(school.grade(1).isEmpty());
66
     assertTrue(school.grade(1).isEmpty());
61
   }
67
   }
62
 
68
 
63
-  @Ignore
69
+  @Ignore("Remove to run test")
64
   @Test
70
   @Test
65
   public void sortsSchool() {
71
   public void sortsSchool() {
66
     school.add("Kyle", 4);
72
     school.add("Kyle", 4);
85
     }
91
     }
86
   }
92
   }
87
 
93
 
88
-  @Ignore
94
+  @Ignore("Remove to run test")
89
   @Test
95
   @Test
90
   public void modifyingFetchedGradeShouldNotModifyInternalDatabase() {
96
   public void modifyingFetchedGradeShouldNotModifyInternalDatabase() {
91
     String shouldNotBeAdded = "Should not be added to school";
97
     String shouldNotBeAdded = "Should not be added to school";
103
     assertThat(school.grade(grade), not(hasItem(shouldNotBeAdded)));
109
     assertThat(school.grade(grade), not(hasItem(shouldNotBeAdded)));
104
   }
110
   }
105
 
111
 
106
-  @Ignore
112
+  @Ignore("Remove to run test")
107
   @Test
113
   @Test
108
   public void modifyingSortedStudentsShouldNotModifyInternalDatabase() {
114
   public void modifyingSortedStudentsShouldNotModifyInternalDatabase() {
109
     int grade = 2;
115
     int grade = 2;
120
       // Such as UnsupportedOperationException when an unmodifiableMap is used
126
       // Such as UnsupportedOperationException when an unmodifiableMap is used
121
     }
127
     }
122
 
128
 
123
-    assertThat(school.studentsByGradeAlphabetical().get(grade), 
129
+    assertThat(school.studentsByGradeAlphabetical().get(grade),
124
       not(hasItem(studentWhichShouldNotBeAdded)));
130
       not(hasItem(studentWhichShouldNotBeAdded)));
125
   }
131
   }
126
 }
132
 }

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

+ 11
- 2
exercises/hamming/src/example/java/Hamming.java Просмотреть файл

1
 public class Hamming {
1
 public class Hamming {
2
+    private final int hammingDistance;
2
 
3
 
3
-    public static int compute(String leftStrand, String rightStrand) {
4
+    public Hamming(String leftStrand, String rightStrand) {
5
+        hammingDistance = computeHammingDistance(leftStrand, rightStrand);
6
+    }
7
+
8
+    public int getHammingDistance() {
9
+        return hammingDistance;
10
+    }
11
+
12
+    private int computeHammingDistance(String leftStrand, String rightStrand) {
4
         if(leftStrand.length() != rightStrand.length()) {
13
         if(leftStrand.length() != rightStrand.length()) {
5
             throw new IllegalArgumentException("leftStrand and rightStrand must be of equal length.");
14
             throw new IllegalArgumentException("leftStrand and rightStrand must be of equal length.");
6
         }
15
         }
13
         return distance;
22
         return distance;
14
     }
23
     }
15
 
24
 
16
-    private static int hammingContributionAt(int index, String leftStrand, String rightStrand) {
25
+    private int hammingContributionAt(int index, String leftStrand, String rightStrand) {
17
       return leftStrand.charAt(index) != rightStrand.charAt(index) ? 1 : 0;
26
       return leftStrand.charAt(index) != rightStrand.charAt(index) ? 1 : 0;
18
     }
27
     }
19
 
28
 

+ 9
- 0
exercises/hamming/src/main/java/Hamming.java Просмотреть файл

1
 public class Hamming {
1
 public class Hamming {
2
+
3
+    Hamming(String leftStrand, String rightStrand) {
4
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+    }
6
+
7
+    int getHammingDistance() {
8
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9
+    }
10
+
2
 }
11
 }

+ 17
- 18
exercises/hamming/src/test/java/HammingTest.java Просмотреть файл

7
 import org.junit.rules.ExpectedException;
7
 import org.junit.rules.ExpectedException;
8
 
8
 
9
 public class HammingTest {
9
 public class HammingTest {
10
-    
11
 
10
 
12
     @Rule
11
     @Rule
13
     public ExpectedException thrown = ExpectedException.none();
12
     public ExpectedException thrown = ExpectedException.none();
14
     
13
     
15
     @Test
14
     @Test
16
     public void testNoDifferenceBetweenIdenticalStrands() {
15
     public void testNoDifferenceBetweenIdenticalStrands() {
17
-        assertThat(Hamming.compute("A", "A"), is(0));
16
+        assertThat(new Hamming("A", "A").getHammingDistance(), is(0));
18
     }
17
     }
19
 
18
 
20
-    @Ignore
19
+    @Ignore("Remove to run test")
21
     @Test
20
     @Test
22
     public void testHammingDistanceForSingleNucleotideStrand() {
21
     public void testHammingDistanceForSingleNucleotideStrand() {
23
-        assertThat(Hamming.compute("A", "G"), is(1));
22
+        assertThat(new Hamming("A", "G").getHammingDistance(), is(1));
24
     }
23
     }
25
 
24
 
26
-    @Ignore
25
+    @Ignore("Remove to run test")
27
     @Test
26
     @Test
28
     public void testHammingDistanceForSmallStrand() {
27
     public void testHammingDistanceForSmallStrand() {
29
-        assertThat(Hamming.compute("AG", "CT"), is(2)); 
28
+        assertThat(new Hamming("AG", "CT").getHammingDistance(), is(2));
30
     }
29
     }
31
 
30
 
32
-    @Ignore
31
+    @Ignore("Remove to run test")
33
     @Test
32
     @Test
34
     public void testSmallHammingDistance() {
33
     public void testSmallHammingDistance() {
35
-        assertThat(Hamming.compute("AT", "CT"), is(1));
34
+        assertThat(new Hamming("AT", "CT").getHammingDistance(), is(1));
36
     }
35
     }
37
 
36
 
38
-    @Ignore
37
+    @Ignore("Remove to run test")
39
     @Test
38
     @Test
40
     public void testSmallHammingDistanceInLongerStrand() {
39
     public void testSmallHammingDistanceInLongerStrand() {
41
-        assertThat(Hamming.compute("GGACG", "GGTCG"), is(1));
40
+        assertThat(new Hamming("GGACG", "GGTCG").getHammingDistance(), is(1));
42
     }
41
     }
43
 
42
 
44
-    @Ignore
43
+    @Ignore("Remove to run test")
45
     @Test
44
     @Test
46
     public void testValidatesFirstStrandNotLonger() {
45
     public void testValidatesFirstStrandNotLonger() {
47
         thrown.expect(IllegalArgumentException.class);
46
         thrown.expect(IllegalArgumentException.class);
48
-        Hamming.compute("AAAG", "AAA");                
47
+        new Hamming("AAAG", "AAA");
49
     }
48
     }
50
 
49
 
51
-    @Ignore
50
+    @Ignore("Remove to run test")
52
     @Test
51
     @Test
53
     public void testValidatesOtherStrandNotLonger() {
52
     public void testValidatesOtherStrandNotLonger() {
54
         thrown.expect(IllegalArgumentException.class);
53
         thrown.expect(IllegalArgumentException.class);
55
-        Hamming.compute("AAA", "AAAG");
54
+        new Hamming("AAA", "AAAG");
56
     }
55
     }
57
 
56
 
58
-    @Ignore
57
+    @Ignore("Remove to run test")
59
     @Test
58
     @Test
60
     public void testLargeHammingDistance() {
59
     public void testLargeHammingDistance() {
61
-        assertThat(Hamming.compute("GATACA", "GCATAA"), is(4));
60
+        assertThat(new Hamming("GATACA", "GCATAA").getHammingDistance(), is(4));
62
     }
61
     }
63
 
62
 
64
-    @Ignore
63
+    @Ignore("Remove to run test")
65
     @Test
64
     @Test
66
     public void testHammingDistanceInVeryLongStrand() {
65
     public void testHammingDistanceInVeryLongStrand() {
67
-        assertThat(Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT"), is(9));
66
+        assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance(), is(9));
68
     }
67
     }
69
 
68
 
70
 }
69
 }

+ 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, remove the `@Ignore` from the next test, and iterate on your solution,
27
 After your first test passes, remove the `@Ignore` from the next test, and iterate on your solution,

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


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