diff --git a/annalyns-infiltration/.exercism/config.json b/annalyns-infiltration/.exercism/config.json new file mode 100644 index 0000000..d58dd07 --- /dev/null +++ b/annalyns-infiltration/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "mikedamay" + ], + "files": { + "solution": [ + "src/main/java/AnnalynsInfiltration.java" + ], + "test": [ + "src/test/java/AnnalynsInfiltrationTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/AnnalynsInfiltration.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/annalyns-infiltration" + ], + "blurb": "Learn about booleans while helping Annalyn rescue her friend." +} diff --git a/annalyns-infiltration/.exercism/metadata.json b/annalyns-infiltration/.exercism/metadata.json new file mode 100644 index 0000000..305928d --- /dev/null +++ b/annalyns-infiltration/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"annalyns-infiltration","id":"5ffc5d6dd6bd40f69606aa8c183c0b8d","url":"https://exercism.org/tracks/java/exercises/annalyns-infiltration","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/annalyns-infiltration/.gradle/7.5.1/checksums/checksums.lock b/annalyns-infiltration/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..72d167f Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/annalyns-infiltration/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/annalyns-infiltration/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..ebc8a58 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/annalyns-infiltration/.gradle/7.5.1/dependencies-accessors/gc.properties b/annalyns-infiltration/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.bin b/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..cf771ef Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.lock b/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..472f9e9 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/annalyns-infiltration/.gradle/7.5.1/fileChanges/last-build.bin b/annalyns-infiltration/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.bin b/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..fa16b17 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.lock b/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..5280fe0 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/annalyns-infiltration/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/annalyns-infiltration/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..b286510 Binary files /dev/null and b/annalyns-infiltration/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/annalyns-infiltration/.gradle/7.5.1/gc.properties b/annalyns-infiltration/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/annalyns-infiltration/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/annalyns-infiltration/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..d7f31f9 Binary files /dev/null and b/annalyns-infiltration/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/annalyns-infiltration/.gradle/buildOutputCleanup/cache.properties b/annalyns-infiltration/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..f01ad93 --- /dev/null +++ b/annalyns-infiltration/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 17:34:54 CET 2023 +gradle.version=7.5.1 diff --git a/annalyns-infiltration/.gradle/buildOutputCleanup/outputFiles.bin b/annalyns-infiltration/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..4a7ead5 Binary files /dev/null and b/annalyns-infiltration/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/annalyns-infiltration/.gradle/file-system.probe b/annalyns-infiltration/.gradle/file-system.probe new file mode 100644 index 0000000..0bc80ca Binary files /dev/null and b/annalyns-infiltration/.gradle/file-system.probe differ diff --git a/annalyns-infiltration/.gradle/vcs-1/gc.properties b/annalyns-infiltration/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/annalyns-infiltration/.idea/.gitignore b/annalyns-infiltration/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/annalyns-infiltration/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/annalyns-infiltration/.idea/compiler.xml b/annalyns-infiltration/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/annalyns-infiltration/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/annalyns-infiltration/.idea/gradle.xml b/annalyns-infiltration/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/annalyns-infiltration/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/annalyns-infiltration/.idea/jarRepositories.xml b/annalyns-infiltration/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/annalyns-infiltration/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/annalyns-infiltration/.idea/misc.xml b/annalyns-infiltration/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/annalyns-infiltration/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/annalyns-infiltration/HELP.md b/annalyns-infiltration/HELP.md new file mode 100644 index 0000000..ba3a35d --- /dev/null +++ b/annalyns-infiltration/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/AnnalynsInfiltration.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/annalyns-infiltration/HINTS.md b/annalyns-infiltration/HINTS.md new file mode 100644 index 0000000..24ca47d --- /dev/null +++ b/annalyns-infiltration/HINTS.md @@ -0,0 +1,12 @@ +# Hints + +## General + +- There are three [boolean operators][operators] to work with boolean values. +- Multiple operators can be combined in a single expression. + +## 1. Check if a fast attack can be made + +- The [boolean operators][operators] can also be applied to boolean parameters. + +[operators]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html \ No newline at end of file diff --git a/annalyns-infiltration/README.md b/annalyns-infiltration/README.md new file mode 100644 index 0000000..4da03d4 --- /dev/null +++ b/annalyns-infiltration/README.md @@ -0,0 +1,83 @@ +# Annalyn's Infiltration + +Welcome to Annalyn's Infiltration on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Booleans in Java are represented by the `boolean` type, which values can be either `true` or `false`. + +Java supports three boolean operators: `!` (NOT), `&&` (AND), and `||` (OR). + +## Instructions + +In this exercise, you'll be implementing the quest logic for a new RPG game a friend is developing. The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best friend was kidnapped while searching for berries in the forest. Annalyn will try to find and free her best friend, optionally taking her dog with her on this quest. + +After some time spent following her best friend's trail, she finds the camp in which her best friend is imprisoned. It turns out there are two kidnappers: a mighty knight and a cunning archer. + +Having found the kidnappers, Annalyn considers which of the following actions she can engage in: + +- Fast attack: a fast attack can be made if the knight is sleeping, as it takes time for him to get his armor on, so he will be vulnerable. +- Spy: the group can be spied upon if at least one of them is awake. Otherwise, spying is a waste of time. +- Signal prisoner: the prisoner can be signalled using bird sounds if the prisoner is awake and the archer is sleeping, as archers are trained in bird signaling, so they could intercept the message. +- _Free prisoner_: Annalyn can try sneaking into the camp to free the prisoner. + This is a risky thing to do and can only succeed in one of two ways: + - If Annalyn has her pet dog with her she can rescue the prisoner if the archer is asleep. + The knight is scared of the dog and the archer will not have time to get ready before Annalyn and the prisoner can escape. + - If Annalyn does not have her dog then she and the prisoner must be very sneaky! + Annalyn can free the prisoner if the prisoner is awake and the knight and archer are both sleeping, but if the prisoner is sleeping they can't be rescued: the prisoner would be startled by Annalyn's sudden appearance and wake up the knight and archer. + +You have four tasks: to implement the logic for determining if the above actions are available based on the state of the three characters found in the forest and whether Annalyn's pet dog is present or not. + +## 1. Check if a fast attack can be made + +Implement the (_static_) `AnnalynsInfiltration.canFastAttack()` method that takes a boolean value that indicates if the knight is awake. This method returns `true` if a fast attack can be made based on the state of the knight. Otherwise, returns `false`: + +```java +boolean knightIsAwake = true; +AnnalynsInfiltration.canFastAttack(knightIsAwake); +// => false +``` + +## 2. Check if the group can be spied upon + +Implement the (_static_) `AnnalynsInfiltration.canSpy()` method that takes three boolean values, indicating if the knight, archer and the prisoner, respectively, are awake. The method returns `true` if the group can be spied upon, based on the state of the three characters. Otherwise, returns `false`: + +```java +boolean knightIsAwake = false; +boolean archerIsAwake = true; +boolean prisonerIsAwake = false; +AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake); +// => true +``` + +## 3. Check if the prisoner can be signalled + +Implement the (_static_) `AnnalynsInfiltration.canSignalPrisoner()` method that takes two boolean values, indicating if the archer and the prisoner, respectively, are awake. The method returns `true` if the prisoner can be signalled, based on the state of the two characters. Otherwise, returns `false`: + +```java +boolean archerIsAwake = false; +boolean prisonerIsAwake = true; +AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake); +// => true +``` + +## 4. Check if the prisoner can be freed + +Implement the (_static_) `AnnalynsInfiltration.canFreePrisoner()` method that takes four boolean values. The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake. The last parameter indicates if Annalyn's pet dog is present. The method returns `true` if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog presence. Otherwise, it returns `false`: + +```java +boolean knightIsAwake = false; +boolean archerIsAwake = true; +boolean prisonerIsAwake = false; +boolean petDogIsPresent = false; +AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, prisonerIsAwake, petDogIsPresent); +// => false +``` + +## Source + +### Created by + +- @mikedamay \ No newline at end of file diff --git a/annalyns-infiltration/build.gradle b/annalyns-infiltration/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/annalyns-infiltration/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/annalyns-infiltration/build/classes/java/main/AnnalynsInfiltration.class b/annalyns-infiltration/build/classes/java/main/AnnalynsInfiltration.class new file mode 100644 index 0000000..0a1def3 Binary files /dev/null and b/annalyns-infiltration/build/classes/java/main/AnnalynsInfiltration.class differ diff --git a/annalyns-infiltration/build/classes/java/test/AnnalynsInfiltrationTest.class b/annalyns-infiltration/build/classes/java/test/AnnalynsInfiltrationTest.class new file mode 100644 index 0000000..5508852 Binary files /dev/null and b/annalyns-infiltration/build/classes/java/test/AnnalynsInfiltrationTest.class differ diff --git a/annalyns-infiltration/build/reports/tests/test/classes/AnnalynsInfiltrationTest.html b/annalyns-infiltration/build/reports/tests/test/classes/AnnalynsInfiltrationTest.html new file mode 100644 index 0000000..0dcebaf --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/classes/AnnalynsInfiltrationTest.html @@ -0,0 +1,241 @@ + + + + + +Test results - Class AnnalynsInfiltrationTest + + + + + +
+

Class AnnalynsInfiltrationTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
30
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.030s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
can_execute_fast_attack_if_knight_is_sleeping0spassed
can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present0spassed
can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present0.001spassed
can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present0.001spassed
can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent0spassed
can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_present0spassed
can_signal_prisoner_if_archer_is_sleeping_and_prisoner_is_awake0spassed
can_spy_if_everyone_but_archer_is_sleeping0spassed
can_spy_if_everyone_but_knight_is_sleeping0.001spassed
can_spy_if_everyone_but_prisoner_is_sleeping0.026spassed
can_spy_if_everyone_is_awake0spassed
can_spy_if_only_archer_is_sleeping0spassed
can_spy_if_only_knight_is_sleeping0spassed
can_spy_if_only_prisoner_is_sleeping0spassed
cannot_execute_fast_attack_if_knight_is_awake0spassed
cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present0spassed
cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absent0.001spassed
cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_present0spassed
cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_present0spassed
cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_absent0spassed
cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_present0spassed
cannot_signal_prisoner_if_archer_and_prisoner_are_both_awake0spassed
cannot_signal_prisoner_if_archer_and_prisoner_are_both_sleeping0spassed
cannot_signal_prisoner_if_archer_is_awake_and_prisoner_is_sleeping0spassed
cannot_spy_if_everyone_is_sleeping0spassed
+
+
+ +
+ + diff --git a/annalyns-infiltration/build/reports/tests/test/css/base-style.css b/annalyns-infiltration/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/annalyns-infiltration/build/reports/tests/test/css/style.css b/annalyns-infiltration/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/annalyns-infiltration/build/reports/tests/test/index.html b/annalyns-infiltration/build/reports/tests/test/index.html new file mode 100644 index 0000000..f73dc1b --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
30
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.030s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +30000.030s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+AnnalynsInfiltrationTest +30000.030s100%
+
+
+ +
+ + diff --git a/annalyns-infiltration/build/reports/tests/test/js/report.js b/annalyns-infiltration/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/annalyns-infiltration/build/reports/tests/test/packages/default-package.html b/annalyns-infiltration/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..5412295 --- /dev/null +++ b/annalyns-infiltration/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
30
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.030s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+AnnalynsInfiltrationTest +30000.030s100%
+
+
+ +
+ + diff --git a/annalyns-infiltration/build/test-results/test/TEST-AnnalynsInfiltrationTest.xml b/annalyns-infiltration/build/test-results/test/TEST-AnnalynsInfiltrationTest.xml new file mode 100644 index 0000000..28698dd --- /dev/null +++ b/annalyns-infiltration/build/test-results/test/TEST-AnnalynsInfiltrationTest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/annalyns-infiltration/build/test-results/test/binary/output.bin b/annalyns-infiltration/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/annalyns-infiltration/build/test-results/test/binary/output.bin.idx b/annalyns-infiltration/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/annalyns-infiltration/build/test-results/test/binary/output.bin.idx differ diff --git a/annalyns-infiltration/build/test-results/test/binary/results.bin b/annalyns-infiltration/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..2ffcd92 Binary files /dev/null and b/annalyns-infiltration/build/test-results/test/binary/results.bin differ diff --git a/annalyns-infiltration/build/tmp/compileJava/previous-compilation-data.bin b/annalyns-infiltration/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..ee41994 Binary files /dev/null and b/annalyns-infiltration/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/annalyns-infiltration/build/tmp/compileTestJava/previous-compilation-data.bin b/annalyns-infiltration/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..48c69a2 Binary files /dev/null and b/annalyns-infiltration/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar b/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar differ diff --git a/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties b/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/annalyns-infiltration/gradlew b/annalyns-infiltration/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/annalyns-infiltration/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/annalyns-infiltration/gradlew.bat b/annalyns-infiltration/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/annalyns-infiltration/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java b/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java new file mode 100644 index 0000000..747b0f8 --- /dev/null +++ b/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java @@ -0,0 +1,17 @@ +class AnnalynsInfiltration { + public static boolean canFastAttack(boolean knightIsAwake) { + return !knightIsAwake; + } + + public static boolean canSpy(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake) { + return (knightIsAwake || archerIsAwake || prisonerIsAwake); + } + + public static boolean canSignalPrisoner(boolean archerIsAwake, boolean prisonerIsAwake) { + return (prisonerIsAwake && !archerIsAwake); + } + + public static boolean canFreePrisoner(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake, boolean petDogIsPresent) { + return ((petDogIsPresent && !archerIsAwake) || (!petDogIsPresent && prisonerIsAwake && !knightIsAwake && !archerIsAwake)); + } +} diff --git a/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java b/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java new file mode 100644 index 0000000..30d133b --- /dev/null +++ b/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java @@ -0,0 +1,268 @@ +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class AnnalynsInfiltrationTest { + @Test + public void cannot_execute_fast_attack_if_knight_is_awake() { + boolean knightIsAwake = true; + assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isFalse(); + } + + @Test + public void can_execute_fast_attack_if_knight_is_sleeping() { + boolean knightIsAwake = false; + assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isTrue(); + } + + @Test + public void cannot_spy_if_everyone_is_sleeping() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isFalse(); + } + + @Test + public void can_spy_if_everyone_but_knight_is_sleeping() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_everyone_but_archer_is_sleeping() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_everyone_but_prisoner_is_sleeping() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_only_knight_is_sleeping() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_only_archer_is_sleeping() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_only_prisoner_is_sleeping() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_spy_if_everyone_is_awake() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void can_signal_prisoner_if_archer_is_sleeping_and_prisoner_is_awake() { + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isTrue(); + } + + @Test + public void cannot_signal_prisoner_if_archer_is_awake_and_prisoner_is_sleeping() { + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); + } + + @Test + public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_sleeping() { + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); + } + + @Test + public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_awake() { + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isTrue(); + } + + @Test + public void cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_present() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isTrue(); + } + + @Test + public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent() { + boolean knightIsAwake = false; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isTrue(); + } + + @Test + public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_present() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absent() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isTrue(); + } + + @Test + public void cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absent() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_present() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_absent() { + boolean knightIsAwake = false; + boolean archerIsAwake = true; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isTrue(); + } + + @Test + public void cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_absent() { + boolean knightIsAwake = true; + boolean archerIsAwake = false; + boolean prisonerIsAwake = true; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_present() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = true; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } + + @Test + public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_absent() { + boolean knightIsAwake = true; + boolean archerIsAwake = true; + boolean prisonerIsAwake = false; + boolean petDogIsPresent = false; + assertThat(AnnalynsInfiltration.canFreePrisoner(knightIsAwake, archerIsAwake, + prisonerIsAwake, petDogIsPresent)).isFalse(); + } +} diff --git a/bird-watcher/.exercism/config.json b/bird-watcher/.exercism/config.json new file mode 100644 index 0000000..d882465 --- /dev/null +++ b/bird-watcher/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "samuelteixeiras", + "ystromm" + ], + "files": { + "solution": [ + "src/main/java/BirdWatcher.java" + ], + "test": [ + "src/test/java/BirdWatcherTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/BirdWatcher.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/bird-watcher" + ], + "blurb": "Learn about arrays by keeping track of how many birds visit your garden." +} diff --git a/bird-watcher/.exercism/metadata.json b/bird-watcher/.exercism/metadata.json new file mode 100644 index 0000000..2b1682b --- /dev/null +++ b/bird-watcher/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"bird-watcher","id":"fe28f433028641dc96ee1cc7c285d8d9","url":"https://exercism.org/tracks/java/exercises/bird-watcher","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/bird-watcher/.gradle/7.5.1/checksums/checksums.lock b/bird-watcher/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..1eb3f91 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/bird-watcher/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/bird-watcher/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..1e45be0 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/bird-watcher/.gradle/7.5.1/dependencies-accessors/gc.properties b/bird-watcher/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.bin b/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..3b0f22a Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.lock b/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..e438c42 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/bird-watcher/.gradle/7.5.1/fileChanges/last-build.bin b/bird-watcher/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.bin b/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..6efd9a2 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.lock b/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..bbe9f72 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/bird-watcher/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/bird-watcher/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..3892269 Binary files /dev/null and b/bird-watcher/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/bird-watcher/.gradle/7.5.1/gc.properties b/bird-watcher/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/bird-watcher/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/bird-watcher/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..f0d9bf9 Binary files /dev/null and b/bird-watcher/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/bird-watcher/.gradle/buildOutputCleanup/cache.properties b/bird-watcher/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..553418e --- /dev/null +++ b/bird-watcher/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 17:58:10 CET 2023 +gradle.version=7.5.1 diff --git a/bird-watcher/.gradle/buildOutputCleanup/outputFiles.bin b/bird-watcher/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..2eca8bb Binary files /dev/null and b/bird-watcher/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/bird-watcher/.gradle/file-system.probe b/bird-watcher/.gradle/file-system.probe new file mode 100644 index 0000000..e7b0b8b Binary files /dev/null and b/bird-watcher/.gradle/file-system.probe differ diff --git a/bird-watcher/.gradle/vcs-1/gc.properties b/bird-watcher/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/bird-watcher/.idea/.gitignore b/bird-watcher/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/bird-watcher/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/bird-watcher/.idea/compiler.xml b/bird-watcher/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/bird-watcher/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bird-watcher/.idea/gradle.xml b/bird-watcher/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/bird-watcher/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/bird-watcher/.idea/jarRepositories.xml b/bird-watcher/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/bird-watcher/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/bird-watcher/.idea/misc.xml b/bird-watcher/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/bird-watcher/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/bird-watcher/HELP.md b/bird-watcher/HELP.md new file mode 100644 index 0000000..a8fc3a9 --- /dev/null +++ b/bird-watcher/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/BirdWatcher.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/bird-watcher/HINTS.md b/bird-watcher/HINTS.md new file mode 100644 index 0000000..d6a9912 --- /dev/null +++ b/bird-watcher/HINTS.md @@ -0,0 +1,38 @@ +# Hints + +## General + +- The bird count per day is stored in a field named `birdsPerDay`. +- The bird count per day is an array that contains exactly 7 integers. + +## 1. Check what the counts were last week + +- As we keep the last week we just need to return the last week values. + +## 2. Check how many birds visited today + +- Remember that the counts are ordered by day from oldest to most recent, with the last element representing today. +- Accessing the last element can be done either by using its (fixed) index (remember to start counting from zero) or by calculating its index using the array's size. + +## 3. Increment today's count + +- Set the element representing today's count to today's count plus 1. + +## 4. Check if there was a day with no visiting birds + +- The array can be iterated over using a `for` loop. +- Another solution is to use the Java Stream Api. + +## 5. Calculate the number of visiting birds for the first number of days + +- A variable can be used to hold the count for the number of visiting birds. +- The array can be iterated over using a `for` loop. +- The variable can be updated inside the loop. +- Remember: arrays are indexed from `0`. + +## 6. Calculate the number of busy days + +- A variable can be used to hold the number of busy days. +- The array can be iterated over using a `foreach` loop. +- The variable can be updated inside the loop. +- A conditional statement can be used inside the loop. \ No newline at end of file diff --git a/bird-watcher/README.md b/bird-watcher/README.md new file mode 100644 index 0000000..d11d94d --- /dev/null +++ b/bird-watcher/README.md @@ -0,0 +1,135 @@ +# Bird Watcher + +Welcome to Bird Watcher on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +In Java, data structures that can hold zero or more elements are known as _collections_. An **array** is a collection that has a fixed size/length and whose elements must all be of the same type. Elements can be assigned to an array or retrieved from it using an index. Java arrays are zero-based, meaning that the first element's index is always zero: + +```java +// Declare array with explicit size (size is 2) +int[] twoInts = new int[2]; + +// Assign second element by index +twoInts[1] = 8; + +// Retrieve the second element by index and assign to the int element +int element = twoInts[1]; +``` + +Arrays can also be defined using a shortcut notation that allows you to both create the array and set its value. As the compiler can now tell how many elements the array will have, the length can be omitted: + +```java +// Two equivalent ways to declare and initialize an array (size is 3) +int[] threeIntsV1 = new int[] { 4, 9, 7 }; +int[] threeIntsV2 = { 4, 9, 7 }; +``` + +Arrays can be manipulated by either calling an array instance's methods or properties, or by using the static methods defined in the `Arrays` class. + +The fact that an array is also a _collection_ means that, besides accessing values by index, you can iterate over _all_ its values using a `foreach` loop: + +```java +char[] vowels = { 'a', 'e', 'i', 'o', 'u' }; + +for(char vowel:vowels) { + // Output the vowel + System.out.print(vowel); +} + +// => aeiou +``` + +If you want more control over which values to iterate over, a `for` loop can be used: + +```java +char[] vowels = { 'a', 'e', 'i', 'o', 'u' }; + +for (int i = 0; i < 3; i++) { + // Output the vowel + System.out.print(vowels[i]); +} + +// => aei +``` + +## Instructions + +You're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days. + +You have six tasks, all dealing with the numbers of birds that visited your garden. + +## 1. Check what the counts were last week + +For comparison purposes, you always keep a copy of last week's counts nearby, which were: 0, 2, 5, 3, 7, 8 and 4. Implement the `BirdWatcher.getLastWeek()` method that returns last week's counts: + +```java +BirdWatcher.getLastWeek(); +// => [0, 2, 5, 3, 7, 8, 4] +``` + +## 2. Check how many birds visited today + +Implement the `BirdWatcher.getToday()` method to return how many birds visited your garden today. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count. + +```java +int[] birdsPerDay = { 2, 5, 0, 7, 4, 1 }; +BirdWatcher birdCount = new BirdWatcher(birdsPerDay); +birdCount.getToday(); +// => 1 +``` + +## 3. Increment today's count + +Implement the `BirdWatcher.incrementTodaysCount()` method to increment today's count: + +```java +int[] birdsPerDay = { 2, 5, 0, 7, 4, 1 }; +BirdWatcher birdCount = new BirdWatcher(birdsPerDay); +birdCount.incrementTodaysCount(); +birdCount.getToday(); +// => 2 +``` + +## 4. Check if there was a day with no visiting birds + +Implement the `BirdWatcher.hasDayWithoutBirds()` method that returns `true` if there was a day at which zero birds visited the garden; otherwise, return `false`: + +```java +int[] birdsPerDay = { 2, 5, 0, 7, 4, 1 }; +BirdWatcher birdCount = new BirdWatcher(birdsPerDay); +birdCount.hasDayWithoutBirds(); +// => true +``` + +## 5. Calculate the number of visiting birds for the first number of days + +Implement the `BirdWatcher.getCountForFirstDays()` method that returns the number of birds that have visited your garden from the start of the week, but limit the count to the specified number of days from the start of the week. + +```java +int[] birdsPerDay = { 2, 5, 0, 7, 4, 1 }; +BirdWatcher birdCount = new BirdWatcher(birdsPerDay); +birdCount.getCountForFirstDays(4); +// => 14 +``` + +## 6. Calculate the number of busy days + +Some days are busier that others. A busy day is one where five or more birds have visited your garden. +Implement the `BirdWatcher.getBusyDays()` method to return the number of busy days: + +```java +int[] birdsPerDay = { 2, 5, 0, 7, 4, 1 }; +BirdWatcher birdCount = new BirdWatcher(birdsPerDay); +birdCount.getBusyDays(); +// => 2 +``` + +## Source + +### Created by + +- @samuelteixeiras +- @ystromm \ No newline at end of file diff --git a/bird-watcher/build.gradle b/bird-watcher/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/bird-watcher/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/bird-watcher/build/classes/java/main/BirdWatcher.class b/bird-watcher/build/classes/java/main/BirdWatcher.class new file mode 100644 index 0000000..2d45129 Binary files /dev/null and b/bird-watcher/build/classes/java/main/BirdWatcher.class differ diff --git a/bird-watcher/build/classes/java/test/BirdWatcherTest.class b/bird-watcher/build/classes/java/test/BirdWatcherTest.class new file mode 100644 index 0000000..30f391d Binary files /dev/null and b/bird-watcher/build/classes/java/test/BirdWatcherTest.class differ diff --git a/bird-watcher/build/reports/tests/test/classes/BirdWatcherTest.html b/bird-watcher/build/reports/tests/test/classes/BirdWatcherTest.html new file mode 100644 index 0000000..2248a5e --- /dev/null +++ b/bird-watcher/build/reports/tests/test/classes/BirdWatcherTest.html @@ -0,0 +1,136 @@ + + + + + +Test results - Class BirdWatcherTest + + + + + +
+

Class BirdWatcherTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.034s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
itHasDayWithoutBirds0spassed
itIncrementTodaysCount0.001spassed
itShouldNotHaveBusyDays0.027spassed
itShouldNotHaveDaysWithoutBirds0.001spassed
itTestGetCountForBusyDays0spassed
itTestGetCountForFirstDays0spassed
itTestGetCountForMoreDaysThanTheArraySize0spassed
itTestGetLastWeek0.005spassed
itTestGetToday0spassed
+
+
+ +
+ + diff --git a/bird-watcher/build/reports/tests/test/css/base-style.css b/bird-watcher/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/bird-watcher/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/bird-watcher/build/reports/tests/test/css/style.css b/bird-watcher/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/bird-watcher/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/bird-watcher/build/reports/tests/test/index.html b/bird-watcher/build/reports/tests/test/index.html new file mode 100644 index 0000000..b56a69f --- /dev/null +++ b/bird-watcher/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.034s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +9000.034s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+BirdWatcherTest +9000.034s100%
+
+
+ +
+ + diff --git a/bird-watcher/build/reports/tests/test/js/report.js b/bird-watcher/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/bird-watcher/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/bird-watcher/build/reports/tests/test/packages/default-package.html b/bird-watcher/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..01a9ecc --- /dev/null +++ b/bird-watcher/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.034s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+BirdWatcherTest +9000.034s100%
+
+
+ +
+ + diff --git a/bird-watcher/build/test-results/test/TEST-BirdWatcherTest.xml b/bird-watcher/build/test-results/test/TEST-BirdWatcherTest.xml new file mode 100644 index 0000000..4561b40 --- /dev/null +++ b/bird-watcher/build/test-results/test/TEST-BirdWatcherTest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/bird-watcher/build/test-results/test/binary/output.bin b/bird-watcher/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/bird-watcher/build/test-results/test/binary/output.bin.idx b/bird-watcher/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/bird-watcher/build/test-results/test/binary/output.bin.idx differ diff --git a/bird-watcher/build/test-results/test/binary/results.bin b/bird-watcher/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..f2efdb5 Binary files /dev/null and b/bird-watcher/build/test-results/test/binary/results.bin differ diff --git a/bird-watcher/build/tmp/compileJava/previous-compilation-data.bin b/bird-watcher/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..b23fe1b Binary files /dev/null and b/bird-watcher/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/bird-watcher/build/tmp/compileTestJava/previous-compilation-data.bin b/bird-watcher/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..ec3348b Binary files /dev/null and b/bird-watcher/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/bird-watcher/gradle/wrapper/gradle-wrapper.jar b/bird-watcher/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/bird-watcher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/bird-watcher/gradle/wrapper/gradle-wrapper.properties b/bird-watcher/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/bird-watcher/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/bird-watcher/gradlew b/bird-watcher/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/bird-watcher/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/bird-watcher/gradlew.bat b/bird-watcher/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/bird-watcher/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/bird-watcher/src/main/java/BirdWatcher.java b/bird-watcher/src/main/java/BirdWatcher.java new file mode 100644 index 0000000..c0fab38 --- /dev/null +++ b/bird-watcher/src/main/java/BirdWatcher.java @@ -0,0 +1,46 @@ + +class BirdWatcher { + private final int[] birdsPerDay; + + public BirdWatcher(int[] birdsPerDay) { + this.birdsPerDay = birdsPerDay.clone(); + } + + public int[] getLastWeek() { + return birdsPerDay; + } + + public int getToday() { + return birdsPerDay[birdsPerDay.length - 1]; + } + + public void incrementTodaysCount() { + birdsPerDay[birdsPerDay.length - 1]++; + } + + public boolean hasDayWithoutBirds() { + for(int dailyVisits : birdsPerDay) { + if(dailyVisits == 0) return true; + } + return false; + } + + public int getCountForFirstDays(int numberOfDays) { + int visits = 0; + int days = Math.min(numberOfDays, 7); + for(int i = 0; i < days; i++) { + visits += birdsPerDay[i]; + } + + return visits; + } + + public int getBusyDays() { + int busyDays = 0; + for(int i = 0; i < birdsPerDay.length; i++) { + if(birdsPerDay[i] >= 5) busyDays++; + } + + return busyDays; + } +} diff --git a/bird-watcher/src/test/java/BirdWatcherTest.java b/bird-watcher/src/test/java/BirdWatcherTest.java new file mode 100644 index 0000000..d56a2ae --- /dev/null +++ b/bird-watcher/src/test/java/BirdWatcherTest.java @@ -0,0 +1,76 @@ +import org.junit.Before; +import org.junit.Test; + + +import static org.assertj.core.api.Assertions.*; + +public class BirdWatcherTest { + + private static final int DAY1 = 0; + private static final int DAY2 = 2; + private static final int DAY3 = 5; + private static final int DAY4 = 3; + private static final int DAY5 = 7; + private static final int DAY6 = 8; + private static final int TODAY = 4; + + private BirdWatcher birdWatcher; + private int lastWeek[] = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY}; + + @Before + public void setUp() { + birdWatcher = new BirdWatcher(lastWeek); + } + + @Test + public void itTestGetLastWeek() { + assertThat(birdWatcher.getLastWeek()) + .containsExactly(DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY); + } + + @Test + public void itTestGetToday() { + assertThat(birdWatcher.getToday()).isEqualTo(TODAY); + } + + @Test + public void itIncrementTodaysCount() { + birdWatcher.incrementTodaysCount(); + assertThat(birdWatcher.getToday()).isEqualTo(TODAY + 1); + } + + @Test + public void itHasDayWithoutBirds() { + assertThat(birdWatcher.hasDayWithoutBirds()).isTrue(); + } + + @Test + public void itShouldNotHaveDaysWithoutBirds() { + birdWatcher = new BirdWatcher(new int[]{1, 2, 5, 3, 7, 8, 4}); + assertThat(birdWatcher.hasDayWithoutBirds()).isFalse(); + } + + + @Test + public void itTestGetCountForFirstDays() { + assertThat(birdWatcher.getCountForFirstDays(4)).isEqualTo(DAY1 + DAY2 + DAY3 + DAY4); + } + + @Test + public void itTestGetCountForMoreDaysThanTheArraySize() { + assertThat(birdWatcher.getCountForFirstDays(10)) + .isEqualTo(DAY1 + DAY2 + DAY3 + DAY4 + DAY5 + DAY6 + TODAY); + } + + @Test + public void itTestGetCountForBusyDays() { + // DAY3, DAY5 and DAY6 are all >= 5 birds + assertThat(birdWatcher.getBusyDays()).isEqualTo(3); + } + + @Test + public void itShouldNotHaveBusyDays() { + birdWatcher = new BirdWatcher(new int[]{1, 2, 3, 3, 2, 1, 4}); + assertThat(birdWatcher.getBusyDays()).isEqualTo(0); + } +} diff --git a/cars-assemble/.exercism/config.json b/cars-assemble/.exercism/config.json new file mode 100644 index 0000000..5a323d4 --- /dev/null +++ b/cars-assemble/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "TalesDias" + ], + "files": { + "solution": [ + "src/main/java/CarsAssemble.java" + ], + "test": [ + "src/test/java/CarsAssembleTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/CarsAssemble.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/cars-assemble" + ], + "blurb": "Learn about numbers by analyzing the production of an assembly line." +} diff --git a/cars-assemble/.exercism/metadata.json b/cars-assemble/.exercism/metadata.json new file mode 100644 index 0000000..9446d9a --- /dev/null +++ b/cars-assemble/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"cars-assemble","id":"3353b6bdeea34aa0958f060388a65c56","url":"https://exercism.org/tracks/java/exercises/cars-assemble","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/cars-assemble/.gradle/7.5.1/checksums/checksums.lock b/cars-assemble/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..f6c767e Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/cars-assemble/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/cars-assemble/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..58f0dd3 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/cars-assemble/.gradle/7.5.1/dependencies-accessors/gc.properties b/cars-assemble/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.bin b/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..3b2a973 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.lock b/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..9694ae2 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/cars-assemble/.gradle/7.5.1/fileChanges/last-build.bin b/cars-assemble/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.bin b/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..e6b246f Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.lock b/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..4840b16 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/cars-assemble/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/cars-assemble/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..1245842 Binary files /dev/null and b/cars-assemble/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/cars-assemble/.gradle/7.5.1/gc.properties b/cars-assemble/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/cars-assemble/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/cars-assemble/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..c628b22 Binary files /dev/null and b/cars-assemble/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/cars-assemble/.gradle/buildOutputCleanup/cache.properties b/cars-assemble/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..e0785ff --- /dev/null +++ b/cars-assemble/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Mar 08 18:02:05 CET 2023 +gradle.version=7.5.1 diff --git a/cars-assemble/.gradle/buildOutputCleanup/outputFiles.bin b/cars-assemble/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..85830de Binary files /dev/null and b/cars-assemble/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/cars-assemble/.gradle/file-system.probe b/cars-assemble/.gradle/file-system.probe new file mode 100644 index 0000000..8ddbcb5 Binary files /dev/null and b/cars-assemble/.gradle/file-system.probe differ diff --git a/cars-assemble/.gradle/vcs-1/gc.properties b/cars-assemble/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/cars-assemble/.idea/.gitignore b/cars-assemble/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/cars-assemble/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/cars-assemble/.idea/compiler.xml b/cars-assemble/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/cars-assemble/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cars-assemble/.idea/gradle.xml b/cars-assemble/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/cars-assemble/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/cars-assemble/.idea/jarRepositories.xml b/cars-assemble/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/cars-assemble/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/cars-assemble/.idea/misc.xml b/cars-assemble/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/cars-assemble/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cars-assemble/HELP.md b/cars-assemble/HELP.md new file mode 100644 index 0000000..aa9b260 --- /dev/null +++ b/cars-assemble/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/CarsAssemble.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/cars-assemble/HINTS.md b/cars-assemble/HINTS.md new file mode 100644 index 0000000..6259650 --- /dev/null +++ b/cars-assemble/HINTS.md @@ -0,0 +1,20 @@ +# Hints + +## General + +- [Numbers tutorial][numbers]. + +## 1. Calculate the production rate per second + +- Determining the success rate can be done through a [conditional statement][if-statement]. +- Java allows for multiplication to be applied to two different number types (such as an `int` and a `double`). It will automatically return the "broader" data type. +- Numbers can be compared using the built-in [comparison][comparison-operators] and [equality operators][comparison-operators]. + +## 2. Calculate the number of working items produced per second + +- Whereas an `int` can be automatically converted to a `double`, the reverse does not hold. The reason for this is that an `int` has less precision than a `double` so rounding has to be applied, also the range of numbers an `int` can represent is smaller than a `double`. To force this conversion you can use a [cast to an int][cast-int]. + +[cast-int]: https://www.w3schools.com/java/java_type_casting.asp +[numbers]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html +[if-statement]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html +[comparison-operators]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html \ No newline at end of file diff --git a/cars-assemble/README.md b/cars-assemble/README.md new file mode 100644 index 0000000..49e3806 --- /dev/null +++ b/cars-assemble/README.md @@ -0,0 +1,80 @@ +# Cars, Assemble! + +Welcome to Cars, Assemble! on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +There are two different types of numbers in Java: + +- Integers: numbers with no digits behind the decimal separator (whole numbers). Examples are `-6`, `0`, `1`, `25`, `976` and `-500000`. +- Floating-point numbers: numbers with zero or more digits behind the decimal separator. Examples are `-20.4`, `0.1`, `2.72`, `16.984025` and `1024.0`. + +The two most common numeric types in Java are `int` and `double`. An `int` is a 32-bit integer and a `double` is a 64-bit floating-point number. + +Arithmetic is done using the standard arithmetic operators. Numbers can be compared using the standard numeric comparison operators and the equality (`==`) and inequality (`!=`) operators. + +Java has two types of numeric conversions: + +1. Implicit conversions: no data will be lost and no additional syntax is required. +2. Explicit conversions: data could be lost and additional syntax in the form of a _cast_ is required. + +As an `int` has less precision than a `double`, converting from an `int` to a `double` is safe and is thus an implicit conversion. However, converting from a `double` to an `int` could mean losing data, so that requires an explicit conversion. + +In this exercise you must conditionally execute logic. The most common way to do this in Java is by using an `if/else` statement: + +```java +int x = 6; + +if (x == 5) { + // Execute logic if x equals 5 +} else if (x > 7) { + // Execute logic if x greater than 7 +} else { + // Execute logic in all other cases +} +``` + +The condition of an `if` statement must be of type `boolean`. Java has no concept of _truthy_ values. + +## Instructions + +In this exercise you'll be writing code to analyze the production of an assembly line in a car factory. The assembly line's speed can range from `0` (off) to `10` (maximum). + +At its lowest speed (`1`), `221` cars are produced each hour. The production increases linearly with the speed. So with the speed set to `4`, it should produce `4 * 221 = 884` cars per hour. However, higher speeds increase the likelihood that faulty cars are produced, which then have to be discarded. The following table shows how speed influences the success rate: + +- `1` to `4`: 100% success rate. +- `5` to `8`: 90% success rate. +- `9`: 80% success rate. +- `10`: 77% success rate. + +You have two tasks. + +## 1. Calculate the production rate per hour + +Implement the `CarsAssemble.productionRatePerHour()` method to calculate the assembly line's production rate per hour, taking into account its current assembly line's speed : + +```Java +CarsAssemble.productionRatePerHour(6) +// => 1193.4 +``` + +Note that the value returned is a `double`. + +## 2. Calculate the number of working items produced per minute + +Implement the `CarsAssemble.workingItemsPerMinute()` method to calculate how many working cars are produced per minute: + +```Java +CarsAssemble.workingItemsPerMinute(6) +// => 19 +``` + +Note that the value returned is an `int`. + +## Source + +### Created by + +- @TalesDias \ No newline at end of file diff --git a/cars-assemble/build.gradle b/cars-assemble/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/cars-assemble/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/cars-assemble/build/classes/java/main/CarsAssemble.class b/cars-assemble/build/classes/java/main/CarsAssemble.class new file mode 100644 index 0000000..93d106a Binary files /dev/null and b/cars-assemble/build/classes/java/main/CarsAssemble.class differ diff --git a/cars-assemble/build/classes/java/test/CarsAssembleTest.class b/cars-assemble/build/classes/java/test/CarsAssembleTest.class new file mode 100644 index 0000000..c285be3 Binary files /dev/null and b/cars-assemble/build/classes/java/test/CarsAssembleTest.class differ diff --git a/cars-assemble/build/reports/tests/test/classes/CarsAssembleTest.html b/cars-assemble/build/reports/tests/test/classes/CarsAssembleTest.html new file mode 100644 index 0000000..c28b842 --- /dev/null +++ b/cars-assemble/build/reports/tests/test/classes/CarsAssembleTest.html @@ -0,0 +1,151 @@ + + + + + +Test results - Class CarsAssembleTest + + + + + +
+

Class CarsAssembleTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.025s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
productionRatePerHourForSpeedFour0spassed
productionRatePerHourForSpeedNine0spassed
productionRatePerHourForSpeedOne0spassed
productionRatePerHourForSpeedSeven0spassed
productionRatePerHourForSpeedTen0spassed
productionRatePerHourForSpeedZero0spassed
workingItemsPerMinuteForSpeedEight0spassed
workingItemsPerMinuteForSpeedFive0.025spassed
workingItemsPerMinuteForSpeedNine0spassed
workingItemsPerMinuteForSpeedOne0spassed
workingItemsPerMinuteForSpeedTen0spassed
workingItemsPerMinuteForSpeedZero0spassed
+
+
+ +
+ + diff --git a/cars-assemble/build/reports/tests/test/css/base-style.css b/cars-assemble/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/cars-assemble/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/cars-assemble/build/reports/tests/test/css/style.css b/cars-assemble/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/cars-assemble/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/cars-assemble/build/reports/tests/test/index.html b/cars-assemble/build/reports/tests/test/index.html new file mode 100644 index 0000000..5254688 --- /dev/null +++ b/cars-assemble/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.025s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +12000.025s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+CarsAssembleTest +12000.025s100%
+
+
+ +
+ + diff --git a/cars-assemble/build/reports/tests/test/js/report.js b/cars-assemble/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/cars-assemble/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/cars-assemble/build/reports/tests/test/packages/default-package.html b/cars-assemble/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..73afa91 --- /dev/null +++ b/cars-assemble/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.025s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+CarsAssembleTest +12000.025s100%
+
+
+ +
+ + diff --git a/cars-assemble/build/test-results/test/TEST-CarsAssembleTest.xml b/cars-assemble/build/test-results/test/TEST-CarsAssembleTest.xml new file mode 100644 index 0000000..064f235 --- /dev/null +++ b/cars-assemble/build/test-results/test/TEST-CarsAssembleTest.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/cars-assemble/build/test-results/test/binary/output.bin b/cars-assemble/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/cars-assemble/build/test-results/test/binary/output.bin.idx b/cars-assemble/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/cars-assemble/build/test-results/test/binary/output.bin.idx differ diff --git a/cars-assemble/build/test-results/test/binary/results.bin b/cars-assemble/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..a8e702d Binary files /dev/null and b/cars-assemble/build/test-results/test/binary/results.bin differ diff --git a/cars-assemble/build/tmp/compileJava/previous-compilation-data.bin b/cars-assemble/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..c646a7c Binary files /dev/null and b/cars-assemble/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/cars-assemble/build/tmp/compileTestJava/previous-compilation-data.bin b/cars-assemble/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..1307de8 Binary files /dev/null and b/cars-assemble/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/cars-assemble/gradle/wrapper/gradle-wrapper.jar b/cars-assemble/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/cars-assemble/gradle/wrapper/gradle-wrapper.jar differ diff --git a/cars-assemble/gradle/wrapper/gradle-wrapper.properties b/cars-assemble/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/cars-assemble/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/cars-assemble/gradlew b/cars-assemble/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/cars-assemble/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/cars-assemble/gradlew.bat b/cars-assemble/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/cars-assemble/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/cars-assemble/src/main/java/CarsAssemble.java b/cars-assemble/src/main/java/CarsAssemble.java new file mode 100644 index 0000000..e3d26cf --- /dev/null +++ b/cars-assemble/src/main/java/CarsAssemble.java @@ -0,0 +1,35 @@ +public class CarsAssemble { + + public CarsAssemble() { + + } + + public static final double CARS_PER_HOUR = 221; + + public double productionRatePerHour(int speed) { + if (speed == 0) return 0; + double produced = CARS_PER_HOUR; + if(speed >= 1 && speed <= 4) { + produced = produced * speed * 100 / 100; + } else if(speed >= 5 && speed <= 8) { + produced = produced * speed * 90 / 100; + } else if(speed == 9) { + produced = produced * speed * 80 / 100; + } else if(speed == 10) { + produced = produced * speed * 77 / 100; + } + + return produced; + } + + public int workingItemsPerMinute(int speed) { + return (int)productionRatePerHour(speed) / 60; + } + + public static void main(String[] args) { + CarsAssemble car = new CarsAssemble(); + + System.out.println(car.productionRatePerHour(6)); + + } +} diff --git a/cars-assemble/src/test/java/CarsAssembleTest.java b/cars-assemble/src/test/java/CarsAssembleTest.java new file mode 100644 index 0000000..344b7ad --- /dev/null +++ b/cars-assemble/src/test/java/CarsAssembleTest.java @@ -0,0 +1,76 @@ +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.*; + + +public class CarsAssembleTest { + + private CarsAssemble carsAssemble; + private double epsilon = 0.0000001d; + + @Before + public void setUp() { + carsAssemble = new CarsAssemble(); + } + + @Test + public void productionRatePerHourForSpeedZero() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(0) - 0.0) < epsilon).isTrue(); + } + + @Test + public void productionRatePerHourForSpeedOne() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(1) - 221.0) < epsilon).isTrue(); + } + + @Test + public void productionRatePerHourForSpeedFour() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(4) - 884.0) < epsilon).isTrue(); + } + + @Test + public void productionRatePerHourForSpeedSeven() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(7) - 1392.3) < epsilon).isTrue(); + } + + @Test + public void productionRatePerHourForSpeedNine() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(9) - 1591.2) < epsilon).isTrue(); + } + + @Test + public void productionRatePerHourForSpeedTen() { + assertThat(Math.abs(carsAssemble.productionRatePerHour(10) - 1701.7) < epsilon).isTrue(); + } + + @Test + public void workingItemsPerMinuteForSpeedZero() { + assertThat(carsAssemble.workingItemsPerMinute(0)).isEqualTo(0); + } + + @Test + public void workingItemsPerMinuteForSpeedOne() { + assertThat(carsAssemble.workingItemsPerMinute(1)).isEqualTo(3); + } + + @Test + public void workingItemsPerMinuteForSpeedFive() { + assertThat(carsAssemble.workingItemsPerMinute(5)).isEqualTo(16); + } + + @Test + public void workingItemsPerMinuteForSpeedEight() { + assertThat(carsAssemble.workingItemsPerMinute(8)).isEqualTo(26); + } + + @Test + public void workingItemsPerMinuteForSpeedNine() { + assertThat(carsAssemble.workingItemsPerMinute(9)).isEqualTo(26); + } + + @Test + public void workingItemsPerMinuteForSpeedTen() { + assertThat(carsAssemble.workingItemsPerMinute(10)).isEqualTo(28); + } +} diff --git a/elons-toy-car/.exercism/config.json b/elons-toy-car/.exercism/config.json new file mode 100644 index 0000000..e55a4b9 --- /dev/null +++ b/elons-toy-car/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "mikedamay" + ], + "contributors": [ + "mirkoperillo" + ], + "files": { + "solution": [ + "src/main/java/ElonsToyCar.java" + ], + "test": [ + "src/test/java/ElonsToyCarTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/ElonsToyCar.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "icon": "elons-toys", + "blurb": "Learn about classes by working on a remote controlled car." +} diff --git a/elons-toy-car/.exercism/metadata.json b/elons-toy-car/.exercism/metadata.json new file mode 100644 index 0000000..df7cac6 --- /dev/null +++ b/elons-toy-car/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"elons-toy-car","id":"047fc2682b4b4c9c854de4eccadabe6c","url":"https://exercism.org/tracks/java/exercises/elons-toy-car","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/elons-toy-car/.gradle/7.5.1/checksums/checksums.lock b/elons-toy-car/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..435aa87 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/elons-toy-car/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/elons-toy-car/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..6d79fba Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/elons-toy-car/.gradle/7.5.1/dependencies-accessors/gc.properties b/elons-toy-car/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.bin b/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..d114a65 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.lock b/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..084ccf9 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/elons-toy-car/.gradle/7.5.1/fileChanges/last-build.bin b/elons-toy-car/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.bin b/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..b47cc0b Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.lock b/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..186fea4 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/elons-toy-car/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/elons-toy-car/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..223f697 Binary files /dev/null and b/elons-toy-car/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/elons-toy-car/.gradle/7.5.1/gc.properties b/elons-toy-car/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/elons-toy-car/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/elons-toy-car/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..e91cc1b Binary files /dev/null and b/elons-toy-car/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/elons-toy-car/.gradle/buildOutputCleanup/cache.properties b/elons-toy-car/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..7b985a4 --- /dev/null +++ b/elons-toy-car/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 18:55:58 CET 2023 +gradle.version=7.5.1 diff --git a/elons-toy-car/.gradle/buildOutputCleanup/outputFiles.bin b/elons-toy-car/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..81de11f Binary files /dev/null and b/elons-toy-car/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/elons-toy-car/.gradle/file-system.probe b/elons-toy-car/.gradle/file-system.probe new file mode 100644 index 0000000..e0dcd78 Binary files /dev/null and b/elons-toy-car/.gradle/file-system.probe differ diff --git a/elons-toy-car/.gradle/vcs-1/gc.properties b/elons-toy-car/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/elons-toy-car/.idea/.gitignore b/elons-toy-car/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/elons-toy-car/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/elons-toy-car/.idea/compiler.xml b/elons-toy-car/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/elons-toy-car/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/elons-toy-car/.idea/gradle.xml b/elons-toy-car/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/elons-toy-car/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/elons-toy-car/.idea/jarRepositories.xml b/elons-toy-car/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/elons-toy-car/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/elons-toy-car/.idea/misc.xml b/elons-toy-car/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/elons-toy-car/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/elons-toy-car/HELP.md b/elons-toy-car/HELP.md new file mode 100644 index 0000000..be1cf50 --- /dev/null +++ b/elons-toy-car/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/ElonsToyCar.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/elons-toy-car/HINTS.md b/elons-toy-car/HINTS.md new file mode 100644 index 0000000..713a7c1 --- /dev/null +++ b/elons-toy-car/HINTS.md @@ -0,0 +1,34 @@ +# Hints + +## General + +## 1. Buy a brand-new remote controlled car + +- [This page shows how to create a new instance of a class][creating-objects]. + +## 2. Display the distance driven + +- Keep track of the distance driven in a [field][fields]. +- Consider what visibility to use for the field (does it need to be used outside the class?). + +## 3. Display the battery percentage + +- Keep track of the distance driven in a [field][fields]. +- Initialize the field to a specific value to correspond to the initial battery charge. +- Consider what visibility to use for the field (does it need to be used outside the class?). + +## 4. Update the number of meters driven when driving + +- Update the field representing the distance driven. + +## 5. Update the battery percentage when driving + +- Update the field representing the battery percentage driven. + +## 6. Prevent driving when the battery is drained + +- Add a conditional to only update the distance and battery if the battery is not already drained. +- Add a conditional to display the empty battery message if the battery is drained. + +[creating-objects]: https://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html +[fields]: https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html \ No newline at end of file diff --git a/elons-toy-car/README.md b/elons-toy-car/README.md new file mode 100644 index 0000000..a77d39d --- /dev/null +++ b/elons-toy-car/README.md @@ -0,0 +1,164 @@ +# Elon's Toy Car + +Welcome to Elon's Toy Car on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +The primary object-oriented construct in Java is the _class_, which is a combination of data (_fields_) and behavior (_methods_). The fields and methods of a class are known as its _members_. + +Access to members can be controlled through access modifiers, the two most common ones being: + +- `public`: the member can be accessed by any code (no restrictions). +- `private`: the member can only be accessed by code in the same class. + +You can think of a class as a template for creating instances of that class. To create an instance of a class (also known as an _object_), the `new` keyword is used: + +```java +class Car { +} + +// Create two car instances +Car myCar = new Car(); +Car yourCar = new Car(); +``` + +Fields have a type and a name (defined in camelCase) and can be defined anywhere in a class (by convention cased in PascalCase): + +```java +class Car { + // Accessible by anyone + public int weight; + + // Only accessible by code in this class + private String color; +} +``` + +One can optionally assign an initial value to a field. If a field does _not_ specify an initial value, it wll be set to its type's default value. An instance's field values can be accessed and updated using dot-notation. + +```java +class Car { + // Will be set to specified value + public int weight = 2500; + + // Will be set to default value (0) + public int year; +} + +Car newCar = new Car(); +newCar.weight; // => 2500 +newCar.year; // => 0 + +// Update value of the field +newCar.year = 2018; +``` + +Private fields are usually updated as a side effect of calling a method. Such methods usually don't return any value, in which case the return type should be `void`: + +```java +class CarImporter { + private int carsImported; + + public void ImportCars(int numberOfCars) + { + // Update private field from public method + carsImported = carsImported + numberOfCars; + } +} +``` + +## Instructions + +In this exercise you'll be playing around with a remote controlled car, which you've finally saved enough money for to buy. + +Cars start with full (100%) batteries. Each time you drive the car using the remote control, it covers 20 meters and drains one percent of the battery. + +The remote controlled car has a fancy LED display that shows two bits of information: + +- The total distance it has driven, displayed as: `"Driven meters"`. +- The remaining battery charge, displayed as: `"Battery at %"`. + +If the battery is at 0%, you can't drive the car anymore and the battery display will show `"Battery empty"`. + +You have six tasks, each of which will work with remote controlled car instances. + +## 1. Buy a brand-new remote controlled car + +Implement the (_static_) `ElonsToyCar.buy()` method to return a brand-new remote controlled car instance: + +```java +ElonsToyCar car = ElonsToyCar.buy(); +``` + +## 2. Display the distance driven + +Implement the `ElonsToyCar.distanceDisplay()` method to return the distance as displayed on the LED display: + +```java +ElonsToyCar car = ElonsToyCar.buy(); +car.distanceDisplay(); +// => "Driven 0 meters" +``` + +## 3. Display the battery percentage + +Implement the `ElonsToyCar.batteryDisplay()` method to return the battery percentage as displayed on the LED display: + +```java +ElonsToyCar car = ElonsToyCar.buy(); +car.batteryDisplay(); +// => "Battery at 100%" +``` + +## 4. Update the number of meters driven when driving + +Implement the `ElonsToyCar.drive()` method that updates the number of meters driven: + +```java +ElonsToyCar car = ElonsToyCar.buy(); +car.drive(); +car.drive(); +car.distanceDisplay(); +// => "Driven 40 meters" +``` + +## 5. Update the battery percentage when driving + +Update the `ElonsToyCar.drive()` method to update the battery percentage: + +```java +ElonsToyCar car = ElonsToyCar.buy(); +car.drive(); +car.drive(); +car.batteryDisplay(); +// => "Battery at 98%" +``` + +## 6. Prevent driving when the battery is drained + +Update the `ElonsToyCar.drive()` method to not increase the distance driven nor decrease the battery percentage when the battery is drained (at 0%): + +```java +ElonsToyCar car = ElonsToyCar.buy(); + +// Drain the battery +// ... + +car.distanceDisplay(); +// => "Driven 2000 meters" + +car.batteryDisplay(); +// => "Battery empty" +``` + +## Source + +### Created by + +- @mikedamay + +### Contributed to by + +- @mirkoperillo \ No newline at end of file diff --git a/elons-toy-car/build.gradle b/elons-toy-car/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/elons-toy-car/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/elons-toy-car/build/classes/java/main/ElonsToyCar.class b/elons-toy-car/build/classes/java/main/ElonsToyCar.class new file mode 100644 index 0000000..7b5dcb6 Binary files /dev/null and b/elons-toy-car/build/classes/java/main/ElonsToyCar.class differ diff --git a/elons-toy-car/build/classes/java/test/ElonsToyCarTest.class b/elons-toy-car/build/classes/java/test/ElonsToyCarTest.class new file mode 100644 index 0000000..a5256cd Binary files /dev/null and b/elons-toy-car/build/classes/java/test/ElonsToyCarTest.class differ diff --git a/elons-toy-car/build/reports/tests/test/classes/ElonsToyCarTest.html b/elons-toy-car/build/reports/tests/test/classes/ElonsToyCarTest.html new file mode 100644 index 0000000..43c98b8 --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/classes/ElonsToyCarTest.html @@ -0,0 +1,141 @@ + + + + + +Test results - Class ElonsToyCarTest + + + + + +
+

Class ElonsToyCarTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
10
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.031s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
battery_display_after_driving_multiple_times0spassed
battery_display_after_driving_once0spassed
battery_display_when_battery_empty0spassed
buy_new_car_returns_instance0.024spassed
buy_new_car_returns_new_car_each_time0.001spassed
distance_display_after_driving_multiple_times0spassed
distance_display_after_driving_once0spassed
distance_display_when_battery_empty0spassed
new_car_battery_display0spassed
new_car_distance_display0.006spassed
+
+
+ +
+ + diff --git a/elons-toy-car/build/reports/tests/test/css/base-style.css b/elons-toy-car/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/elons-toy-car/build/reports/tests/test/css/style.css b/elons-toy-car/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/elons-toy-car/build/reports/tests/test/index.html b/elons-toy-car/build/reports/tests/test/index.html new file mode 100644 index 0000000..e588b79 --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
10
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.031s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +10000.031s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+ElonsToyCarTest +10000.031s100%
+
+
+ +
+ + diff --git a/elons-toy-car/build/reports/tests/test/js/report.js b/elons-toy-car/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/elons-toy-car/build/reports/tests/test/packages/default-package.html b/elons-toy-car/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..f3b9f74 --- /dev/null +++ b/elons-toy-car/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
10
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.031s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+ElonsToyCarTest +10000.031s100%
+
+
+ +
+ + diff --git a/elons-toy-car/build/test-results/test/TEST-ElonsToyCarTest.xml b/elons-toy-car/build/test-results/test/TEST-ElonsToyCarTest.xml new file mode 100644 index 0000000..d2a2858 --- /dev/null +++ b/elons-toy-car/build/test-results/test/TEST-ElonsToyCarTest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/elons-toy-car/build/test-results/test/binary/output.bin b/elons-toy-car/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/elons-toy-car/build/test-results/test/binary/output.bin.idx b/elons-toy-car/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/elons-toy-car/build/test-results/test/binary/output.bin.idx differ diff --git a/elons-toy-car/build/test-results/test/binary/results.bin b/elons-toy-car/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..b0787f5 Binary files /dev/null and b/elons-toy-car/build/test-results/test/binary/results.bin differ diff --git a/elons-toy-car/build/tmp/compileJava/previous-compilation-data.bin b/elons-toy-car/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..93c3f55 Binary files /dev/null and b/elons-toy-car/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/elons-toy-car/build/tmp/compileTestJava/previous-compilation-data.bin b/elons-toy-car/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..6811c2a Binary files /dev/null and b/elons-toy-car/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/elons-toy-car/gradle/wrapper/gradle-wrapper.jar b/elons-toy-car/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/elons-toy-car/gradle/wrapper/gradle-wrapper.jar differ diff --git a/elons-toy-car/gradle/wrapper/gradle-wrapper.properties b/elons-toy-car/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/elons-toy-car/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/elons-toy-car/gradlew b/elons-toy-car/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/elons-toy-car/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/elons-toy-car/gradlew.bat b/elons-toy-car/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/elons-toy-car/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/elons-toy-car/src/main/java/ElonsToyCar.java b/elons-toy-car/src/main/java/ElonsToyCar.java new file mode 100644 index 0000000..811cb1e --- /dev/null +++ b/elons-toy-car/src/main/java/ElonsToyCar.java @@ -0,0 +1,27 @@ +public class ElonsToyCar { + private int meters; + private int percentage; + + public ElonsToyCar() { + meters = 0; + percentage = 100; + } + public static ElonsToyCar buy() { + return new ElonsToyCar(); + } + + public String distanceDisplay() { + return "Driven " + meters + " meters"; + } + + public String batteryDisplay() { + if(percentage <= 0) return "Battery empty"; + return "Battery at " + percentage + "%"; + } + + public void drive() { + if(percentage <=0) return; + meters += 20; + percentage--; + } +} diff --git a/elons-toy-car/src/test/java/ElonsToyCarTest.java b/elons-toy-car/src/test/java/ElonsToyCarTest.java new file mode 100644 index 0000000..349a23f --- /dev/null +++ b/elons-toy-car/src/test/java/ElonsToyCarTest.java @@ -0,0 +1,97 @@ +import org.junit.Test; + +import static org.assertj.core.api.Assertions.*; + +public class ElonsToyCarTest { + @Test + public void buy_new_car_returns_instance() { + ElonsToyCar car = ElonsToyCar.buy(); + assertThat(car).isNotNull(); + } + + @Test + public void buy_new_car_returns_new_car_each_time() { + ElonsToyCar car1 = ElonsToyCar.buy(); + ElonsToyCar car2 = ElonsToyCar.buy(); + assertThat(car1).isNotEqualTo(car2); + } + + @Test + public void new_car_distance_display() { + ElonsToyCar car = new ElonsToyCar(); + assertThat(car.distanceDisplay()).isEqualTo("Driven 0 meters"); + } + + @Test + public void new_car_battery_display() { + ElonsToyCar car = new ElonsToyCar(); + assertThat(car.batteryDisplay()).isEqualTo("Battery at 100%"); + } + + @Test + public void distance_display_after_driving_once() { + ElonsToyCar car = new ElonsToyCar(); + car.drive(); + assertThat(car.distanceDisplay()).isEqualTo("Driven 20 meters"); + } + + @Test + public void distance_display_after_driving_multiple_times() { + ElonsToyCar car = new ElonsToyCar(); + + for (int i = 0; i < 17; i++) { + car.drive(); + } + + assertThat(car.distanceDisplay()).isEqualTo("Driven 340 meters"); + } + + @Test + public void battery_display_after_driving_once() { + ElonsToyCar car = new ElonsToyCar(); + car.drive(); + + assertThat(car.batteryDisplay()).isEqualTo("Battery at 99%"); + } + + @Test + public void battery_display_after_driving_multiple_times() { + ElonsToyCar car = new ElonsToyCar(); + + for (int i = 0; i < 23; i++) { + car.drive(); + } + + assertThat(car.batteryDisplay()).isEqualTo("Battery at 77%"); + } + + @Test + public void battery_display_when_battery_empty() { + ElonsToyCar car = new ElonsToyCar(); + + // Drain the battery + for (int i = 0; i < 100; i++) { + car.drive(); + } + + // Attempt to drive one more time (should not work) + car.drive(); + + assertThat(car.batteryDisplay()).isEqualTo("Battery empty"); + } + + @Test + public void distance_display_when_battery_empty() { + ElonsToyCar car = new ElonsToyCar(); + + // Drain the battery + for (int i = 0; i < 100; i++) { + car.drive(); + } + + // Attempt to drive one more time (should not work) + car.drive(); + + assertThat(car.distanceDisplay()).isEqualTo("Driven 2000 meters"); + } +} diff --git a/gigasecond/.exercism/config.json b/gigasecond/.exercism/config.json new file mode 100644 index 0000000..09cdfe5 --- /dev/null +++ b/gigasecond/.exercism/config.json @@ -0,0 +1,40 @@ +{ + "authors": [], + "contributors": [ + "FridaTveit", + "jmrunkle", + "jtigger", + "kytrinyx", + "lemoncurry", + "LukBukkit", + "matthewmorgan", + "mirkoperillo", + "morrme", + "msomji", + "muzimuzhi", + "SleeplessByte", + "Smarticles101", + "sshine", + "stkent", + "Valkryst", + "vdemeester", + "Zaldrick" + ], + "files": { + "solution": [ + "src/main/java/Gigasecond.java" + ], + "test": [ + "src/test/java/GigasecondTest.java" + ], + "example": [ + ".meta/src/reference/java/Gigasecond.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", + "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=09" +} diff --git a/gigasecond/.exercism/metadata.json b/gigasecond/.exercism/metadata.json new file mode 100644 index 0000000..03aefc9 --- /dev/null +++ b/gigasecond/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"gigasecond","id":"748d11fb993247d49c5192c22d8fb44b","url":"https://exercism.org/tracks/java/exercises/gigasecond","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/gigasecond/.gradle/7.5.1/checksums/checksums.lock b/gigasecond/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..2b0b103 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/gigasecond/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/gigasecond/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..5859125 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/gigasecond/.gradle/7.5.1/dependencies-accessors/gc.properties b/gigasecond/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.bin b/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..4015c73 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.lock b/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..2294dce Binary files /dev/null and b/gigasecond/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/gigasecond/.gradle/7.5.1/fileChanges/last-build.bin b/gigasecond/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.bin b/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..18a466d Binary files /dev/null and b/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.lock b/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..fd320d4 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/gigasecond/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/gigasecond/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..a7a0e82 Binary files /dev/null and b/gigasecond/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/gigasecond/.gradle/7.5.1/gc.properties b/gigasecond/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/gigasecond/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/gigasecond/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..9dcbcc4 Binary files /dev/null and b/gigasecond/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/gigasecond/.gradle/buildOutputCleanup/cache.properties b/gigasecond/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..40d8a62 --- /dev/null +++ b/gigasecond/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Mar 08 17:40:04 CET 2023 +gradle.version=7.5.1 diff --git a/gigasecond/.gradle/buildOutputCleanup/outputFiles.bin b/gigasecond/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..236bb71 Binary files /dev/null and b/gigasecond/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/gigasecond/.gradle/file-system.probe b/gigasecond/.gradle/file-system.probe new file mode 100644 index 0000000..de7051d Binary files /dev/null and b/gigasecond/.gradle/file-system.probe differ diff --git a/gigasecond/.gradle/vcs-1/gc.properties b/gigasecond/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/gigasecond/.idea/.gitignore b/gigasecond/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/gigasecond/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/gigasecond/.idea/compiler.xml b/gigasecond/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/gigasecond/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/gigasecond/.idea/gradle.xml b/gigasecond/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/gigasecond/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/gigasecond/.idea/jarRepositories.xml b/gigasecond/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/gigasecond/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/gigasecond/.idea/misc.xml b/gigasecond/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/gigasecond/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/gigasecond/HELP.md b/gigasecond/HELP.md new file mode 100644 index 0000000..ba05317 --- /dev/null +++ b/gigasecond/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/Gigasecond.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/gigasecond/README.md b/gigasecond/README.md new file mode 100644 index 0000000..4cc64a5 --- /dev/null +++ b/gigasecond/README.md @@ -0,0 +1,65 @@ +# Gigasecond + +Welcome to Gigasecond on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +The way we measure time is kind of messy. +We have 60 seconds in a minute, and 60 minutes in an hour. +This comes from ancient Babylon, where they used 60 as the basis for their number system. +We have 24 hours in a day, 7 days in a week, and how many days in a month? +Well, for days in a month it depends not only on which month it is, but also on what type of calendar is used in the country you live in. + +What if, instead, we only use seconds to express time intervals? +Then we can use metric system prefixes for writing large numbers of seconds in more easily comprehensible quantities. + +- A food recipe might explain that you need to let the brownies cook in the oven for two kiloseconds (that's two thousand seconds). +- Perhaps you and your family would travel to somewhere exotic for two megaseconds (that's two million seconds). +- And if you and your spouse were married for _a thousand million_ seconds, you would celebrate your one gigasecond anniversary. + +```exercism/note +If we ever colonize Mars or some other planet, measuring time is going to get even messier. +If someone says "year" do they mean a year on Earth or a year on Mars? + +The idea for this exercise came from the science fiction novel ["A Deepness in the Sky"][vinge-novel] by author Vernor Vinge. +In it the author uses the metric system as the basis for time measurements. + +[vinge-novel]: https://www.tor.com/2017/08/03/science-fiction-with-something-for-everyone-a-deepness-in-the-sky-by-vernor-vinge/ +``` + +## Instructions + +Your task is to determine the date and time one gigasecond after a certain date. + +A gigasecond is one thousand million seconds. +That is a one with nine zeros after it. + +If you were born on _January 24th, 2015 at 22:00 (10:00:00pm)_, then you would be a gigasecond old on _October 2nd, 2046 at 23:46:40 (11:46:40pm)_. + +## Source + +### Contributed to by + +- @FridaTveit +- @jmrunkle +- @jtigger +- @kytrinyx +- @lemoncurry +- @LukBukkit +- @matthewmorgan +- @mirkoperillo +- @morrme +- @msomji +- @muzimuzhi +- @SleeplessByte +- @Smarticles101 +- @sshine +- @stkent +- @Valkryst +- @vdemeester +- @Zaldrick + +### Based on + +Chapter 9 in Chris Pine's online Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=09 \ No newline at end of file diff --git a/gigasecond/build.gradle b/gigasecond/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/gigasecond/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/gigasecond/build/classes/java/main/Gigasecond.class b/gigasecond/build/classes/java/main/Gigasecond.class new file mode 100644 index 0000000..d02fea5 Binary files /dev/null and b/gigasecond/build/classes/java/main/Gigasecond.class differ diff --git a/gigasecond/build/classes/java/test/GigasecondTest.class b/gigasecond/build/classes/java/test/GigasecondTest.class new file mode 100644 index 0000000..93252e5 Binary files /dev/null and b/gigasecond/build/classes/java/test/GigasecondTest.class differ diff --git a/gigasecond/build/reports/tests/test/classes/GigasecondTest.html b/gigasecond/build/reports/tests/test/classes/GigasecondTest.html new file mode 100644 index 0000000..1c49c46 --- /dev/null +++ b/gigasecond/build/reports/tests/test/classes/GigasecondTest.html @@ -0,0 +1,116 @@ + + + + + +Test results - Class GigasecondTest + + + + + +
+

Class GigasecondTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.003s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
afterEpochTime0spassed
beforeEpochTime0spassed
modernTime0spassed
withFullTimeSpecified0.003spassed
withFullTimeSpecifiedAndDayRollover0spassed
+
+
+ +
+ + diff --git a/gigasecond/build/reports/tests/test/css/base-style.css b/gigasecond/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/gigasecond/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/gigasecond/build/reports/tests/test/css/style.css b/gigasecond/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/gigasecond/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/gigasecond/build/reports/tests/test/index.html b/gigasecond/build/reports/tests/test/index.html new file mode 100644 index 0000000..00849ab --- /dev/null +++ b/gigasecond/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.003s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +5000.003s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+GigasecondTest +5000.003s100%
+
+
+ +
+ + diff --git a/gigasecond/build/reports/tests/test/js/report.js b/gigasecond/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/gigasecond/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/gigasecond/build/reports/tests/test/packages/default-package.html b/gigasecond/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..da9fef3 --- /dev/null +++ b/gigasecond/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.003s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+GigasecondTest +5000.003s100%
+
+
+ +
+ + diff --git a/gigasecond/build/test-results/test/TEST-GigasecondTest.xml b/gigasecond/build/test-results/test/TEST-GigasecondTest.xml new file mode 100644 index 0000000..8c1e161 --- /dev/null +++ b/gigasecond/build/test-results/test/TEST-GigasecondTest.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/gigasecond/build/test-results/test/binary/output.bin b/gigasecond/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/gigasecond/build/test-results/test/binary/output.bin.idx b/gigasecond/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/gigasecond/build/test-results/test/binary/output.bin.idx differ diff --git a/gigasecond/build/test-results/test/binary/results.bin b/gigasecond/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..44be169 Binary files /dev/null and b/gigasecond/build/test-results/test/binary/results.bin differ diff --git a/gigasecond/build/tmp/compileJava/previous-compilation-data.bin b/gigasecond/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..4ceea0d Binary files /dev/null and b/gigasecond/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/gigasecond/build/tmp/compileTestJava/previous-compilation-data.bin b/gigasecond/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..6a5a941 Binary files /dev/null and b/gigasecond/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/gigasecond/gradle/wrapper/gradle-wrapper.jar b/gigasecond/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/gigasecond/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gigasecond/gradle/wrapper/gradle-wrapper.properties b/gigasecond/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/gigasecond/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gigasecond/gradlew b/gigasecond/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/gigasecond/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gigasecond/gradlew.bat b/gigasecond/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/gigasecond/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/gigasecond/src/main/java/Gigasecond.java b/gigasecond/src/main/java/Gigasecond.java new file mode 100644 index 0000000..ed89a72 --- /dev/null +++ b/gigasecond/src/main/java/Gigasecond.java @@ -0,0 +1,18 @@ +import java.time.LocalDate; +import java.time.LocalDateTime; + +public class Gigasecond { + private long seconds = 1000000000; + LocalDateTime afterGiga; + public Gigasecond(LocalDate moment) { + this.afterGiga = moment.atStartOfDay(); + } + + public Gigasecond(LocalDateTime moment) { + this.afterGiga = moment; + } + + public LocalDateTime getDateTime() { + return afterGiga.plusSeconds(seconds); + } +} diff --git a/gigasecond/src/test/java/GigasecondTest.java b/gigasecond/src/test/java/GigasecondTest.java new file mode 100644 index 0000000..23e9e5a --- /dev/null +++ b/gigasecond/src/test/java/GigasecondTest.java @@ -0,0 +1,46 @@ +import org.junit.Test; +import org.junit.Ignore; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; + +import static org.junit.Assert.assertEquals; + +public class GigasecondTest { + + @Test + public void modernTime() { + Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25)); + + assertEquals(LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40), gigaSecond.getDateTime()); + } + + @Test + public void afterEpochTime() { + Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13)); + + assertEquals(LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40), gigaSecond.getDateTime()); + } + + @Test + public void beforeEpochTime() { + Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19)); + + assertEquals(LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40), gigaSecond.getDateTime()); + } + + @Test + public void withFullTimeSpecified() { + Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0)); + + assertEquals(LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40), gigaSecond.getDateTime()); + } + + @Test + public void withFullTimeSpecifiedAndDayRollover() { + Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59)); + + assertEquals(LocalDateTime.of(2046, Month.OCTOBER, 3, 1, 46, 39), gigaSecond.getDateTime()); + } +} diff --git a/hamming/.exercism/config.json b/hamming/.exercism/config.json new file mode 100644 index 0000000..67e4966 --- /dev/null +++ b/hamming/.exercism/config.json @@ -0,0 +1,49 @@ +{ + "authors": [ + "wdjunaidi" + ], + "contributors": [ + "c-thornton", + "ChristianWilkie", + "FridaTveit", + "javaeeeee", + "jmrunkle", + "jonnynabors", + "jtigger", + "kytrinyx", + "lemoncurry", + "matthewmorgan", + "michael-berger-FR", + "michaelspets", + "mirkoperillo", + "msomji", + "muzimuzhi", + "odzeno", + "sjwarner-bp", + "SleeplessByte", + "Smarticles101", + "sshine", + "stkent", + "t0dd", + "Valkryst", + "vasouv", + "Zaldrick" + ], + "files": { + "solution": [ + "src/main/java/Hamming.java" + ], + "test": [ + "src/test/java/HammingTest.java" + ], + "example": [ + ".meta/src/reference/java/Hamming.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Calculate the Hamming difference between two DNA strands.", + "source": "The Calculating Point Mutations problem at Rosalind", + "source_url": "http://rosalind.info/problems/hamm/" +} diff --git a/hamming/.exercism/metadata.json b/hamming/.exercism/metadata.json new file mode 100644 index 0000000..dcf113b --- /dev/null +++ b/hamming/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"hamming","id":"3935f75ded4a4915b3a9d6ba595ad807","url":"https://exercism.org/tracks/java/exercises/hamming","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/hamming/.gradle/7.5.1/checksums/checksums.lock b/hamming/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..49e9d0a Binary files /dev/null and b/hamming/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/hamming/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/hamming/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..c3c5e8d Binary files /dev/null and b/hamming/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/hamming/.gradle/7.5.1/dependencies-accessors/gc.properties b/hamming/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/hamming/.gradle/7.5.1/executionHistory/executionHistory.bin b/hamming/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..ed491df Binary files /dev/null and b/hamming/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/hamming/.gradle/7.5.1/executionHistory/executionHistory.lock b/hamming/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..f77a406 Binary files /dev/null and b/hamming/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/hamming/.gradle/7.5.1/fileChanges/last-build.bin b/hamming/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/hamming/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/hamming/.gradle/7.5.1/fileHashes/fileHashes.bin b/hamming/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..0d8dea2 Binary files /dev/null and b/hamming/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/hamming/.gradle/7.5.1/fileHashes/fileHashes.lock b/hamming/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..b94f715 Binary files /dev/null and b/hamming/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/hamming/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/hamming/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..e7d0fe2 Binary files /dev/null and b/hamming/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/hamming/.gradle/7.5.1/gc.properties b/hamming/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/hamming/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/hamming/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..58d2d50 Binary files /dev/null and b/hamming/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/hamming/.gradle/buildOutputCleanup/cache.properties b/hamming/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..2844e03 --- /dev/null +++ b/hamming/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 19:09:01 CET 2023 +gradle.version=7.5.1 diff --git a/hamming/.gradle/buildOutputCleanup/outputFiles.bin b/hamming/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..0e3a39b Binary files /dev/null and b/hamming/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/hamming/.gradle/file-system.probe b/hamming/.gradle/file-system.probe new file mode 100644 index 0000000..eaf2e2f Binary files /dev/null and b/hamming/.gradle/file-system.probe differ diff --git a/hamming/.gradle/vcs-1/gc.properties b/hamming/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/hamming/.idea/.gitignore b/hamming/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/hamming/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/hamming/.idea/compiler.xml b/hamming/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/hamming/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/hamming/.idea/gradle.xml b/hamming/.idea/gradle.xml new file mode 100644 index 0000000..611e7c8 --- /dev/null +++ b/hamming/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/hamming/.idea/jarRepositories.xml b/hamming/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/hamming/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/hamming/.idea/misc.xml b/hamming/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/hamming/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hamming/HELP.md b/hamming/HELP.md new file mode 100644 index 0000000..08abfbc --- /dev/null +++ b/hamming/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/Hamming.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/hamming/README.md b/hamming/README.md new file mode 100644 index 0000000..cdf6774 --- /dev/null +++ b/hamming/README.md @@ -0,0 +1,76 @@ +# Hamming + +Welcome to Hamming on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Calculate the Hamming Distance between two DNA strands. + +Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! + +When cells divide, their DNA replicates too. Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. This is known as the "Hamming Distance". + +We read DNA using the letters C,A,G and T. Two strands might look like this: + + GAGCCTACTAACGGGAT + CATCGTAATGACGGCCT + ^ ^ ^ ^ ^ ^^ + +They have 7 differences, and therefore the Hamming Distance is 7. + +The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) + +The Hamming distance is only defined for sequences of equal length, so +an attempt to calculate it between sequences of different lengths should +not work. The general handling of this situation (e.g., raising an +exception vs returning a special value) may differ between languages. + +This is the first exercise with tests that require you to throw an +[`Exception`](https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html). `Exception`s are typically thrown to +indicate that a program has encountered an unexpected input or state. + +We use JUnit's [`ExpectedException`](http://junit.org/junit4/javadoc/4.12/org/junit/rules/ExpectedException.html) +[rule](https://github.com/junit-team/junit4/wiki/rules) throughout the track to verify that the exceptions you throw +are: + +1. instances of a specified Java type; +2. (optionally) initialized with a specified message. + +## Source + +### Created by + +- @wdjunaidi + +### Contributed to by + +- @c-thornton +- @ChristianWilkie +- @FridaTveit +- @javaeeeee +- @jmrunkle +- @jonnynabors +- @jtigger +- @kytrinyx +- @lemoncurry +- @matthewmorgan +- @michael-berger-FR +- @michaelspets +- @mirkoperillo +- @msomji +- @muzimuzhi +- @odzeno +- @sjwarner-bp +- @SleeplessByte +- @Smarticles101 +- @sshine +- @stkent +- @t0dd +- @Valkryst +- @vasouv +- @Zaldrick + +### Based on + +The Calculating Point Mutations problem at Rosalind - http://rosalind.info/problems/hamm/ \ No newline at end of file diff --git a/hamming/build.gradle b/hamming/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/hamming/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/hamming/build/classes/java/main/Hamming.class b/hamming/build/classes/java/main/Hamming.class new file mode 100644 index 0000000..69cd7ed Binary files /dev/null and b/hamming/build/classes/java/main/Hamming.class differ diff --git a/hamming/build/classes/java/test/HammingTest.class b/hamming/build/classes/java/test/HammingTest.class new file mode 100644 index 0000000..ebfd0a3 Binary files /dev/null and b/hamming/build/classes/java/test/HammingTest.class differ diff --git a/hamming/build/reports/tests/test/classes/HammingTest.html b/hamming/build/reports/tests/test/classes/HammingTest.html new file mode 100644 index 0000000..973b7dc --- /dev/null +++ b/hamming/build/reports/tests/test/classes/HammingTest.html @@ -0,0 +1,136 @@ + + + + + +Test results - Class HammingTest + + + + + +
+

Class HammingTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
testCompleteDistanceInSingleLetterDifferentStrands0.026spassed
testDisallowLeftEmptyStrand0.002spassed
testDisallowRightEmptyStrand0spassed
testDistanceInLongDifferentStrands0spassed
testDistanceInLongIdenticalStrands0spassed
testNoDistanceBetweenEmptyStrands0spassed
testNoDistanceBetweenShortIdenticalStrands0spassed
testValidatesFirstStrandNotLonger0spassed
testValidatesSecondStrandNotLonger0spassed
+
+
+ +
+ + diff --git a/hamming/build/reports/tests/test/css/base-style.css b/hamming/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/hamming/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/hamming/build/reports/tests/test/css/style.css b/hamming/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/hamming/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/hamming/build/reports/tests/test/index.html b/hamming/build/reports/tests/test/index.html new file mode 100644 index 0000000..c2d139e --- /dev/null +++ b/hamming/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +9000.028s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+HammingTest +9000.028s100%
+
+
+ +
+ + diff --git a/hamming/build/reports/tests/test/js/report.js b/hamming/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/hamming/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/hamming/build/reports/tests/test/packages/default-package.html b/hamming/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..4fc4825 --- /dev/null +++ b/hamming/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
9
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+HammingTest +9000.028s100%
+
+
+ +
+ + diff --git a/hamming/build/test-results/test/TEST-HammingTest.xml b/hamming/build/test-results/test/TEST-HammingTest.xml new file mode 100644 index 0000000..ce08aaa --- /dev/null +++ b/hamming/build/test-results/test/TEST-HammingTest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/hamming/build/test-results/test/binary/output.bin b/hamming/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/hamming/build/test-results/test/binary/output.bin.idx b/hamming/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/hamming/build/test-results/test/binary/output.bin.idx differ diff --git a/hamming/build/test-results/test/binary/results.bin b/hamming/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..eccfe04 Binary files /dev/null and b/hamming/build/test-results/test/binary/results.bin differ diff --git a/hamming/build/tmp/compileJava/previous-compilation-data.bin b/hamming/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..c092959 Binary files /dev/null and b/hamming/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/hamming/build/tmp/compileTestJava/previous-compilation-data.bin b/hamming/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..3e58f67 Binary files /dev/null and b/hamming/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/hamming/gradle/wrapper/gradle-wrapper.jar b/hamming/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/hamming/gradle/wrapper/gradle-wrapper.jar differ diff --git a/hamming/gradle/wrapper/gradle-wrapper.properties b/hamming/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/hamming/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/hamming/gradlew b/hamming/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/hamming/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/hamming/gradlew.bat b/hamming/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/hamming/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/hamming/src/main/java/Hamming.java b/hamming/src/main/java/Hamming.java new file mode 100644 index 0000000..1bb4dc1 --- /dev/null +++ b/hamming/src/main/java/Hamming.java @@ -0,0 +1,23 @@ +public class Hamming { + private String leftStrand; + private String rightStrand; + public Hamming(String leftStrand, String rightStrand) { + if(!(leftStrand.length() == 0 && rightStrand.length() == 0)) { + if(leftStrand.length() == 0) throw new IllegalArgumentException("left strand must not be empty."); + if(rightStrand.length() == 0) throw new IllegalArgumentException("right strand must not be empty."); + } + + if(leftStrand.length() != rightStrand.length()) throw new IllegalArgumentException("leftStrand and rightStrand must be of equal length."); + this.leftStrand = leftStrand; + this.rightStrand = rightStrand; + } + + public int getHammingDistance() { + int hamming = 0; + for(int i = 0; i < leftStrand.length(); i++) { + if(leftStrand.charAt(i) != rightStrand.charAt(i)) hamming++; + } + + return hamming; + } +} diff --git a/hamming/src/test/java/HammingTest.java b/hamming/src/test/java/HammingTest.java new file mode 100644 index 0000000..bbed560 --- /dev/null +++ b/hamming/src/test/java/HammingTest.java @@ -0,0 +1,62 @@ +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +import org.junit.Ignore; +import org.junit.Test; + +public class HammingTest { + + @Test + public void testNoDistanceBetweenEmptyStrands() { + assertThat(new Hamming("", "").getHammingDistance()).isEqualTo(0); + } + + @Test + public void testNoDistanceBetweenShortIdenticalStrands() { + assertThat(new Hamming("A", "A").getHammingDistance()).isEqualTo(0); + } + + @Test + public void testCompleteDistanceInSingleLetterDifferentStrands() { + assertThat(new Hamming("G", "T").getHammingDistance()).isEqualTo(1); + } + + @Test + public void testDistanceInLongIdenticalStrands() { + assertThat(new Hamming("GGACTGAAATCTG", "GGACTGAAATCTG").getHammingDistance()).isEqualTo(0); + } + + @Test + public void testDistanceInLongDifferentStrands() { + assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance()).isEqualTo(9); + } + + @Test + public void testValidatesFirstStrandNotLonger() { + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> new Hamming("AATG", "AAA")) + .withMessage("leftStrand and rightStrand must be of equal length."); + } + + @Test + public void testValidatesSecondStrandNotLonger() { + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> new Hamming("ATA", "AGTG")) + .withMessage("leftStrand and rightStrand must be of equal length."); + } + + @Test + public void testDisallowLeftEmptyStrand() { + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> new Hamming("", "G")) + .withMessage("left strand must not be empty."); + } + + @Test + public void testDisallowRightEmptyStrand() { + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> new Hamming("G", "")) + .withMessage("right strand must not be empty."); + } + +} diff --git a/karls-languages/.exercism/config.json b/karls-languages/.exercism/config.json new file mode 100644 index 0000000..2315fc3 --- /dev/null +++ b/karls-languages/.exercism/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "jmrunkle" + ], + "files": { + "solution": [ + "src/main/java/LanguageList.java" + ], + "test": [ + "src/test/java/LanguageListTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/LanguageList.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "icon": "language-list", + "blurb": "Learn about lists by helping Karl keep track of the languages he wants to learn on Exercism." +} diff --git a/karls-languages/.exercism/metadata.json b/karls-languages/.exercism/metadata.json new file mode 100644 index 0000000..5bf77f2 --- /dev/null +++ b/karls-languages/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"karls-languages","id":"6d0efea5b2474ac9bc05f47cef326263","url":"https://exercism.org/tracks/java/exercises/karls-languages","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/karls-languages/.gradle/7.5.1/checksums/checksums.lock b/karls-languages/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..0659217 Binary files /dev/null and b/karls-languages/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/karls-languages/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/karls-languages/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..a97ffc5 Binary files /dev/null and b/karls-languages/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/karls-languages/.gradle/7.5.1/dependencies-accessors/gc.properties b/karls-languages/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.bin b/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..fd5d2b5 Binary files /dev/null and b/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.lock b/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..7e27110 Binary files /dev/null and b/karls-languages/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/karls-languages/.gradle/7.5.1/fileChanges/last-build.bin b/karls-languages/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/karls-languages/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.bin b/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..bcb8dff Binary files /dev/null and b/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.lock b/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..331949d Binary files /dev/null and b/karls-languages/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/karls-languages/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/karls-languages/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..aa6e0ae Binary files /dev/null and b/karls-languages/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/karls-languages/.gradle/7.5.1/gc.properties b/karls-languages/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/karls-languages/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/karls-languages/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..214f0cf Binary files /dev/null and b/karls-languages/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/karls-languages/.gradle/buildOutputCleanup/cache.properties b/karls-languages/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..58ebfaa --- /dev/null +++ b/karls-languages/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 18:38:49 CET 2023 +gradle.version=7.5.1 diff --git a/karls-languages/.gradle/buildOutputCleanup/outputFiles.bin b/karls-languages/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..75e6d2f Binary files /dev/null and b/karls-languages/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/karls-languages/.gradle/file-system.probe b/karls-languages/.gradle/file-system.probe new file mode 100644 index 0000000..3a9dada Binary files /dev/null and b/karls-languages/.gradle/file-system.probe differ diff --git a/karls-languages/.gradle/vcs-1/gc.properties b/karls-languages/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/karls-languages/.idea/.gitignore b/karls-languages/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/karls-languages/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/karls-languages/.idea/compiler.xml b/karls-languages/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/karls-languages/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/karls-languages/.idea/gradle.xml b/karls-languages/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/karls-languages/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/karls-languages/.idea/jarRepositories.xml b/karls-languages/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/karls-languages/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/karls-languages/.idea/misc.xml b/karls-languages/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/karls-languages/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/karls-languages/HELP.md b/karls-languages/HELP.md new file mode 100644 index 0000000..7c68701 --- /dev/null +++ b/karls-languages/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/LanguageList.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/karls-languages/HINTS.md b/karls-languages/HINTS.md new file mode 100644 index 0000000..0c4e5a0 --- /dev/null +++ b/karls-languages/HINTS.md @@ -0,0 +1,32 @@ +# Hints + +## 1. Define a function to check if the language list is empty + +* Try using the [`isEmpty()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#isEmpty()) method. + +## 2. Define a function to add a language to the list + +* Try using the [`add(E element)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#add(E)) method. +* Reminder: methods that return `void` do not need any `return` statements. + +## 3. Define a function to remove a language from the list + +* Try using the [`remove(Object o)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#remove(java.lang.Object)) method. +* Reminder: methods that return `void` do not need any `return` statements. + +## 4. Define a function to return the first item in the list + +* Try using the [`get(int index)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#get(int)) method. + +## 5. Define a function to return how many languages are in the list + +* Try using the [`size()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#size()) method. + +## 6. Define a function to determine if a language is in the list + +* Try using the [`contains(Object o)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#contains(java.lang.Object)) method. + +## 7. Define a function to determine if the list is exciting + +* Try using a [for-each loop](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html) through all of the elements, checking each one. +* Alternatively, try using the `containsLanguage` method from the previous step. \ No newline at end of file diff --git a/karls-languages/README.md b/karls-languages/README.md new file mode 100644 index 0000000..800e19c --- /dev/null +++ b/karls-languages/README.md @@ -0,0 +1,169 @@ +# Karl's Languages + +Welcome to Karl's Languages on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +## Generic Types + +A **generic type** is a generic class or interface that is parameterized over types. +This allows the compiler to enforce type safety on the class or interface. + +Consider this non-generic `Container` interface: + +```java +class Container { + private Object object; + + public void set(Object object) { this.object = object; } + public Object get() { return object; } +} +``` + +Since it accepts and returns Object types, it works with any non-primitive type. +However, this comes at a cost because some code may call `get` expecting `Integer`s while other code calls `set` adding `String`s resulting in a runtime exception. + +A **generic class** and **generic interface** have the following formats: + +```java +class ClassName { ... } +interface InterfaceName { ... } +``` + +The type parameter section, delimited by angle brackets (`<>`), following the class or interface name specifies the type parameters (also called type variables) `T1`, `T2`, ..., and `Tn`. +These can be used inside the body of the class or interface to get generic type safety. + +Here is the generic version of `Container`: + +```java +class Container { + private E object; + + public void set(E object) { this.object = object; } + public E get() { return object; } +} +``` + +When created, now we have to declare what type it holds and the compiler will enforce that constraint: + +```java +// empty <> can infer from context +Container stringContainer = new Container<>(); +// compiler knows this is a String, so it is allowed +stringContainer.set("Some string"); +// no cast needed, compiler knows it is a String +String result = stringContainer.get(); +// this causes a compiler error: +stringContainer.set(42); +``` + +## Lists + +**Lists** are the ordered sequence collection in Java. +Unlike arrays, a [`List`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html) can grow in size to accomodate any number of items. +One standard implementation is the `ArrayList` which is backed by a re-sizable array. +Another standard implementation is the `LinkedList` class which is backed by a doubly-linked list. + +`List`s may be empty or hold any number of items (including duplicates). +`List`s are a **generic interface** typed to indicate which type of objects they can contain. +For example: + +```java +List emptyListOfStrings = List.of(); +List singleInteger = List.of(1); +List threeBooleans = List.of(true, false, true); +List listWithMulitipleTypes = List.of("hello", 1, true); +``` + +`List`s have various helpful methods to add, remove, get, and check for an element to be present: + +```java +List vowels = new ArrayList<>(List.of('a', 'e', 'i', 'o', 'i', 'e', 'a')); +int startingSize = vowels.size(); // 7 +vowels.add('u'); // vowels is now ['a', 'e', 'i', 'o', 'i', 'e', 'a', 'u'] +char a = vowels.get(0); // 'a' +boolean hadI = vowels.remove('i'); // true and vowels is now ['a', 'e', 'o', 'i', 'e', 'a', 'u'] +boolean hasI = vowels.contains('i'); // true (still have one more left) +``` + +## Instructions + +Karl wants to keep track of a list of languages to learn on Exercism's website. +Karl needs to be able to add new languages, remove old ones and check if certain languages are in the list. +It would be very exciting if Karl wants to learn Java or Kotlin! + +## 1. Define a function to check if the language list is empty + +Karl needs to know if his list of languages ever becomes empty so he can go find more to learn! +Define a method called `isEmpty` which returns `true` if there are no languages in the list. + +```java +if (languageList.isEmpty()) { + findMoreLanguagesToLearn(); +} +``` + +## 2. Define a function to add a language to the list + +Karl is looking forward to learning Kotlin and Python! +Help Karl get started by defining a method called `addLanguage` which takes the language he wants to learn and adds it to the list. + +```java +languageList.addLanguage("Kotlin"); +languageList.addLanguage("Python"); +``` + +## 3. Define a function to remove a language from the list + +Karl decided he does not want to learn Scala right now. +Help Karl remove it from the list by defining a method called `removeLanguage` which takes the language he is removing and removes it from the list. + +```java +languageList.removeLanguage("Scala"); +``` + +## 4. Define a function to return the first item in the list + +Karl wants to remember the first language he added to the list (that is still in the list). +Define a method called `firstLanguage` that returns the first language in the list. + +```java +String kotlin = languageList.firstLanguage(); // "Kotlin" +``` + +## 5. Define a function to return how many languages are in the list + +Karl needs to know how many languages he is trying to learn. +Help Karl find the answer by defining a method called `count` which returns the number of languages in the list. + +```java +int two = languageList.count(); // 2 +``` + +## 6. Define a function to determine if a language is in the list + +Karl is trying to remember if he wanted to learn Python or Ruby. +Define a method called `containsLanguage` which takes the language he is asking about so Karl can find out! + +```java +boolean learningPython = languageList.containsLanguage("Python"); // true +boolean learningRuby = languageList.containsLanguage("Ruby"); // false +``` + +## 7. Define a function to determine if the list is exciting + +If Karl wants to learn Java or Kotlin, that is very exciting! +Define a method called `isExciting` that returns true if Karl wants to learn Java or Kotlin. + +```java +javaLanguageList.isExciting() // true +neitherKotlinNorJavaLanguageList.isExciting() // false +``` + +## Source + +### Created by + +- @jmrunkle \ No newline at end of file diff --git a/karls-languages/build.gradle b/karls-languages/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/karls-languages/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/karls-languages/build/classes/java/main/LanguageList.class b/karls-languages/build/classes/java/main/LanguageList.class new file mode 100644 index 0000000..69ae505 Binary files /dev/null and b/karls-languages/build/classes/java/main/LanguageList.class differ diff --git a/karls-languages/build/classes/java/test/LanguageListTest.class b/karls-languages/build/classes/java/test/LanguageListTest.class new file mode 100644 index 0000000..4273a5f Binary files /dev/null and b/karls-languages/build/classes/java/test/LanguageListTest.class differ diff --git a/karls-languages/build/reports/tests/test/classes/LanguageListTest.html b/karls-languages/build/reports/tests/test/classes/LanguageListTest.html new file mode 100644 index 0000000..579a97b --- /dev/null +++ b/karls-languages/build/reports/tests/test/classes/LanguageListTest.html @@ -0,0 +1,146 @@ + + + + + +Test results - Class LanguageListTest + + + + + +
+

Class LanguageListTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.027s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
addMultipleLanguages0.024spassed
addOneLanguage0spassed
boringLanguageList0spassed
countEmpty0.002spassed
countThree0spassed
empty0spassed
excitingLanguageListWithJava0spassed
excitingLanguageListWithKotlin0spassed
firstLanguage0.001spassed
nonEmpty0spassed
removeLanguage0spassed
+
+
+ +
+ + diff --git a/karls-languages/build/reports/tests/test/css/base-style.css b/karls-languages/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/karls-languages/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/karls-languages/build/reports/tests/test/css/style.css b/karls-languages/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/karls-languages/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/karls-languages/build/reports/tests/test/index.html b/karls-languages/build/reports/tests/test/index.html new file mode 100644 index 0000000..c841016 --- /dev/null +++ b/karls-languages/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.027s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +11000.027s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+LanguageListTest +11000.027s100%
+
+
+ +
+ + diff --git a/karls-languages/build/reports/tests/test/js/report.js b/karls-languages/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/karls-languages/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/karls-languages/build/reports/tests/test/packages/default-package.html b/karls-languages/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..329ffe2 --- /dev/null +++ b/karls-languages/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.027s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+LanguageListTest +11000.027s100%
+
+
+ +
+ + diff --git a/karls-languages/build/test-results/test/TEST-LanguageListTest.xml b/karls-languages/build/test-results/test/TEST-LanguageListTest.xml new file mode 100644 index 0000000..248a29e --- /dev/null +++ b/karls-languages/build/test-results/test/TEST-LanguageListTest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/karls-languages/build/test-results/test/binary/output.bin b/karls-languages/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/karls-languages/build/test-results/test/binary/output.bin.idx b/karls-languages/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/karls-languages/build/test-results/test/binary/output.bin.idx differ diff --git a/karls-languages/build/test-results/test/binary/results.bin b/karls-languages/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..feeab9b Binary files /dev/null and b/karls-languages/build/test-results/test/binary/results.bin differ diff --git a/karls-languages/build/tmp/compileJava/previous-compilation-data.bin b/karls-languages/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..0865b4e Binary files /dev/null and b/karls-languages/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/karls-languages/build/tmp/compileTestJava/previous-compilation-data.bin b/karls-languages/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..28b28b9 Binary files /dev/null and b/karls-languages/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/karls-languages/gradle/wrapper/gradle-wrapper.jar b/karls-languages/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/karls-languages/gradle/wrapper/gradle-wrapper.jar differ diff --git a/karls-languages/gradle/wrapper/gradle-wrapper.properties b/karls-languages/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/karls-languages/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/karls-languages/gradlew b/karls-languages/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/karls-languages/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/karls-languages/gradlew.bat b/karls-languages/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/karls-languages/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/karls-languages/src/main/java/LanguageList.java b/karls-languages/src/main/java/LanguageList.java new file mode 100644 index 0000000..de1f2a2 --- /dev/null +++ b/karls-languages/src/main/java/LanguageList.java @@ -0,0 +1,34 @@ +import java.util.ArrayList; +import java.util.List; + +public class LanguageList { + private final List languages = new ArrayList<>(); + + public boolean isEmpty() { + return languages.isEmpty(); + } + + public void addLanguage(String language) { + languages.add(language); + } + + public void removeLanguage(String language) { + languages.remove(language); + } + + public String firstLanguage() { + return languages.get(0); + } + + public int count() { + return languages.size(); + } + + public boolean containsLanguage(String language) { + return languages.contains(language); + } + + public boolean isExciting() { + return (languages.contains("Java") || languages.contains("Kotlin")); + } +} diff --git a/karls-languages/src/test/java/LanguageListTest.java b/karls-languages/src/test/java/LanguageListTest.java new file mode 100644 index 0000000..c618e33 --- /dev/null +++ b/karls-languages/src/test/java/LanguageListTest.java @@ -0,0 +1,100 @@ +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class LanguageListTest { + + LanguageList languageList = new LanguageList(); + + @Test + public void empty() { + assertThat(languageList.isEmpty()).isTrue(); + } + + @Test + public void nonEmpty() { + languageList.addLanguage("Java"); + + assertThat(languageList.isEmpty()).isFalse(); + } + + @Test + public void addOneLanguage() { + languageList.addLanguage("Java"); + + assertThat(languageList.containsLanguage("Java")).isTrue(); + assertThat(languageList.containsLanguage("Python")).isFalse(); + } + + @Test + public void addMultipleLanguages() { + languageList.addLanguage("Java"); + languageList.addLanguage("Ruby"); + languageList.addLanguage("C++"); + + assertThat(languageList.containsLanguage("Java")).isTrue(); + assertThat(languageList.containsLanguage("Ruby")).isTrue(); + assertThat(languageList.containsLanguage("C++")).isTrue(); + assertThat(languageList.containsLanguage("Python")).isFalse(); + } + + @Test + public void removeLanguage() { + languageList.addLanguage("Java"); + languageList.addLanguage("Python"); + languageList.addLanguage("Ruby"); + + languageList.removeLanguage("Python"); + + assertThat(languageList.containsLanguage("Java")).isTrue(); + assertThat(languageList.containsLanguage("Python")).isFalse(); + assertThat(languageList.containsLanguage("Ruby")).isTrue(); + } + + @Test + public void firstLanguage() { + languageList.addLanguage("Java"); + languageList.addLanguage("Python"); + languageList.addLanguage("Ruby"); + + assertThat(languageList.firstLanguage()).isEqualTo("Java"); + } + + @Test + public void countThree() { + languageList.addLanguage("Java"); + languageList.addLanguage("Python"); + languageList.addLanguage("Ruby"); + + assertThat(languageList.count()).isEqualTo(3); + } + + @Test + public void countEmpty() { + assertThat(languageList.count()).isEqualTo(0); + } + + @Test + public void excitingLanguageListWithJava() { + languageList.addLanguage("Java"); + + assertThat(languageList.isExciting()).isTrue(); + } + + @Test + public void excitingLanguageListWithKotlin() { + languageList.addLanguage("Python"); + languageList.addLanguage("Kotlin"); + + assertThat(languageList.isExciting()).isTrue(); + } + + @Test + public void boringLanguageList() { + languageList.addLanguage("Python"); + languageList.addLanguage("Ruby"); + languageList.addLanguage("C++"); + + assertThat(languageList.isExciting()).isFalse(); + } +} diff --git a/lasagna/.exercism/config.json b/lasagna/.exercism/config.json new file mode 100644 index 0000000..9cf76ed --- /dev/null +++ b/lasagna/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "mirkoperillo" + ], + "files": { + "solution": [ + "src/main/java/Lasagna.java" + ], + "test": [ + "src/test/java/LasagnaTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/Lasagna.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/lucians-luscious-lasagna" + ], + "blurb": "Learn about the basics of Java by following a lasagna recipe." +} diff --git a/lasagna/.exercism/metadata.json b/lasagna/.exercism/metadata.json new file mode 100644 index 0000000..8e03dd0 --- /dev/null +++ b/lasagna/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"lasagna","id":"08eb6ff4a5c042a1aed228551bb1c301","url":"https://exercism.org/tracks/java/exercises/lasagna","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/lasagna/.gradle/7.5.1/checksums/checksums.lock b/lasagna/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..c2337e6 Binary files /dev/null and b/lasagna/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/lasagna/.gradle/7.5.1/checksums/md5-checksums.bin b/lasagna/.gradle/7.5.1/checksums/md5-checksums.bin new file mode 100644 index 0000000..c9f4081 Binary files /dev/null and b/lasagna/.gradle/7.5.1/checksums/md5-checksums.bin differ diff --git a/lasagna/.gradle/7.5.1/checksums/sha1-checksums.bin b/lasagna/.gradle/7.5.1/checksums/sha1-checksums.bin new file mode 100644 index 0000000..aabca2b Binary files /dev/null and b/lasagna/.gradle/7.5.1/checksums/sha1-checksums.bin differ diff --git a/lasagna/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/lasagna/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..5cecb53 Binary files /dev/null and b/lasagna/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/lasagna/.gradle/7.5.1/dependencies-accessors/gc.properties b/lasagna/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/lasagna/.gradle/7.5.1/executionHistory/executionHistory.bin b/lasagna/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..ae65b56 Binary files /dev/null and b/lasagna/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/lasagna/.gradle/7.5.1/executionHistory/executionHistory.lock b/lasagna/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..6bdf226 Binary files /dev/null and b/lasagna/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/lasagna/.gradle/7.5.1/fileChanges/last-build.bin b/lasagna/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/lasagna/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/lasagna/.gradle/7.5.1/fileHashes/fileHashes.bin b/lasagna/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..953e8ac Binary files /dev/null and b/lasagna/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/lasagna/.gradle/7.5.1/fileHashes/fileHashes.lock b/lasagna/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..b1b856e Binary files /dev/null and b/lasagna/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/lasagna/.gradle/7.5.1/gc.properties b/lasagna/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/lasagna/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/lasagna/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..907d464 Binary files /dev/null and b/lasagna/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/lasagna/.gradle/buildOutputCleanup/cache.properties b/lasagna/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..4522aa6 --- /dev/null +++ b/lasagna/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 17:27:00 CET 2023 +gradle.version=7.5.1 diff --git a/lasagna/.gradle/buildOutputCleanup/outputFiles.bin b/lasagna/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..50f0e2f Binary files /dev/null and b/lasagna/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/lasagna/.gradle/file-system.probe b/lasagna/.gradle/file-system.probe new file mode 100644 index 0000000..eb77e4e Binary files /dev/null and b/lasagna/.gradle/file-system.probe differ diff --git a/lasagna/.gradle/vcs-1/gc.properties b/lasagna/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/lasagna/.idea/.gitignore b/lasagna/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lasagna/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lasagna/.idea/compiler.xml b/lasagna/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/lasagna/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lasagna/.idea/gradle.xml b/lasagna/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/lasagna/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/lasagna/.idea/jarRepositories.xml b/lasagna/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/lasagna/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lasagna/.idea/misc.xml b/lasagna/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/lasagna/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/lasagna/HELP.md b/lasagna/HELP.md new file mode 100644 index 0000000..3bf67e9 --- /dev/null +++ b/lasagna/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/Lasagna.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/lasagna/HINTS.md b/lasagna/HINTS.md new file mode 100644 index 0000000..734a0e0 --- /dev/null +++ b/lasagna/HINTS.md @@ -0,0 +1,38 @@ +# Hints + +## General + +- An [integer value][integers] can be defined as one or more consecutive digits. + +## 1. Define the expected oven time in minutes + +- You need to define a [method][methods] without any arguments. +- You need to return an [integer][integers]. + +## 2. Calculate the remaining oven time in minutes + +- You need to define a [method][methods] with a single parameter. +- You have to [explicitly return an integer][return] from a method. +- The method's parameter is an [integer][integers]. +- You can use the [mathematical operator for subtraction][operators] to subtract values. + +## 3. Calculate the preparation time in minutes + +- You need to define a [method][methods] with a single parameter. +- You have to [explicitly return an integer][return] from a method. +- The method's parameter is an [integer][integers]. +- You can use the [mathematical operator for multiplicaton][operators] to multiply values. + +## 4. Calculate the total working time in minutes + +- You need to define a [method][methods] with two parameters. +- You have to [explicitly return an integer][return] from a method. +- The method's parameter is an [integer][integers]. +- You can [invoke][invocation] one of the other methods you've defined previously. +- You can use the [mathematical operator for addition][operators] to add values. + +[methods]: https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html +[return]: https://docs.oracle.com/javase/tutorial/java/javaOO/returnvalue.html +[operators]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html +[integers]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html +[invocation]: https://docs.oracle.com/javase/tutorial/java/javaOO/usingobject.html \ No newline at end of file diff --git a/lasagna/README.md b/lasagna/README.md new file mode 100644 index 0000000..f72b99d --- /dev/null +++ b/lasagna/README.md @@ -0,0 +1,105 @@ +# Cook your lasagna + +Welcome to Cook your lasagna on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Java is a statically-typed language, which means that everything has a type at compile-time. Assigning a value to a name is referred to as defining a variable. A variable is defined by explicitly specifying its type. + +```java +int explicitVar = 10; +``` + +Updating a variable's value is done through the `=` operator. Once defined, a variable's type can never change. + +```java +int count = 1; // Assign initial value +count = 2; // Update to new value + +// Compiler error when assigning different type +// count = false; +``` + +Java is an [object-oriented language][object-oriented-programming] and requires all functions to be defined in a _class_. The `class` keyword is used to define a class. + +```java +class Calculator { + // ... +} +``` + +A function within a class is referred to as a _method_. Each method can have zero or more parameters. All parameters must be explicitly typed, there is no type inference for parameters. Similarly, the return type must also be made explicit. Values are returned from functions using the `return` keyword. To allow a method to be called by other classes, the `public` access modifier must be added. + +```java +class Calculator { + public int add(int x, int y) { + return x + y; + } +} +``` + +Invoking a method is done by specifying its class and method name and passing arguments for each of the method's parameters. + +```java +int sum = new Calculator().add(1, 2); +``` + +Scope in Java is defined between the `{` and `}` characters. + +Java supports two types of comments. Single line comments are preceded by `//` and multiline comments are inserted between `/*` and `*/`. + +[object-oriented-programming]: https://docs.oracle.com/javase/tutorial/java/javaOO/index.html + +## Instructions + +In this exercise you're going to write some code to help you cook a brilliant lasagna from your favorite cooking book. + +You have four tasks, all related to the time spent cooking the lasagna. + +## 1. Define the expected oven time in minutes + +Define the `expectedMinutesInOven()` method that does not take any parameters and returns how many minutes the lasagna should be in the oven. According to the cooking book, the expected oven time in minutes is 40: + +```java +Lasagna lasagna = new Lasagna(); +lasagna.expectedMinutesInOven(); +// => 40 +``` + +## 2. Calculate the remaining oven time in minutes + +Define the `remainingMinutesInOven()` method that takes the actual minutes the lasagna has been in the oven as a parameter and returns how many minutes the lasagna still has to remain in the oven, based on the expected oven time in minutes from the previous task. + +```java +Lasagna lasagna = new Lasagna(); +lasagna.remainingMinutesInOven(30); +// => 10 +``` + +## 3. Calculate the preparation time in minutes + +Define the `preparationTimeInMinutes()` method that takes the number of layers you added to the lasagna as a parameter and returns how many minutes you spent preparing the lasagna, assuming each layer takes you 2 minutes to prepare. + +```java +Lasagna lasagna = new Lasagna(); +lasagna.preparationTimeInMinutes(2); +// => 4 +``` + +## 4. Calculate the total working time in minutes + +Define the `totalTimeInMinutes()` method that takes two parameters: the first parameter is the number of layers you added to the lasagna, and the second parameter is the number of minutes the lasagna has been in the oven. The function should return how many minutes in total you've worked on cooking the lasagna, which is the sum of the preparation time in minutes, and the time in minutes the lasagna has spent in the oven at the moment. + +```java +Lasagna lasagna = new Lasagna(); +lasagna.totalTimeInMinutes(3, 20); +// => 26 +``` + +## Source + +### Created by + +- @mirkoperillo \ No newline at end of file diff --git a/lasagna/build.gradle b/lasagna/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/lasagna/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/lasagna/gradle/wrapper/gradle-wrapper.jar b/lasagna/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/lasagna/gradle/wrapper/gradle-wrapper.jar differ diff --git a/lasagna/gradle/wrapper/gradle-wrapper.properties b/lasagna/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/lasagna/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/lasagna/gradlew b/lasagna/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/lasagna/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/lasagna/gradlew.bat b/lasagna/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/lasagna/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/lasagna/src/main/java/Lasagna.java b/lasagna/src/main/java/Lasagna.java new file mode 100644 index 0000000..9278d85 --- /dev/null +++ b/lasagna/src/main/java/Lasagna.java @@ -0,0 +1,27 @@ +public class Lasagna { + private static final int TIME = 40; + private static final int LAYER_TIME = 2; + + // TODO: define the 'expectedMinutesInOven()' method + public int expectedMinutesInOven() { + return TIME; + } + + // TODO: define the 'remainingMinutesInOven()' method + + public int remainingMinutesInOven(int timePast) { + return Math.max(0, TIME-timePast); + } + + // TODO: define the 'preparationTimeInMinutes()' method + + public int preparationTimeInMinutes(int layers) { + return Math.max(0, layers*LAYER_TIME); + } + + // TODO: define the 'totalTimeInMinutes()' method + + public int totalTimeInMinutes(int layers, int timeOven) { + return preparationTimeInMinutes(layers) + timeOven; + } +} diff --git a/lasagna/src/test/java/LasagnaTest.java b/lasagna/src/test/java/LasagnaTest.java new file mode 100644 index 0000000..ca89719 --- /dev/null +++ b/lasagna/src/test/java/LasagnaTest.java @@ -0,0 +1,90 @@ +import org.junit.Test; + +import utils.Lasagna; + +import static org.assertj.core.api.Assertions.*; + +public class LasagnaTest { + + @Test + public void implemented_expected_minutes_in_oven() { + assertThat(new Lasagna().hasMethod("expectedMinutesInOven")) + .withFailMessage("Method expectedMinutesInOven must be created") + .isTrue(); + assertThat(new Lasagna().isMethodPublic("expectedMinutesInOven")) + .withFailMessage("Method expectedMinutesInOven must be public") + .isTrue(); + assertThat(new Lasagna().isMethodReturnType(int.class, "expectedMinutesInOven")) + .withFailMessage("Method expectedMinutesInOven must return an int") + .isTrue(); + } + + @Test + public void expected_minutes_in_oven() { + assertThat(new Lasagna().expectedMinutesInOven()).isEqualTo(40); + } + + @Test + public void implemented_remaining_minutes_in_oven() { + assertThat(new Lasagna().hasMethod("remainingMinutesInOven", int.class)) + .withFailMessage("Method remainingMinutesInOven must be created") + .isTrue(); + assertThat(new Lasagna().isMethodPublic("remainingMinutesInOven", int.class)) + .withFailMessage("Method remainingMinutesInOven must be public") + .isTrue(); + assertThat(new Lasagna().isMethodReturnType(int.class, "remainingMinutesInOven", int.class)) + .withFailMessage("Method remainingMinutesInOven must return an int") + .isTrue(); + } + + @Test + public void remaining_minutes_in_oven() { + assertThat(new Lasagna().remainingMinutesInOven(25)).isEqualTo(15); + } + + @Test + public void implemented_preparation_time_in_minutes() { + assertThat(new Lasagna().hasMethod("preparationTimeInMinutes", int.class)) + .withFailMessage("Method preparationTimeInMinutes must be created") + .isTrue(); + assertThat(new Lasagna().isMethodPublic("preparationTimeInMinutes", int.class)) + .withFailMessage("Method preparationTimeInMinutes must be public") + .isTrue(); + assertThat(new Lasagna().isMethodReturnType(int.class, "preparationTimeInMinutes", int.class)) + .withFailMessage("Method preparationTimeInMinutes must return an int") + .isTrue(); + } + + @Test + public void preparation_time_in_minutes_for_one_layer() { + assertThat(new Lasagna().preparationTimeInMinutes(1)).isEqualTo(2); + } + + @Test + public void preparation_time_in_minutes_for_multiple_layers() { + assertThat(new Lasagna().preparationTimeInMinutes(4)).isEqualTo(8); + } + + @Test + public void implemented_total_time_in_minutes() { + assertThat(new Lasagna().hasMethod("totalTimeInMinutes", int.class, int.class)) + .withFailMessage("Method totalTimeInMinutes must be created") + .isTrue(); + assertThat(new Lasagna().isMethodPublic("totalTimeInMinutes", int.class, int.class)) + .withFailMessage("Method totalTimeInMinutes must be public") + .isTrue(); + assertThat(new Lasagna().isMethodReturnType(int.class, "totalTimeInMinutes", int.class, int.class)) + .withFailMessage("Method totalTimeInMinutes must return an int") + .isTrue(); + } + + @Test + public void total_time_in_minutes_for_one_layer() { + assertThat(new Lasagna().totalTimeInMinutes(1, 30)).isEqualTo(32); + } + + @Test + public void total_time_in_minutes_for_multiple_layers() { + assertThat(new Lasagna().totalTimeInMinutes(4, 8)).isEqualTo(16); + } +} diff --git a/lasagna/src/test/java/utils/Lasagna.java b/lasagna/src/test/java/utils/Lasagna.java new file mode 100644 index 0000000..21e12ef --- /dev/null +++ b/lasagna/src/test/java/utils/Lasagna.java @@ -0,0 +1,41 @@ +package utils; + +public class Lasagna extends ReflectionProxy { + + @Override + public String getTargetClassName() { + return "Lasagna"; + } + + public int expectedMinutesInOven() { + try { + return invokeMethod("expectedMinutesInOven", new Class[]{}); + } catch (Exception e) { + throw new UnsupportedOperationException("Please implement the expectedMinutesInOven() method"); + } + } + + public int remainingMinutesInOven(int actualMinutes) { + try { + return invokeMethod("remainingMinutesInOven", new Class[]{int.class}, actualMinutes); + } catch (Exception e) { + throw new UnsupportedOperationException("Please implement the remainingMinutesInOven(int) method"); + } + } + + public int preparationTimeInMinutes(int amountLayers) { + try { + return invokeMethod("preparationTimeInMinutes", new Class[]{int.class}, amountLayers); + } catch (Exception e) { + throw new UnsupportedOperationException("Please implement the preparationTimeInMinutes(int) method"); + } + } + + public int totalTimeInMinutes(int amountLayers, int actualMinutes) { + try { + return invokeMethod("totalTimeInMinutes", new Class[]{int.class, int.class}, amountLayers, actualMinutes); + } catch (Exception e) { + throw new UnsupportedOperationException("Please implement the totalTimeInMinutes(int, int) method"); + } + } +} diff --git a/lasagna/src/test/java/utils/ReflectionProxy.java b/lasagna/src/test/java/utils/ReflectionProxy.java new file mode 100644 index 0000000..6405b52 --- /dev/null +++ b/lasagna/src/test/java/utils/ReflectionProxy.java @@ -0,0 +1,487 @@ +package utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; + +import static java.lang.Class.forName; + +public abstract class ReflectionProxy { + + /** + * An instance of the target class (if found) + */ + private final Object target; + + /** + * A constructor to instantiate the target class with parameters + * @param args An array of parameters matching the constructor from the target class + */ + protected ReflectionProxy(Object... args) { + this.target = instantiateTarget(args); + } + + /** + * Abstract method that defines the fully qualified name of the target class + * @return The fully qualified name of the target class + */ + public abstract String getTargetClassName(); + + /** + * Getter for the target instance + * @return The target instance + */ + public Object getTarget() { + return target; + } + + /** + * Gets the target class + * @return The target class if it exists, null otherwise + */ + public Class getTargetClass() { + try { + return forName(this.getTargetClassName()); + } catch (ClassNotFoundException e) { + return null; + } + } + + /** + * Checks if the target class has a specific method + * @param name The name of the method to find + * @param parameterTypes The list of parameter types + * @return True if the method is found, false otherwise + */ + public boolean hasMethod(String name, Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Method m = targetClass.getDeclaredMethod(name, parameterTypes); + return m != null; + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Checks if a method from the target class is public + * @param name The name of the method + * @param parameterTypes A list of method parameters + * @return True if the method exists and is public, false otherwise + */ + public boolean isMethodPublic(String name, Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Method m = targetClass.getDeclaredMethod(name, parameterTypes); + return Modifier.isPublic(m.getModifiers()); + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Checks if a method from the target class returns the correct type + * @param returnType The type of return value + * @param name The name of the method + * @param parameterTypes The list of method parameters + * @return + */ + public boolean isMethodReturnType(Class returnType, String name, Class... parameterTypes) { + return isMethodReturnType(returnType, null, name, parameterTypes); + } + + /** + * Invokes a method from the target instance + * @param methodName The name of the method + * @param parameterTypes The list of parameter types + * @param parameterValues The list with values for the method parameters + * @param The result type we expect the method to be + * @return The value returned by the method + */ + protected T invokeMethod(String methodName, Class[] parameterTypes, Object... parameterValues) { + if (target == null) { + return null; + } + try { + // getDeclaredMethod is used to get protected/private methods + Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes); + method.setAccessible(true); + return (T) method.invoke(target, parameterValues); + } catch (NoSuchMethodException e) { + try { + // try getting it from parent class, but only public methods will work + Method method = target.getClass().getMethod(methodName, parameterTypes); + method.setAccessible(true); + return (T) method.invoke(target, parameterValues); + } catch (Exception ex) { + return null; + } + } catch (Exception e) { + return null; + } + } + + /** + * Creates an instance of the target class + * @param args The list of constructor parameters + * @return An instance of the target class, if found, or null otherwise + */ + private Object instantiateTarget(Object... args) { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return null; + } + Constructor[] constructors = getAllConstructors(); + for (Constructor c : constructors) { + if (c.getParameterCount() == args.length) { + try { + return c.newInstance(args); + } catch (Exception e) { + // do nothing; + } + } + } + return null; + } + + /** + * Gets a list with all the constructors defined by the target class + * @return A list with all constructor definitions + */ + private Constructor[] getAllConstructors() { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return new Constructor[]{}; + } + return targetClass.getConstructors(); + } + + + //region Unused + + /** + * The default constructor, for when you have already an instance of the target class + * @param target An instance of the target class + */ + protected ReflectionProxy(Object target) { + this.target = target; + } + + /** + * Checks if the target class exists + * @return True if the class exists, false otherwise + */ + public boolean existsClass() { + return getTargetClass() != null; + } + + /** + * Checks if the class implements a specific interface + * @param anInterface The interface to check + * @return True if the class implements the referred interface, false otherwise + */ + public boolean implementsInterface(Class anInterface) { + Class targetClass = getTargetClass(); + if (targetClass == null || anInterface == null) { + return false; + } + return anInterface.isAssignableFrom(targetClass); + } + + /** + * Checks if the target class has a specific property + * @param name The name of the property to find + * @return True if the property is found, false otherwise + */ + public boolean hasProperty(String name) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Field f = targetClass.getDeclaredField(name); + return f != null; + } catch (NoSuchFieldException e) { + return false; + } + } + + /** + * Checks if an existing property has the type we expect + * @param name The name of the property to check + * @param type The type you are expecting the property to be + * @return True if the property is found and has the specified type, false otherwise + */ + public boolean isPropertyOfType(String name, Class type) { + return isPropertyOfType(name, type, null); + } + + /** + * Checks if an existing Collection type has the parameterized type (Generics) as expected (eg. List) + * @param name The name of the property + * @param type The type of the property (eg. List) + * @param parameterizedType The parameterized property (eg. String) + * @return True if the parameterized type matches the desired type, false otherwise + */ + public boolean isPropertyOfType(String name, Class type, Class parameterizedType) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null || type == null) { + return false; + } + try { + Field f = targetClass.getDeclaredField(name); + if (!f.getType().equals(type)) { + return false; + } + if (parameterizedType == null) { + return true; + } + if (!(f.getGenericType() instanceof ParameterizedType)) { + return false; + } + ParameterizedType pType = (ParameterizedType) f.getGenericType(); + return pType.getActualTypeArguments()[0].equals(parameterizedType); + + } catch (NoSuchFieldException e) { + return false; + } + } + + /** + * Checks if a property is private + * @param name The name of the property + * @return True if the property exists and is private, false otherwise + */ + public boolean isPropertyPrivate(String name) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Field f = targetClass.getDeclaredField(name); + return Modifier.isPrivate(f.getModifiers()); + } catch (NoSuchFieldException e) { + return false; + } + } + + /** + * Checks if a method from the target class returns a correct parameterized collection (Generics) + * @param returnType The return type we expect (eg. List) + * @param parameterizedType The parameterized type we expect (eg. String) + * @param name The name of the method + * @param parameterTypes A list of method parameter types + * @return True if the method returns the correct parameterized collection, false otherwise + */ + public boolean isMethodReturnType(Class returnType, Class parameterizedType, + String name, Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Method m = targetClass.getDeclaredMethod(name, parameterTypes); + if (!m.getReturnType().equals(returnType)) { + return false; + } + if (parameterizedType == null) { + return true; + } + if (!(m.getGenericReturnType() instanceof ParameterizedType)) { + return false; + } + ParameterizedType pType = (ParameterizedType) m.getGenericReturnType(); + return pType.getActualTypeArguments()[0].equals(parameterizedType); + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Checks if a target class has a specific constructor + * @param parameterTypes The list of desired parameter types + * @return True if the constructor exists, false otherwise + */ + public boolean hasConstructor(Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return false; + } + try { + Constructor c = targetClass.getDeclaredConstructor(parameterTypes); + return c != null; + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Checks if a specific constructor from the target class is public + * @param parameterTypes A list of parameter types + * @return True if the constructor is found and is public, false otherwise + */ + public boolean isConstructorPublic(Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return false; + } + try { + Constructor c = targetClass.getDeclaredConstructor(parameterTypes); + return Modifier.isPublic(c.getModifiers()); + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Proxy for the 'equals' method + * @param obj The ReflexionProxy object you want to compare against + * @return True if both targets are equal, false otherwise + */ + public boolean equals(Object obj) { + if (target == null || !(obj instanceof ReflectionProxy)) { + return false; + } + try { + Method method = target.getClass().getMethod("equals", Object.class); + method.setAccessible(true); + return (boolean) method.invoke(target, ((ReflectionProxy) obj).getTarget()); + } catch (Exception e) { + return false; + } + } + + /** + * Proxy for the 'hashCode' method + * @return The hashCode from the target class + */ + public int hashCode() { + if (target == null) { + return 0; + } + try { + Method method = target.getClass().getMethod("hashCode"); + method.setAccessible(true); + return (int) method.invoke(target); + } catch (Exception e) { + return 0; + } + } + + /** + * Proxy for the 'toString' method from the target class + * @return The result of 'toString' from the target instance + */ + public String toString() { + return invokeMethod("toString", new Class[]{ }); + } + + /** + * Gets a property value from the target instance (if it exists) + * @param propertyName The name of the property + * @param The type we are expecting it to be + * @return The value of the property (if it exists) + */ + protected T getPropertyValue(String propertyName) { + if (target == null || !hasProperty(propertyName)) { + return null; + } + try { + Field field = target.getClass().getDeclaredField(propertyName); + field.setAccessible(true); + return (T) field.get(target); + } catch (Exception e) { + return null; + } + } + + /** + * Checks if the target class is abstract + * @return True if the target class exists and is abstract, false otherwise + */ + public boolean isAbstract() { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return false; + } + return Modifier.isAbstract(targetClass.getModifiers()); + } + + /** + * Checks if the target class extends another + * @param className The fully qualified name of the class it should extend + * @return True if the target class extends the specified one, false otherwise + */ + public boolean extendsClass(String className) { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return false; + } + try { + Class parentClass = Class.forName(className); + return parentClass.isAssignableFrom(targetClass); + } catch (ClassNotFoundException e) { + return false; + } + } + + /** + * Checks if the target class is an interface + * @return True if the target class exists and is an interface, false otherwise + */ + public boolean isInterface() { + Class targetClass = getTargetClass(); + if (targetClass == null) { + return false; + } + return targetClass.isInterface(); + } + + /** + * Checks if a method is abstract + * @param name The name of the method + * @param parameterTypes The list of method parameter types + * @return True if the method exists and is abstract, false otherwise + */ + public boolean isMethodAbstract(String name, Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Method m = targetClass.getDeclaredMethod(name, parameterTypes); + return Modifier.isAbstract(m.getModifiers()); + } catch (NoSuchMethodException e) { + return false; + } + } + + /** + * Checks if a method is protected + * @param name The name of the method + * @param parameterTypes The list of method parameter types + * @return True if the method exists and is protected, false otherwise + */ + public boolean isMethodProtected(String name, Class... parameterTypes) { + Class targetClass = getTargetClass(); + if (targetClass == null || name == null) { + return false; + } + try { + Method m = targetClass.getDeclaredMethod(name, parameterTypes); + return Modifier.isProtected(m.getModifiers()); + } catch (NoSuchMethodException e) { + return false; + } + } + + //endregion +} diff --git a/log-levels/.exercism/config.json b/log-levels/.exercism/config.json new file mode 100644 index 0000000..48f0f80 --- /dev/null +++ b/log-levels/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "mirkoperillo" + ], + "files": { + "solution": [ + "src/main/java/LogLevels.java" + ], + "test": [ + "src/test/java/LogLevelsTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/LogLevels.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/log-levels" + ], + "blurb": "Learn about strings by processing logs." +} diff --git a/log-levels/.exercism/metadata.json b/log-levels/.exercism/metadata.json new file mode 100644 index 0000000..46f74c4 --- /dev/null +++ b/log-levels/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"log-levels","id":"3d47498a4cfe4ac785daf1c25eabaeeb","url":"https://exercism.org/tracks/java/exercises/log-levels","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/log-levels/.gradle/7.5.1/checksums/checksums.lock b/log-levels/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..8fdb9f2 Binary files /dev/null and b/log-levels/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/log-levels/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/log-levels/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..9a7cb46 Binary files /dev/null and b/log-levels/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/log-levels/.gradle/7.5.1/dependencies-accessors/gc.properties b/log-levels/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/log-levels/.gradle/7.5.1/executionHistory/executionHistory.bin b/log-levels/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..9f3ecc3 Binary files /dev/null and b/log-levels/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/log-levels/.gradle/7.5.1/executionHistory/executionHistory.lock b/log-levels/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..a682c78 Binary files /dev/null and b/log-levels/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/log-levels/.gradle/7.5.1/fileChanges/last-build.bin b/log-levels/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/log-levels/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/log-levels/.gradle/7.5.1/fileHashes/fileHashes.bin b/log-levels/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..8822978 Binary files /dev/null and b/log-levels/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/log-levels/.gradle/7.5.1/fileHashes/fileHashes.lock b/log-levels/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..82d0799 Binary files /dev/null and b/log-levels/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/log-levels/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/log-levels/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..58ff72c Binary files /dev/null and b/log-levels/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/log-levels/.gradle/7.5.1/gc.properties b/log-levels/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/log-levels/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/log-levels/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..a54d3da Binary files /dev/null and b/log-levels/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/log-levels/.gradle/buildOutputCleanup/cache.properties b/log-levels/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..482548c --- /dev/null +++ b/log-levels/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Mar 08 18:29:09 CET 2023 +gradle.version=7.5.1 diff --git a/log-levels/.gradle/buildOutputCleanup/outputFiles.bin b/log-levels/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..ebd2dab Binary files /dev/null and b/log-levels/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/log-levels/.gradle/file-system.probe b/log-levels/.gradle/file-system.probe new file mode 100644 index 0000000..2880dc4 Binary files /dev/null and b/log-levels/.gradle/file-system.probe differ diff --git a/log-levels/.gradle/vcs-1/gc.properties b/log-levels/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/log-levels/.idea/.gitignore b/log-levels/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/log-levels/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/log-levels/.idea/compiler.xml b/log-levels/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/log-levels/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/log-levels/.idea/gradle.xml b/log-levels/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/log-levels/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/log-levels/.idea/jarRepositories.xml b/log-levels/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/log-levels/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/log-levels/.idea/misc.xml b/log-levels/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/log-levels/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/log-levels/HELP.md b/log-levels/HELP.md new file mode 100644 index 0000000..62e7787 --- /dev/null +++ b/log-levels/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/LogLevels.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/log-levels/HINTS.md b/log-levels/HINTS.md new file mode 100644 index 0000000..4f3036f --- /dev/null +++ b/log-levels/HINTS.md @@ -0,0 +1,27 @@ +# Hints + +## General + +- The `String` class has many useful [built-in methods][string-class]. + +## 1. Get message from a log line + +- Different options to search for text in a string are explored in [this tutorial][tutorial-search-text-in-string]. +- How to split strings can be seen [here][tutorial-split-strings] +- Removing white space is [built-in][tutorial-trim-white-space]. + +## 2. Get log level from a log line + +- Changing a `String`'s casing is explored [here][tutorial-changing-case-upper] and [here][tutorial-changing-case-lower]. + +## 3. Reformat a log line + +- There are several ways to [concatenate strings][tutorial-concatenate-strings] + +[string-class]: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html +[tutorial-search-text-in-string]: https://javarevisited.blogspot.com/2016/10/how-to-check-if-string-contains-another-substring-in-java-indexof-example.html +[tutorial-trim-white-space]: https://www.geeksforgeeks.org/java-string-trim-method-example/ +[tutorial-changing-case-upper]: https://www.javatpoint.com/java-string-touppercase +[tutorial-changing-case-lower]: https://www.javatpoint.com/java-string-tolowercase +[tutorial-concatenate-strings]: https://www.javatpoint.com/string-concatenation-in-java +[tutorial-split-strings]: https://www.geeksforgeeks.org/split-string-java-examples/ \ No newline at end of file diff --git a/log-levels/README.md b/log-levels/README.md new file mode 100644 index 0000000..4fb55b2 --- /dev/null +++ b/log-levels/README.md @@ -0,0 +1,70 @@ +# Log Levels + +Welcome to Log Levels on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +A `String` in Java is an object that represents immutable text as a sequence of Unicode characters (letters, digits, punctuation, etc.). Double quotes are used to define a `String` instance: + +```java +String fruit = "Apple"; +``` + +Strings are manipulated by calling the string's methods. Once a string has been constructed, its value can never change. Any methods that appear to modify a string will actually return a new string. +The `String` class provides some _static_ methods to transform the strings. + +## Instructions + +In this exercise you'll be processing log-lines. + +Each log line is a string formatted as follows: `"[]: "`. + +There are three different log levels: + +- `INFO` +- `WARNING` +- `ERROR` + +You have three tasks, each of which will take a log line and ask you to do something with it. + +## 1. Get message from a log line + +Implement the (_static_) `LogLevels.message()` method to return a log line's message: + +```java +LogLevels.message("[ERROR]: Invalid operation") +// => "Invalid operation" +``` + +Any leading or trailing white space should be removed: + +```java +LogLevels.message("[WARNING]: Disk almost full\r\n") +// => "Disk almost full" +``` + +## 2. Get log level from a log line + +Implement the (_static_) `LogLevels.logLevel()` method to return a log line's log level, which should be returned in lowercase: + +```java +LogLevels.logLevel("[ERROR]: Invalid operation") +// => "error" +``` + +## 3. Reformat a log line + +Implement the (_static_) `LogLevels.reformat()` method that reformats the log line, putting the message first and the log level after it in parentheses: + +```java +LogLevels.reformat("[INFO]: Operation completed") +// => "Operation completed (info)" +``` + +## Source + +### Created by + +- @mirkoperillo \ No newline at end of file diff --git a/log-levels/build.gradle b/log-levels/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/log-levels/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/log-levels/build/classes/java/main/LogLevels.class b/log-levels/build/classes/java/main/LogLevels.class new file mode 100644 index 0000000..4c3d4f0 Binary files /dev/null and b/log-levels/build/classes/java/main/LogLevels.class differ diff --git a/log-levels/build/classes/java/test/LogLevelsTest.class b/log-levels/build/classes/java/test/LogLevelsTest.class new file mode 100644 index 0000000..41c176b Binary files /dev/null and b/log-levels/build/classes/java/test/LogLevelsTest.class differ diff --git a/log-levels/build/reports/tests/test/classes/LogLevelsTest.html b/log-levels/build/reports/tests/test/classes/LogLevelsTest.html new file mode 100644 index 0000000..b544cc8 --- /dev/null +++ b/log-levels/build/reports/tests/test/classes/LogLevelsTest.html @@ -0,0 +1,146 @@ + + + + + +Test results - Class LogLevelsTest + + + + + +
+

Class LogLevelsTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
error_log_level0spassed
error_message0spassed
error_reformat0spassed
info_log_level0spassed
info_message0spassed
info_reformat0.001spassed
message_with_leading_and_trailing_white_space0.027spassed
reformat_with_leading_and_trailing_white_space0spassed
warning_log_level0spassed
warning_message0spassed
warning_reformat0spassed
+
+
+ +
+ + diff --git a/log-levels/build/reports/tests/test/css/base-style.css b/log-levels/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/log-levels/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/log-levels/build/reports/tests/test/css/style.css b/log-levels/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/log-levels/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/log-levels/build/reports/tests/test/index.html b/log-levels/build/reports/tests/test/index.html new file mode 100644 index 0000000..22bd84c --- /dev/null +++ b/log-levels/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +11000.028s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+LogLevelsTest +11000.028s100%
+
+
+ +
+ + diff --git a/log-levels/build/reports/tests/test/js/report.js b/log-levels/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/log-levels/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/log-levels/build/reports/tests/test/packages/default-package.html b/log-levels/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..94ca372 --- /dev/null +++ b/log-levels/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.028s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+LogLevelsTest +11000.028s100%
+
+
+ +
+ + diff --git a/log-levels/build/test-results/test/TEST-LogLevelsTest.xml b/log-levels/build/test-results/test/TEST-LogLevelsTest.xml new file mode 100644 index 0000000..54d7381 --- /dev/null +++ b/log-levels/build/test-results/test/TEST-LogLevelsTest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/log-levels/build/test-results/test/binary/output.bin b/log-levels/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/log-levels/build/test-results/test/binary/output.bin.idx b/log-levels/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/log-levels/build/test-results/test/binary/output.bin.idx differ diff --git a/log-levels/build/test-results/test/binary/results.bin b/log-levels/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..9443173 Binary files /dev/null and b/log-levels/build/test-results/test/binary/results.bin differ diff --git a/log-levels/build/tmp/compileJava/previous-compilation-data.bin b/log-levels/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..c29dbdb Binary files /dev/null and b/log-levels/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/log-levels/build/tmp/compileTestJava/previous-compilation-data.bin b/log-levels/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..1183139 Binary files /dev/null and b/log-levels/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/log-levels/gradle/wrapper/gradle-wrapper.jar b/log-levels/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/log-levels/gradle/wrapper/gradle-wrapper.jar differ diff --git a/log-levels/gradle/wrapper/gradle-wrapper.properties b/log-levels/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/log-levels/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/log-levels/gradlew b/log-levels/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/log-levels/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/log-levels/gradlew.bat b/log-levels/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/log-levels/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/log-levels/src/main/java/LogLevels.java b/log-levels/src/main/java/LogLevels.java new file mode 100644 index 0000000..b9deedc --- /dev/null +++ b/log-levels/src/main/java/LogLevels.java @@ -0,0 +1,14 @@ +public class LogLevels { + + public static String message(String logLine) { + return logLine.split("]: ")[1].trim(); + } + + public static String logLevel(String logLine) { + return logLine.split("]: ")[0].substring(1).toLowerCase(); + } + + public static String reformat(String logLine) { + return String.format("%s (%s)", message(logLine), logLevel(logLine)); + } +} diff --git a/log-levels/src/test/java/LogLevelsTest.java b/log-levels/src/test/java/LogLevelsTest.java new file mode 100644 index 0000000..5fec717 --- /dev/null +++ b/log-levels/src/test/java/LogLevelsTest.java @@ -0,0 +1,64 @@ +import org.junit.Test; + +import static org.assertj.core.api.Assertions.*; + +public class LogLevelsTest { + @Test + public void error_message() { + assertThat(LogLevels.message("[ERROR]: Stack overflow")).isEqualTo("Stack overflow"); + } + + @Test + public void warning_message() { + assertThat(LogLevels.message("[WARNING]: Disk almost full")).isEqualTo("Disk almost full"); + } + + @Test + public void info_message() { + assertThat(LogLevels.message("[INFO]: File moved")).isEqualTo("File moved"); + } + + @Test + public void message_with_leading_and_trailing_white_space() { + assertThat(LogLevels.message("[WARNING]: \tTimezone not set \r\n")).isEqualTo("Timezone not set"); + } + + @Test + public void error_log_level() { + assertThat(LogLevels.logLevel("[ERROR]: Disk full")).isEqualTo("error"); + } + + @Test + public void warning_log_level() { + assertThat(LogLevels.logLevel("[WARNING]: Unsafe password")).isEqualTo("warning"); + } + + @Test + public void info_log_level() { + assertThat(LogLevels.logLevel("[INFO]: Timezone changed")).isEqualTo("info"); + } + + @Test + public void error_reformat() { + assertThat(LogLevels.reformat("[ERROR]: Segmentation fault")) + .isEqualTo("Segmentation fault (error)"); + } + + @Test + public void warning_reformat() { + assertThat(LogLevels.reformat("[WARNING]: Decreased performance")) + .isEqualTo("Decreased performance (warning)"); + } + + @Test + public void info_reformat() { + assertThat(LogLevels.reformat("[INFO]: Disk defragmented")) + .isEqualTo("Disk defragmented (info)"); + } + + @Test + public void reformat_with_leading_and_trailing_white_space() { + assertThat(LogLevels.reformat("[ERROR]: \t Corrupt disk\t \t \r\n")) + .isEqualTo("Corrupt disk (error)"); + } +} diff --git a/need-for-speed/.exercism/config.json b/need-for-speed/.exercism/config.json new file mode 100644 index 0000000..6db5778 --- /dev/null +++ b/need-for-speed/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "ystromm" + ], + "contributors": [ + "mirkoperillo" + ], + "files": { + "solution": [ + "src/main/java/NeedForSpeed.java" + ], + "test": [ + "src/test/java/NeedForSpeedTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/NeedForSpeed.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Learn about classes by creating cars." +} diff --git a/need-for-speed/.exercism/metadata.json b/need-for-speed/.exercism/metadata.json new file mode 100644 index 0000000..1837af0 --- /dev/null +++ b/need-for-speed/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"need-for-speed","id":"eff51292680746ad86b0fa691827a53d","url":"https://exercism.org/tracks/java/exercises/need-for-speed","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/need-for-speed/.gradle/7.5.1/checksums/checksums.lock b/need-for-speed/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..39747e5 Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/need-for-speed/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/need-for-speed/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..946871d Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/need-for-speed/.gradle/7.5.1/dependencies-accessors/gc.properties b/need-for-speed/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.bin b/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..008766a Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.lock b/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..24862f6 Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/need-for-speed/.gradle/7.5.1/fileChanges/last-build.bin b/need-for-speed/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.bin b/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..8b9d7aa Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.lock b/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..1c1b60e Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/need-for-speed/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/need-for-speed/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..cf9ebde Binary files /dev/null and b/need-for-speed/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/need-for-speed/.gradle/7.5.1/gc.properties b/need-for-speed/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/need-for-speed/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/need-for-speed/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..ff1c1b9 Binary files /dev/null and b/need-for-speed/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/need-for-speed/.gradle/buildOutputCleanup/cache.properties b/need-for-speed/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..0776a51 --- /dev/null +++ b/need-for-speed/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Mar 08 17:50:06 CET 2023 +gradle.version=7.5.1 diff --git a/need-for-speed/.gradle/buildOutputCleanup/outputFiles.bin b/need-for-speed/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..5eedf20 Binary files /dev/null and b/need-for-speed/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/need-for-speed/.gradle/file-system.probe b/need-for-speed/.gradle/file-system.probe new file mode 100644 index 0000000..90ad470 Binary files /dev/null and b/need-for-speed/.gradle/file-system.probe differ diff --git a/need-for-speed/.gradle/vcs-1/gc.properties b/need-for-speed/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/need-for-speed/.idea/.gitignore b/need-for-speed/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/need-for-speed/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/need-for-speed/.idea/compiler.xml b/need-for-speed/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/need-for-speed/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/need-for-speed/.idea/gradle.xml b/need-for-speed/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/need-for-speed/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/need-for-speed/.idea/jarRepositories.xml b/need-for-speed/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/need-for-speed/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/need-for-speed/.idea/misc.xml b/need-for-speed/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/need-for-speed/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/need-for-speed/HELP.md b/need-for-speed/HELP.md new file mode 100644 index 0000000..df2f51b --- /dev/null +++ b/need-for-speed/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/NeedForSpeed.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/need-for-speed/HINTS.md b/need-for-speed/HINTS.md new file mode 100644 index 0000000..c92384f --- /dev/null +++ b/need-for-speed/HINTS.md @@ -0,0 +1,38 @@ +# Hints + +## 1. Creating a remote controlled car + +- [Define a constructor][constructor-syntax] that has two `int` parameters. +- Store the two parameters as [fields][fields] to access them from the classes' methods. + +## 2. Creating a race track + +- [Define a constructor][constructor-syntax] that has one `int` parameter. +- Store the parameter as a [field][fields] to access it from the class' method. + +## 3. Drive the car + +- Add a [field][fields] to keep track of the distance driven. +- Add the car's speed to the [field][fields] that keeps track of the distance driven. + +## 4. Check for a drained battery + +- Add a [field][fields] to keep track of the remaining battery charge percentage (starts at 100%). +- Remove the car's battery drain from the [field][fields] to keep track of the battery charge. +- Don't update the distance driven if the battery is drained. +- Remember that if the battery charge is less than the battery drain percentage, it is considered drained. + +## 5. Create the Nitro remote control car + +- [Instantiate][instance-constructors] an instance of the `RemoteControlCar` with the correct arguments. + +## 6. Check if a remote control car can finish a race + +- Solving this is probably best done by [repeatedly driving the car][while]. +- Remember that the car has a method to retrieve the distance it has driven. +- Consider what to do when the battery has been drained before reaching the finish line. + +[constructor-syntax]: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html +[instance-constructors]: https://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html +[while]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html +[fields]: https://docs.oracle.com/javase/tutorial/java/javaOO/variables.html \ No newline at end of file diff --git a/need-for-speed/README.md b/need-for-speed/README.md new file mode 100644 index 0000000..b9855d4 --- /dev/null +++ b/need-for-speed/README.md @@ -0,0 +1,141 @@ +# Need for Speed + +Welcome to Need for Speed on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Creating an instance of a _class_ is done by calling its _constructor_ through the `new` operator. A constructor is a special type of method whose goal is to initialize a newly created instance. Constructors look like regular methods, but without a return type and with a name that matches the classes' name. + +```java +class Library { + private int books; + + public Library() { + // Initialize the books field + this.books = 10; + } +} + +// This will call the constructor +var library = new Library(); +``` + +Like regular methods, constructors can have parameters. Constructor parameters are usually stored as (private) fields to be accessed later, or else used in some one-off calculation. Arguments can be passed to constructors just like passing arguments to regular methods. + +```java +class Building { + private int numberOfStories; + private int totalHeight; + + public Building(int numberOfStories, double storyHeight) { + this.numberOfStories = numberOfStories; + this.totalHeight = numberOfStories * storyHeight; + } +} + +// Call a constructor with two arguments +var largeBuilding = new Building(55, 6.2); +``` + +## Instructions + +In this exercise you'll be organizing races between various types of remote controlled cars. Each car has its own speed and battery drain characteristics. + +Cars start with full (100%) batteries. Each time you drive the car using the remote control, it covers the car's speed in meters and decreases the remaining battery percentage by its battery drain. + +If a car's battery is below its battery drain percentage, you can't drive the car anymore. + +Each race track has its own distance. Cars are tested by checking if they can finish the track without running out of battery. + +You have six tasks, each of which will work with remote controller car instances. + +## 1. Creating a remote controlled car + +Allow creating a remote controller car by defining a constructor for the `NeedForSpeed` class that takes the speed of the car in meters and the battery drain percentage as its two parameters (both of type `int`): + +```java +int speed = 5; +int batteryDrain = 2; +var car = new NeedForSpeed(speed, batteryDrain); +``` + +## 2. Creating a race track + +Allow creating a race track by defining a constructor for the `RaceTrack` class that takes the track's distance in meters as its sole parameter (which is of type `int`): + +```java +int distance = 800; +var raceTrack = new RaceTrack(distance); +``` + +## 3. Drive the car + +Implement the `NeedForSpeed.drive()` method that updates the number of meters driven based on the car's speed. Also implement the `NeedForSpeed.distanceDriven()` method to return the number of meters driven by the car: + +```java +int speed = 5; +int batteryDrain = 2; +var car = new NeedForSpeed(speed, batteryDrain); +car.drive(); + +car.distanceDriven(); +// => 5 +``` + +## 4. Check for a drained battery + +Update the `NeedForSpeed.drive()` method to drain the battery based on the car's battery drain. Also implement the `NeedForSpeed.batteryDrained()` method that indicates if the battery is drained: + +```java +int speed = 5; +int batteryDrain = 2; +var car = new NeedForSpeed(speed, batteryDrain); +car.drive(); + +car.batteryDrained(); +// => false +``` + +## 5. Create the Nitro remote control car + +The best-selling remote control car is the Nitro, which has a stunning top speed of 50 meters with a battery drain of 4%. Implement the (static) `NeedForSpeed.nitro()` method to return this type of car: + +```java +var car = NeedForSpeed.nitro(); +car.drive(); +car.distanceDriven(); +// => 50 +``` + +## 6. Check if a remote control car can finish a race + +To finish a race, a car has to be able to drive the race's distance. This means not draining its battery before having crossed the finish line. Implement the `RaceTrack.tryFinishTrack()` method that takes a `NeedForSpeed` instance as its parameter and returns `true` if the car can finish the race; otherwise, return `false`. To see if the car can finish the race, you should try to drive the car until either you reach the end of the track or the battery drains: + +```java +int speed = 5; +int batteryDrain = 2; +var car = new NeedForSpeed(speed, batteryDrain); + +int distance = 100; +var race = new RaceTrack(distance); + +car.distanceDriven() +// => 0 + +race.tryFinishTrack(car); +// => true + +car.distanceDriven() +// => 100 + +## Source + +### Created by + +- @ystromm + +### Contributed to by + +- @mirkoperillo \ No newline at end of file diff --git a/need-for-speed/build.gradle b/need-for-speed/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/need-for-speed/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/need-for-speed/build/classes/java/main/NeedForSpeed.class b/need-for-speed/build/classes/java/main/NeedForSpeed.class new file mode 100644 index 0000000..c5098b7 Binary files /dev/null and b/need-for-speed/build/classes/java/main/NeedForSpeed.class differ diff --git a/need-for-speed/build/classes/java/main/RaceTrack.class b/need-for-speed/build/classes/java/main/RaceTrack.class new file mode 100644 index 0000000..79a442b Binary files /dev/null and b/need-for-speed/build/classes/java/main/RaceTrack.class differ diff --git a/need-for-speed/build/classes/java/test/NeedForSpeedTest.class b/need-for-speed/build/classes/java/test/NeedForSpeedTest.class new file mode 100644 index 0000000..93b52cd Binary files /dev/null and b/need-for-speed/build/classes/java/test/NeedForSpeedTest.class differ diff --git a/need-for-speed/build/reports/tests/test/classes/NeedForSpeedTest.html b/need-for-speed/build/reports/tests/test/classes/NeedForSpeedTest.html new file mode 100644 index 0000000..3198f31 --- /dev/null +++ b/need-for-speed/build/reports/tests/test/classes/NeedForSpeedTest.html @@ -0,0 +1,161 @@ + + + + + +Test results - Class NeedForSpeedTest + + + + + +
+

Class NeedForSpeedTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
14
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.032s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
car_can_finish_with_car_that_can_easily_finish0spassed
car_can_finish_with_car_that_can_just_finish0spassed
car_can_finish_with_car_that_cannot_finish0spassed
car_can_finish_with_car_that_just_cannot_finish0spassed
drive_does_not_increase_distance_driven_when_battery_drained0spassed
drive_increases_distance_driven_with_speed0spassed
drive_to_almost_drain_battery0spassed
drive_until_battery_is_drained0spassed
new_remote_control_car_battery_is_not_drained0spassed
new_remote_control_car_has_not_driven_any_distance0.032spassed
nitro_car_has_battery_not_drained0spassed
nitro_car_has_correct_speed0spassed
nitro_car_has_not_driven_any_distance0spassed
nitro_has_correct_battery_drain0spassed
+
+
+ +
+ + diff --git a/need-for-speed/build/reports/tests/test/css/base-style.css b/need-for-speed/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/need-for-speed/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/need-for-speed/build/reports/tests/test/css/style.css b/need-for-speed/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/need-for-speed/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/need-for-speed/build/reports/tests/test/index.html b/need-for-speed/build/reports/tests/test/index.html new file mode 100644 index 0000000..adc801d --- /dev/null +++ b/need-for-speed/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
14
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.032s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +14000.032s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+NeedForSpeedTest +14000.032s100%
+
+
+ +
+ + diff --git a/need-for-speed/build/reports/tests/test/js/report.js b/need-for-speed/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/need-for-speed/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/need-for-speed/build/reports/tests/test/packages/default-package.html b/need-for-speed/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..9c2813b --- /dev/null +++ b/need-for-speed/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
14
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.032s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+NeedForSpeedTest +14000.032s100%
+
+
+ +
+ + diff --git a/need-for-speed/build/test-results/test/TEST-NeedForSpeedTest.xml b/need-for-speed/build/test-results/test/TEST-NeedForSpeedTest.xml new file mode 100644 index 0000000..d85b756 --- /dev/null +++ b/need-for-speed/build/test-results/test/TEST-NeedForSpeedTest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/need-for-speed/build/test-results/test/binary/output.bin b/need-for-speed/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/need-for-speed/build/test-results/test/binary/output.bin.idx b/need-for-speed/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/need-for-speed/build/test-results/test/binary/output.bin.idx differ diff --git a/need-for-speed/build/test-results/test/binary/results.bin b/need-for-speed/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..c0ea20c Binary files /dev/null and b/need-for-speed/build/test-results/test/binary/results.bin differ diff --git a/need-for-speed/build/tmp/compileJava/previous-compilation-data.bin b/need-for-speed/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..91662c5 Binary files /dev/null and b/need-for-speed/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/need-for-speed/build/tmp/compileTestJava/previous-compilation-data.bin b/need-for-speed/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..882af51 Binary files /dev/null and b/need-for-speed/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/need-for-speed/gradle/wrapper/gradle-wrapper.jar b/need-for-speed/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/need-for-speed/gradle/wrapper/gradle-wrapper.jar differ diff --git a/need-for-speed/gradle/wrapper/gradle-wrapper.properties b/need-for-speed/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/need-for-speed/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/need-for-speed/gradlew b/need-for-speed/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/need-for-speed/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/need-for-speed/gradlew.bat b/need-for-speed/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/need-for-speed/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/need-for-speed/src/main/java/NeedForSpeed.java b/need-for-speed/src/main/java/NeedForSpeed.java new file mode 100644 index 0000000..07bd0d0 --- /dev/null +++ b/need-for-speed/src/main/java/NeedForSpeed.java @@ -0,0 +1,48 @@ +class NeedForSpeed { + private int speed; + private int batteryDrain; + private int driven; + private int percent; + + public NeedForSpeed(int speed, int batteryDrain) { + this.speed = speed; + this.batteryDrain = batteryDrain; + + driven = 0; + percent = 100; + } + + public boolean batteryDrained() { + return percent < batteryDrain; + } + + public int distanceDriven() { + return driven; + } + + public void drive() { + if(!batteryDrained()) { + driven += speed; + percent -= batteryDrain; + } + } + + public static NeedForSpeed nitro() { + return new NeedForSpeed(50, 4); + } +} + +class RaceTrack { + private int distance; + + public RaceTrack(int distance) { + this.distance = distance; + } + + public boolean tryFinishTrack(NeedForSpeed car) { + while(!car.batteryDrained()) { + car.drive(); + } + return car.distanceDriven() >= distance; + } +} diff --git a/need-for-speed/src/test/java/NeedForSpeedTest.java b/need-for-speed/src/test/java/NeedForSpeedTest.java new file mode 100644 index 0000000..ff6d177 --- /dev/null +++ b/need-for-speed/src/test/java/NeedForSpeedTest.java @@ -0,0 +1,163 @@ +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class NeedForSpeedTest { + @Test + public void new_remote_control_car_has_not_driven_any_distance() { + int speed = 10; + int batteryDrain = 2; + var car = new NeedForSpeed(speed, batteryDrain); + + assertThat(car.distanceDriven()).isEqualTo(0); + } + + @Test + public void drive_increases_distance_driven_with_speed() { + int speed = 5; + int batteryDrain = 1; + var car = new NeedForSpeed(speed, batteryDrain); + + car.drive(); + + assertThat(car.distanceDriven()).isEqualTo(5); + } + + @Test + public void drive_does_not_increase_distance_driven_when_battery_drained() { + int speed = 9; + int batteryDrain = 50; + var car = new NeedForSpeed(speed, batteryDrain); + + // Drain the battery + car.drive(); + car.drive(); + + // One extra drive attempt (should not succeed) + car.drive(); + + assertThat(car.distanceDriven()).isEqualTo(18); + } + + @Test + public void new_remote_control_car_battery_is_not_drained() { + int speed = 15; + int batteryDrain = 3; + var car = new NeedForSpeed(speed, batteryDrain); + + assertThat(car.batteryDrained()).isFalse(); + } + + @Test + public void drive_to_almost_drain_battery() { + int speed = 2; + int batteryDrain = 1; + var car = new NeedForSpeed(speed, batteryDrain); + + // Almost drain the battery + for (var i = 0; i < 99; i++) { + car.drive(); + } + + assertThat(car.batteryDrained()).isFalse(); + } + + @Test + public void drive_until_battery_is_drained() { + int speed = 2; + int batteryDrain = 1; + var car = new NeedForSpeed(speed, batteryDrain); + + // Drain the battery + for (var i = 0; i < 100; i++) { + car.drive(); + } + + assertThat(car.batteryDrained()).isTrue(); + } + + @Test + public void nitro_car_has_not_driven_any_distance() { + var car = NeedForSpeed.nitro(); + assertThat(car.distanceDriven()).isEqualTo(0); + } + + @Test + public void nitro_car_has_battery_not_drained() { + var car = NeedForSpeed.nitro(); + assertThat(car.batteryDrained()).isFalse(); + } + + @Test + public void nitro_car_has_correct_speed() { + var car = NeedForSpeed.nitro(); + car.drive(); + assertThat(car.distanceDriven()).isEqualTo(50); + } + + @Test + public void nitro_has_correct_battery_drain() { + var car = NeedForSpeed.nitro(); + + // The battery is almost drained + for (var i = 0; i < 24; i++) { + car.drive(); + } + + assertThat(car.batteryDrained()).isFalse(); + + // Drain the battery + car.drive(); + + assertThat(car.batteryDrained()).isTrue(); + } + + @Test + public void car_can_finish_with_car_that_can_easily_finish() { + int speed = 10; + int batteryDrain = 2; + var car = new NeedForSpeed(speed, batteryDrain); + + int distance = 100; + var race = new RaceTrack(distance); + + assertThat(race.tryFinishTrack(car)).isTrue(); + } + + @Test + public void car_can_finish_with_car_that_can_just_finish() { + int speed = 2; + int batteryDrain = 10; + var car = new NeedForSpeed(speed, batteryDrain); + + int distance = 20; + var race = new RaceTrack(distance); + + assertThat(race.tryFinishTrack(car)).isTrue(); + } + + @Test + public void car_can_finish_with_car_that_just_cannot_finish() { + int speed = 3; + int batteryDrain = 20; + var car = new NeedForSpeed(speed, batteryDrain); + + int distance = 16; + var race = new RaceTrack(distance); + + assertThat(race.tryFinishTrack(car)).isFalse(); + } + + @Test + public void car_can_finish_with_car_that_cannot_finish() { + int speed = 1; + int batteryDrain = 20; + var car = new NeedForSpeed(speed, batteryDrain); + + int distance = 678; + var race = new RaceTrack(distance); + + assertThat(race.tryFinishTrack(car)).isFalse(); + } +} + diff --git a/scrabble-score/.exercism/config.json b/scrabble-score/.exercism/config.json new file mode 100644 index 0000000..3c14e2a --- /dev/null +++ b/scrabble-score/.exercism/config.json @@ -0,0 +1,40 @@ +{ + "authors": [], + "contributors": [ + "FridaTveit", + "jmrunkle", + "jonnynabors", + "jtigger", + "kytrinyx", + "lemoncurry", + "LuLechuan", + "matthewmorgan", + "msomji", + "muzimuzhi", + "sjwarner-bp", + "SleeplessByte", + "Smarticles101", + "sshine", + "stkent", + "vdemeester", + "vivshaw", + "Zaldrick" + ], + "files": { + "solution": [ + "src/main/java/Scrabble.java" + ], + "test": [ + "src/test/java/ScrabbleScoreTest.java" + ], + "example": [ + ".meta/src/reference/java/Scrabble.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Given a word, compute the Scrabble score for that word.", + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/scrabble-score/.exercism/metadata.json b/scrabble-score/.exercism/metadata.json new file mode 100644 index 0000000..d757b66 --- /dev/null +++ b/scrabble-score/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"scrabble-score","id":"632048d0fe6f431b97b56b5cfaf2015e","url":"https://exercism.org/tracks/java/exercises/scrabble-score","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/scrabble-score/.gradle/7.5.1/checksums/checksums.lock b/scrabble-score/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..a205374 Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/scrabble-score/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/scrabble-score/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..c35276e Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/scrabble-score/.gradle/7.5.1/dependencies-accessors/gc.properties b/scrabble-score/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.bin b/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..f175c6e Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.lock b/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..4266f40 Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/scrabble-score/.gradle/7.5.1/fileChanges/last-build.bin b/scrabble-score/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.bin b/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..8e42bf5 Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.lock b/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..248919d Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/scrabble-score/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/scrabble-score/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..eaaa5cf Binary files /dev/null and b/scrabble-score/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/scrabble-score/.gradle/7.5.1/gc.properties b/scrabble-score/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/scrabble-score/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/scrabble-score/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..433c2ba Binary files /dev/null and b/scrabble-score/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/scrabble-score/.gradle/buildOutputCleanup/cache.properties b/scrabble-score/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..02877e9 --- /dev/null +++ b/scrabble-score/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Mar 08 18:45:09 CET 2023 +gradle.version=7.5.1 diff --git a/scrabble-score/.gradle/buildOutputCleanup/outputFiles.bin b/scrabble-score/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..21cada8 Binary files /dev/null and b/scrabble-score/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/scrabble-score/.gradle/file-system.probe b/scrabble-score/.gradle/file-system.probe new file mode 100644 index 0000000..dd49304 Binary files /dev/null and b/scrabble-score/.gradle/file-system.probe differ diff --git a/scrabble-score/.gradle/vcs-1/gc.properties b/scrabble-score/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/scrabble-score/.idea/.gitignore b/scrabble-score/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/scrabble-score/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/scrabble-score/.idea/compiler.xml b/scrabble-score/.idea/compiler.xml new file mode 100644 index 0000000..ac216bc --- /dev/null +++ b/scrabble-score/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/scrabble-score/.idea/gradle.xml b/scrabble-score/.idea/gradle.xml new file mode 100644 index 0000000..7754215 --- /dev/null +++ b/scrabble-score/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/scrabble-score/.idea/jarRepositories.xml b/scrabble-score/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/scrabble-score/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/scrabble-score/.idea/misc.xml b/scrabble-score/.idea/misc.xml new file mode 100644 index 0000000..1412ac5 --- /dev/null +++ b/scrabble-score/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/scrabble-score/HELP.md b/scrabble-score/HELP.md new file mode 100644 index 0000000..1d7cc75 --- /dev/null +++ b/scrabble-score/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/Scrabble.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/scrabble-score/README.md b/scrabble-score/README.md new file mode 100644 index 0000000..c3b8620 --- /dev/null +++ b/scrabble-score/README.md @@ -0,0 +1,72 @@ +# Scrabble Score + +Welcome to Scrabble Score on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a word, compute the Scrabble score for that word. + +## Letter Values + +You'll need these: + +```text +Letter Value +A, E, I, O, U, L, N, R, S, T 1 +D, G 2 +B, C, M, P 3 +F, H, V, W, Y 4 +K 5 +J, X 8 +Q, Z 10 +``` + +## Examples + +"cabbage" should be scored as worth 14 points: + +- 3 points for C +- 1 point for A, twice +- 3 points for B, twice +- 2 points for G +- 1 point for E + +And to total: + +- `3 + 2*1 + 2*3 + 2 + 1` +- = `3 + 2 + 6 + 3` +- = `5 + 9` +- = 14 + +## Extensions + +- You can play a double or a triple letter. +- You can play a double or a triple word. + +## Source + +### Contributed to by + +- @FridaTveit +- @jmrunkle +- @jonnynabors +- @jtigger +- @kytrinyx +- @lemoncurry +- @LuLechuan +- @matthewmorgan +- @msomji +- @muzimuzhi +- @sjwarner-bp +- @SleeplessByte +- @Smarticles101 +- @sshine +- @stkent +- @vdemeester +- @vivshaw +- @Zaldrick + +### Based on + +Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup \ No newline at end of file diff --git a/scrabble-score/build.gradle b/scrabble-score/build.gradle new file mode 100644 index 0000000..ac0f6a7 --- /dev/null +++ b/scrabble-score/build.gradle @@ -0,0 +1,26 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 diff --git a/scrabble-score/build/classes/java/main/Scrabble.class b/scrabble-score/build/classes/java/main/Scrabble.class new file mode 100644 index 0000000..5292921 Binary files /dev/null and b/scrabble-score/build/classes/java/main/Scrabble.class differ diff --git a/scrabble-score/build/classes/java/test/ScrabbleScoreTest.class b/scrabble-score/build/classes/java/test/ScrabbleScoreTest.class new file mode 100644 index 0000000..21d41ca Binary files /dev/null and b/scrabble-score/build/classes/java/test/ScrabbleScoreTest.class differ diff --git a/scrabble-score/build/reports/tests/test/classes/ScrabbleScoreTest.html b/scrabble-score/build/reports/tests/test/classes/ScrabbleScoreTest.html new file mode 100644 index 0000000..d8b6c60 --- /dev/null +++ b/scrabble-score/build/reports/tests/test/classes/ScrabbleScoreTest.html @@ -0,0 +1,146 @@ + + + + + +Test results - Class ScrabbleScoreTest + + + + + +
+

Class ScrabbleScoreTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.002s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
testAEnglishLikeWord0spassed
testALongMixCaseWord0spassed
testALowerCaseLetter0spassed
testAMediumValuableWord0spassed
testAMediumWord0spassed
testAShortValuableWord0.001spassed
testAShortWord0spassed
testAUpperCaseLetter0spassed
testAValuableLetter0.001spassed
testAnEmptyInput0spassed
testEntireAlphabetAvailable0spassed
+
+
+ +
+ + diff --git a/scrabble-score/build/reports/tests/test/css/base-style.css b/scrabble-score/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/scrabble-score/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/scrabble-score/build/reports/tests/test/css/style.css b/scrabble-score/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/scrabble-score/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/scrabble-score/build/reports/tests/test/index.html b/scrabble-score/build/reports/tests/test/index.html new file mode 100644 index 0000000..4f29356 --- /dev/null +++ b/scrabble-score/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.002s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +11000.002s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+ScrabbleScoreTest +11000.002s100%
+
+
+ +
+ + diff --git a/scrabble-score/build/reports/tests/test/js/report.js b/scrabble-score/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/scrabble-score/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/scrabble-score/build/reports/tests/test/packages/default-package.html b/scrabble-score/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..aad01c4 --- /dev/null +++ b/scrabble-score/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
11
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.002s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+ScrabbleScoreTest +11000.002s100%
+
+
+ +
+ + diff --git a/scrabble-score/build/test-results/test/TEST-ScrabbleScoreTest.xml b/scrabble-score/build/test-results/test/TEST-ScrabbleScoreTest.xml new file mode 100644 index 0000000..75a2d00 --- /dev/null +++ b/scrabble-score/build/test-results/test/TEST-ScrabbleScoreTest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/scrabble-score/build/test-results/test/binary/output.bin b/scrabble-score/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/scrabble-score/build/test-results/test/binary/output.bin.idx b/scrabble-score/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/scrabble-score/build/test-results/test/binary/output.bin.idx differ diff --git a/scrabble-score/build/test-results/test/binary/results.bin b/scrabble-score/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..c0b3982 Binary files /dev/null and b/scrabble-score/build/test-results/test/binary/results.bin differ diff --git a/scrabble-score/build/tmp/compileJava/previous-compilation-data.bin b/scrabble-score/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..c3dc229 Binary files /dev/null and b/scrabble-score/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/scrabble-score/build/tmp/compileTestJava/previous-compilation-data.bin b/scrabble-score/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..081a68e Binary files /dev/null and b/scrabble-score/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/scrabble-score/gradle/wrapper/gradle-wrapper.jar b/scrabble-score/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/scrabble-score/gradle/wrapper/gradle-wrapper.jar differ diff --git a/scrabble-score/gradle/wrapper/gradle-wrapper.properties b/scrabble-score/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/scrabble-score/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/scrabble-score/gradlew b/scrabble-score/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/scrabble-score/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/scrabble-score/gradlew.bat b/scrabble-score/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/scrabble-score/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/scrabble-score/src/main/java/Scrabble.java b/scrabble-score/src/main/java/Scrabble.java new file mode 100644 index 0000000..993cf36 --- /dev/null +++ b/scrabble-score/src/main/java/Scrabble.java @@ -0,0 +1,67 @@ +class Scrabble { + + private String word; + + public Scrabble(String word) { + this.word = word.toLowerCase(); + } + + public int getScore() { + int points = 0; + for(int i = 0; i < word.length(); i++) { + switch (word.charAt(i)) { + case 'a': + case 'e': + case 'i': + case 'o': + case 'u': + case 'l': + case 'n': + case 'r': + case 's': + case 't': + points += 1; + break; + + case 'd': + case 'g': + points += 2; + break; + + case 'b': + case 'c': + case 'm': + case 'p': + points += 3; + break; + + case 'f': + case 'h': + case 'v': + case 'w': + case 'y': + points += 4; + break; + + case 'k': + points += 5; + break; + + case 'j': + case 'x': + points += 8; + break; + + case 'q': + case 'z': + points += 10; + + default: + + } + } + + return points; + } + +} diff --git a/scrabble-score/src/test/java/ScrabbleScoreTest.java b/scrabble-score/src/test/java/ScrabbleScoreTest.java new file mode 100644 index 0000000..65d9ef6 --- /dev/null +++ b/scrabble-score/src/test/java/ScrabbleScoreTest.java @@ -0,0 +1,74 @@ +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ScrabbleScoreTest { + + @Test + public void testALowerCaseLetter() { + Scrabble scrabble = new Scrabble("a"); + assertEquals(1, scrabble.getScore()); + } + + @Test + public void testAUpperCaseLetter() { + Scrabble scrabble = new Scrabble("A"); + assertEquals(1, scrabble.getScore()); + } + + @Test + public void testAValuableLetter() { + Scrabble scrabble = new Scrabble("f"); + assertEquals(4, scrabble.getScore()); + } + + @Test + public void testAShortWord() { + Scrabble scrabble = new Scrabble("at"); + assertEquals(2, scrabble.getScore()); + } + + @Test + public void testAShortValuableWord() { + Scrabble scrabble = new Scrabble("zoo"); + assertEquals(12, scrabble.getScore()); + } + + @Test + public void testAMediumWord() { + Scrabble scrabble = new Scrabble("street"); + assertEquals(6, scrabble.getScore()); + } + + @Test + public void testAMediumValuableWord() { + Scrabble scrabble = new Scrabble("quirky"); + assertEquals(22, scrabble.getScore()); + } + + @Test + public void testALongMixCaseWord() { + Scrabble scrabble = new Scrabble("OxyphenButazone"); + assertEquals(41, scrabble.getScore()); + } + + @Test + public void testAEnglishLikeWord() { + Scrabble scrabble = new Scrabble("pinata"); + assertEquals(8, scrabble.getScore()); + } + + @Test + public void testAnEmptyInput() { + Scrabble scrabble = new Scrabble(""); + assertEquals(0, scrabble.getScore()); + } + + @Test + public void testEntireAlphabetAvailable() { + Scrabble scrabble = new Scrabble("abcdefghijklmnopqrstuvwxyz"); + assertEquals(87, scrabble.getScore()); + } + +} diff --git a/squeaky-clean/.exercism/config.json b/squeaky-clean/.exercism/config.json new file mode 100644 index 0000000..5440c20 --- /dev/null +++ b/squeaky-clean/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "ystromm" + ], + "files": { + "solution": [ + "src/main/java/SqueakyClean.java" + ], + "test": [ + "src/test/java/SqueakyCleanTest.java" + ], + "exemplar": [ + ".meta/src/reference/java/SqueakyClean.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "forked_from": [ + "csharp/squeaky-clean" + ], + "blurb": "Learn about characters and StringBuilder by cleaning strings." +} diff --git a/squeaky-clean/.exercism/metadata.json b/squeaky-clean/.exercism/metadata.json new file mode 100644 index 0000000..b8d7cef --- /dev/null +++ b/squeaky-clean/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"squeaky-clean","id":"59e3a02272644cddb92f4bf0aa83748a","url":"https://exercism.org/tracks/java/exercises/squeaky-clean","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/squeaky-clean/.gradle/7.5.1/checksums/checksums.lock b/squeaky-clean/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..b5d171c Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/squeaky-clean/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/squeaky-clean/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..2c10b2d Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/squeaky-clean/.gradle/7.5.1/dependencies-accessors/gc.properties b/squeaky-clean/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.bin b/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..8e35ee2 Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.lock b/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..fc36054 Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/squeaky-clean/.gradle/7.5.1/fileChanges/last-build.bin b/squeaky-clean/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.bin b/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..dd6ef33 Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.lock b/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..732b639 Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/squeaky-clean/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/squeaky-clean/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..9e90bda Binary files /dev/null and b/squeaky-clean/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/squeaky-clean/.gradle/7.5.1/gc.properties b/squeaky-clean/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/squeaky-clean/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/squeaky-clean/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..ff200ec Binary files /dev/null and b/squeaky-clean/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/squeaky-clean/.gradle/buildOutputCleanup/cache.properties b/squeaky-clean/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..eeb2478 --- /dev/null +++ b/squeaky-clean/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 18:44:25 CET 2023 +gradle.version=7.5.1 diff --git a/squeaky-clean/.gradle/buildOutputCleanup/outputFiles.bin b/squeaky-clean/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..c3d89cb Binary files /dev/null and b/squeaky-clean/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/squeaky-clean/.gradle/file-system.probe b/squeaky-clean/.gradle/file-system.probe new file mode 100644 index 0000000..d809225 Binary files /dev/null and b/squeaky-clean/.gradle/file-system.probe differ diff --git a/squeaky-clean/.gradle/vcs-1/gc.properties b/squeaky-clean/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/squeaky-clean/.idea/.gitignore b/squeaky-clean/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/squeaky-clean/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/squeaky-clean/.idea/compiler.xml b/squeaky-clean/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/squeaky-clean/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/squeaky-clean/.idea/gradle.xml b/squeaky-clean/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/squeaky-clean/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/squeaky-clean/.idea/jarRepositories.xml b/squeaky-clean/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/squeaky-clean/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/squeaky-clean/.idea/misc.xml b/squeaky-clean/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/squeaky-clean/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/squeaky-clean/HELP.md b/squeaky-clean/HELP.md new file mode 100644 index 0000000..10aa8a8 --- /dev/null +++ b/squeaky-clean/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/SqueakyClean.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/squeaky-clean/HINTS.md b/squeaky-clean/HINTS.md new file mode 100644 index 0000000..f133655 --- /dev/null +++ b/squeaky-clean/HINTS.md @@ -0,0 +1,35 @@ +# Hints + +## 1. Replace any spaces encountered with underscores + +- [This tutorial][chars-tutorial] is useful. +- [Reference documentation][chars-docs] for `char`s is here. +- You can retrieve `char`s from a string using the [charAt][char-at] method. +- You should use a [`StringBuilder`][string-builder] to build the output string. +- See [this method][iswhitespace] for detecting spaces. Remember it is a static method. +- `char` literals are enclosed in single quotes. + +## 2. Replace control characters with the upper case string "CTRL" + +- See [this method][iscontrol] to check if a character is a control character. + +## 3. Convert kebab-case to camel-case + +- See [this method][toupper] to convert a character to upper case. + +## 4. Omit characters that are not letters + +- See [this method][isLetter] to check if a character is a letter. + +## 5. Omit Greek lower case letters + +- `char`s support the default equality and comparison operators. + +[chars-docs]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html +[chars-tutorial]: https://docs.oracle.com/javase/tutorial/java/data/characters.html +[char-at]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#charAt(int) +[string-builder]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/StringBuilder.html +[iswhitespace]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isWhitespace(char) +[iscontrol]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isISOControl(char) +[toupper]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#toUpperCase(char) +[isLetter]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isLetter(char) \ No newline at end of file diff --git a/squeaky-clean/README.md b/squeaky-clean/README.md new file mode 100644 index 0000000..f39ec01 --- /dev/null +++ b/squeaky-clean/README.md @@ -0,0 +1,84 @@ +# Squeaky Clean + +Welcome to Squeaky Clean on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +The Java `char` type represents the smallest addressable components of text. +Multiple `char`s can comprise a string such as `"word"` or `char`s can be +processed independently. Their literals have single quotes e.g. `'A'`. + +Java `char`s support Unicode encoding so in addition to the Latin character set +pretty much all the writing systems in use worldwide can be represented, +e.g. the Greek letter `'β'`. + +There are many builtin library methods to inspect and manipulate `char`s. These +can be found as static methods of the `java.lang.Character` class. + +`char`s are sometimes used in conjunction with a `StringBuilder` object. +This object has methods that allow a string to be constructed +character by character and manipulated. At the end of the process +`toString` can be called on it to output a complete string. + +## Instructions + +In this exercise you will implement a partial set of utility routines to help a developer +clean up SqueakyClean names. + +In the 4 tasks you will gradually build up the `clean` method. +A valid SqueakyClean name is comprised of zero or more letters and underscores. + +In all cases the input string is guaranteed to be non-null. Note that the `clean` method should treat an empty string as valid. + +## 1. Replace any spaces encountered with underscores + +Implement the (_static_) `SqueakyClean.clean()` method to replace any spaces with underscores. This also applies to leading and trailing spaces. + +```java +SqueakyClean.clean("my Id"); +// => "my___Id" +``` + +## 2. Replace control characters with the upper case string "CTRL" + +Modify the (_static_) `SqueakyClean.clean()` method to replace control characters with the upper case string `"CTRL"`. + +```java +SqueakyClean.clean("my\0Id"); +// => "myCTRLId", +``` + +## 3. Convert kebab-case to camelCase + +Modify the (_static_) `SqueakyClean.clean()` method to convert kebab-case to camelCase. + +```java +SqueakyClean.clean("à-ḃç"); +// => "àḂç" +``` + +## 4. Omit characters that are not letters + +Modify the (_static_) `SqueakyClean.clean()` method to omit any characters that are not letters. + +```java +SqueakyClean.clean("a1😀2😀3😀b"); +// => "ab" +``` + +## 5. Omit Greek lower case letters + +Modify the (_static_) `SqueakyClean.clean()` method to omit any Greek letters in the range 'α' to 'ω'. + +```java +SqueakyClean.clean("MyΟβιεγτFinder"); +// => "MyΟFinder" +``` + +## Source + +### Created by + +- @ystromm \ No newline at end of file diff --git a/squeaky-clean/build.gradle b/squeaky-clean/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/squeaky-clean/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/squeaky-clean/build/classes/java/main/SqueakyClean.class b/squeaky-clean/build/classes/java/main/SqueakyClean.class new file mode 100644 index 0000000..1dab5d6 Binary files /dev/null and b/squeaky-clean/build/classes/java/main/SqueakyClean.class differ diff --git a/squeaky-clean/build/classes/java/test/SqueakyCleanTest.class b/squeaky-clean/build/classes/java/test/SqueakyCleanTest.class new file mode 100644 index 0000000..d47bd9c Binary files /dev/null and b/squeaky-clean/build/classes/java/test/SqueakyCleanTest.class differ diff --git a/squeaky-clean/build/reports/tests/test/classes/SqueakyCleanTest.html b/squeaky-clean/build/reports/tests/test/classes/SqueakyCleanTest.html new file mode 100644 index 0000000..672e624 --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/classes/SqueakyCleanTest.html @@ -0,0 +1,793 @@ + + + + + +Test results - Class SqueakyCleanTest + + + + + +
+

Class SqueakyCleanTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
12
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.004s
+

duration

+
+
+
+
+
+
0%
+

successful

+
+
+
+
+ +
+

Failed tests

+
+ +

combine_conversions

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.combine_conversions(SqueakyCleanTest.java:64)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

ctrl

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.ctrl(SqueakyCleanTest.java:34)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

empty

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.empty(SqueakyCleanTest.java:9)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

kebab_to_camel_case

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.kebab_to_camel_case(SqueakyCleanTest.java:49)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

kebab_to_camel_case_no_letter

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.kebab_to_camel_case_no_letter(SqueakyCleanTest.java:54)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

keep_only_letters

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.keep_only_letters(SqueakyCleanTest.java:44)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

leading_and_trailing_spaces

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.leading_and_trailing_spaces(SqueakyCleanTest.java:29)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

omit_lower_case_greek_letters

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.omit_lower_case_greek_letters(SqueakyCleanTest.java:59)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

single_letter

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.single_letter(SqueakyCleanTest.java:14)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

spaces

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.spaces(SqueakyCleanTest.java:24)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

string

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.string(SqueakyCleanTest.java:19)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+ +

string_with_no_letters

+ +
java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method
+	at SqueakyClean.clean(SqueakyClean.java:3)
+	at SqueakyCleanTest.string_with_no_letters(SqueakyCleanTest.java:39)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
+	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
+	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
+	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
+	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
+	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
+	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
+	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
+	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
+	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
+	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
+	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
+	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
+	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
+	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
+	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
+	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
+	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
+	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
+	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
+	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
+	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
+	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
+	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
+
+
+
+
+
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
combine_conversions0sfailed
ctrl0sfailed
empty0sfailed
kebab_to_camel_case0sfailed
kebab_to_camel_case_no_letter0sfailed
keep_only_letters0.002sfailed
leading_and_trailing_spaces0sfailed
omit_lower_case_greek_letters0sfailed
single_letter0sfailed
spaces0.001sfailed
string0sfailed
string_with_no_letters0.001sfailed
+
+
+ +
+ + diff --git a/squeaky-clean/build/reports/tests/test/css/base-style.css b/squeaky-clean/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/squeaky-clean/build/reports/tests/test/css/style.css b/squeaky-clean/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/squeaky-clean/build/reports/tests/test/index.html b/squeaky-clean/build/reports/tests/test/index.html new file mode 100644 index 0000000..8a80c66 --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/index.html @@ -0,0 +1,189 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
12
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.004s
+

duration

+
+
+
+
+
+
0%
+

successful

+
+
+
+
+ + +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +121200.004s0%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+SqueakyCleanTest +121200.004s0%
+
+
+ +
+ + diff --git a/squeaky-clean/build/reports/tests/test/js/report.js b/squeaky-clean/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/squeaky-clean/build/reports/tests/test/packages/default-package.html b/squeaky-clean/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..00ea9d0 --- /dev/null +++ b/squeaky-clean/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,159 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
12
+

tests

+
+
+
+
12
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.004s
+

duration

+
+
+
+
+
+
0%
+

successful

+
+
+
+ + +
+ + diff --git a/squeaky-clean/build/test-results/test/TEST-SqueakyCleanTest.xml b/squeaky-clean/build/test-results/test/TEST-SqueakyCleanTest.xml new file mode 100644 index 0000000..409578c --- /dev/null +++ b/squeaky-clean/build/test-results/test/TEST-SqueakyCleanTest.xml @@ -0,0 +1,594 @@ + + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.keep_only_letters(SqueakyCleanTest.java:44) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.omit_lower_case_greek_letters(SqueakyCleanTest.java:59) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.spaces(SqueakyCleanTest.java:24) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.string(SqueakyCleanTest.java:19) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.kebab_to_camel_case_no_letter(SqueakyCleanTest.java:54) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.string_with_no_letters(SqueakyCleanTest.java:39) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.ctrl(SqueakyCleanTest.java:34) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.empty(SqueakyCleanTest.java:9) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.leading_and_trailing_spaces(SqueakyCleanTest.java:29) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.combine_conversions(SqueakyCleanTest.java:64) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.kebab_to_camel_case(SqueakyCleanTest.java:49) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + java.lang.UnsupportedOperationException: Please implement the (static) SqueakyClean.clean() method + at SqueakyClean.clean(SqueakyClean.java:3) + at SqueakyCleanTest.single_letter(SqueakyCleanTest.java:14) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) + at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) + at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) + at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) + at org.junit.runners.ParentRunner.run(ParentRunner.java:413) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:566) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) + at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) + at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) + at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) + + + + + diff --git a/squeaky-clean/build/test-results/test/binary/output.bin b/squeaky-clean/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/squeaky-clean/build/test-results/test/binary/output.bin.idx b/squeaky-clean/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/squeaky-clean/build/test-results/test/binary/output.bin.idx differ diff --git a/squeaky-clean/build/test-results/test/binary/results.bin b/squeaky-clean/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..76ce757 Binary files /dev/null and b/squeaky-clean/build/test-results/test/binary/results.bin differ diff --git a/squeaky-clean/build/tmp/compileJava/previous-compilation-data.bin b/squeaky-clean/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..52af1ec Binary files /dev/null and b/squeaky-clean/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/squeaky-clean/build/tmp/compileTestJava/previous-compilation-data.bin b/squeaky-clean/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..273ac4e Binary files /dev/null and b/squeaky-clean/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/squeaky-clean/gradle/wrapper/gradle-wrapper.jar b/squeaky-clean/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/squeaky-clean/gradle/wrapper/gradle-wrapper.jar differ diff --git a/squeaky-clean/gradle/wrapper/gradle-wrapper.properties b/squeaky-clean/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/squeaky-clean/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/squeaky-clean/gradlew b/squeaky-clean/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/squeaky-clean/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/squeaky-clean/gradlew.bat b/squeaky-clean/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/squeaky-clean/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/squeaky-clean/src/main/java/SqueakyClean.java b/squeaky-clean/src/main/java/SqueakyClean.java new file mode 100644 index 0000000..cbb313e --- /dev/null +++ b/squeaky-clean/src/main/java/SqueakyClean.java @@ -0,0 +1,21 @@ +import java.util.Locale; +import java.util.regex.Pattern; + +class SqueakyClean { + static String clean(String identifier) { + + var result = identifier.replace(' ', '_') + .replaceAll("[α-ω]", "") + .replaceAll("\\p{C}", "CTRL") + .replaceAll("[^\\p{L}\\p{P}]", ""); + var matcher = Pattern.compile("(.*)(-\\p{L})(.*)").matcher(result); + if (matcher.matches()) { + result = matcher.replaceAll( + matcher.group(1) + + matcher.group(2).toUpperCase(Locale.ROOT).substring(1) + + matcher.group(3) + ); + } + return result; + } +} \ No newline at end of file diff --git a/squeaky-clean/src/test/java/SqueakyCleanTest.java b/squeaky-clean/src/test/java/SqueakyCleanTest.java new file mode 100644 index 0000000..f5adb33 --- /dev/null +++ b/squeaky-clean/src/test/java/SqueakyCleanTest.java @@ -0,0 +1,66 @@ +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SqueakyCleanTest { + + @Test + public void empty() { + assertThat(SqueakyClean.clean("")).isEmpty(); + } + + @Test + public void single_letter() { + assertThat(SqueakyClean.clean("A")).isEqualTo("A"); + } + + @Test + public void string() { + assertThat(SqueakyClean.clean("àḃç")).isEqualTo("àḃç"); + } + + @Test + public void spaces() { + assertThat(SqueakyClean.clean("my Id")).isEqualTo("my___Id"); + } + + @Test + public void leading_and_trailing_spaces() { + assertThat(SqueakyClean.clean(" myId ")).isEqualTo("_myId_"); + } + + @Test + public void ctrl() { + assertThat(SqueakyClean.clean("my\0\r\u007FId")).isEqualTo("myCTRLCTRLCTRLId"); + } + + @Test + public void string_with_no_letters() { + assertThat(SqueakyClean.clean("\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00")).isEmpty(); + } + + @Test + public void keep_only_letters() { + assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab"); + } + + @Test + public void kebab_to_camel_case() { + assertThat(SqueakyClean.clean("à-ḃç")).isEqualTo("àḂç"); + } + + @Test + public void kebab_to_camel_case_no_letter() { + assertThat(SqueakyClean.clean("a-1C")).isEqualTo("aC"); + } + + @Test + public void omit_lower_case_greek_letters() { + assertThat(SqueakyClean.clean("MyΟβιεγτFinder")).isEqualTo("MyΟFinder"); + } + + @Test + public void combine_conversions() { + assertThat(SqueakyClean.clean("9 -abcĐ\uD83D\uDE00ω\0")).isEqualTo("_AbcĐCTRL"); + } +} diff --git a/two-fer/.exercism/config.json b/two-fer/.exercism/config.json new file mode 100644 index 0000000..d6d255b --- /dev/null +++ b/two-fer/.exercism/config.json @@ -0,0 +1,39 @@ +{ + "authors": [ + "Smarticles101" + ], + "contributors": [ + "FridaTveit", + "ikhadykin", + "jmrunkle", + "jssander", + "kytrinyx", + "lemoncurry", + "msomji", + "muzimuzhi", + "rdavid1099", + "sjwarner-bp", + "SleeplessByte", + "sshine", + "stkent", + "uzilan", + "Valkryst", + "ymoskovits" + ], + "files": { + "solution": [ + "src/main/java/Twofer.java" + ], + "test": [ + "src/test/java/TwoferTest.java" + ], + "example": [ + ".meta/src/reference/java/Twofer.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Create a sentence of the form \"One for X, one for me.\"", + "source_url": "https://github.com/exercism/problem-specifications/issues/757" +} diff --git a/two-fer/.exercism/metadata.json b/two-fer/.exercism/metadata.json new file mode 100644 index 0000000..64289f6 --- /dev/null +++ b/two-fer/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"java","exercise":"two-fer","id":"8023acb3fc954e4ea9527b9e83691ebb","url":"https://exercism.org/tracks/java/exercises/two-fer","handle":"GicoProgram","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/two-fer/.gradle/7.5.1/checksums/checksums.lock b/two-fer/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..e366cd1 Binary files /dev/null and b/two-fer/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/two-fer/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/two-fer/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..e6b6178 Binary files /dev/null and b/two-fer/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/two-fer/.gradle/7.5.1/dependencies-accessors/gc.properties b/two-fer/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/two-fer/.gradle/7.5.1/executionHistory/executionHistory.bin b/two-fer/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..46729ed Binary files /dev/null and b/two-fer/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/two-fer/.gradle/7.5.1/executionHistory/executionHistory.lock b/two-fer/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..70fe7ad Binary files /dev/null and b/two-fer/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/two-fer/.gradle/7.5.1/fileChanges/last-build.bin b/two-fer/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/two-fer/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/two-fer/.gradle/7.5.1/fileHashes/fileHashes.bin b/two-fer/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..3ceaa78 Binary files /dev/null and b/two-fer/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/two-fer/.gradle/7.5.1/fileHashes/fileHashes.lock b/two-fer/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..8d0f577 Binary files /dev/null and b/two-fer/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/two-fer/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/two-fer/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..18cb1ee Binary files /dev/null and b/two-fer/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/two-fer/.gradle/7.5.1/gc.properties b/two-fer/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/two-fer/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/two-fer/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..fd4b70c Binary files /dev/null and b/two-fer/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/two-fer/.gradle/buildOutputCleanup/cache.properties b/two-fer/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..d95f9aa --- /dev/null +++ b/two-fer/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 07 19:03:27 CET 2023 +gradle.version=7.5.1 diff --git a/two-fer/.gradle/buildOutputCleanup/outputFiles.bin b/two-fer/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..345134c Binary files /dev/null and b/two-fer/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/two-fer/.gradle/file-system.probe b/two-fer/.gradle/file-system.probe new file mode 100644 index 0000000..68ecc48 Binary files /dev/null and b/two-fer/.gradle/file-system.probe differ diff --git a/two-fer/.gradle/vcs-1/gc.properties b/two-fer/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/two-fer/.idea/.gitignore b/two-fer/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/two-fer/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/two-fer/.idea/compiler.xml b/two-fer/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/two-fer/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/two-fer/.idea/gradle.xml b/two-fer/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/two-fer/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/two-fer/.idea/jarRepositories.xml b/two-fer/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/two-fer/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/two-fer/.idea/misc.xml b/two-fer/.idea/misc.xml new file mode 100644 index 0000000..25d34a4 --- /dev/null +++ b/two-fer/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/two-fer/HELP.md b/two-fer/HELP.md new file mode 100644 index 0000000..d678c75 --- /dev/null +++ b/two-fer/HELP.md @@ -0,0 +1,131 @@ +# Help + +## Running the tests + +Choose your operating system: + +* [Windows](#windows) +* [macOS](#macos) +* [Linux](#linux) + +---- + +1. Open a Command Prompt. +2. Get the first exercise: + + ```batchfile + C:\Users\JohnDoe>exercism download --exercise hello-world --track java + + Not Submitted: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + New: 1 problem + java (Hello World) C:\Users\JohnDoe\exercism\java\hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +3. Change directory into the exercism: + + ```batchfile + C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\java\hello-world + ``` + +4. Run the tests: + + ```batchfile + C:\Users\JohnDoe>gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /Users/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + ``` + +2. Change directory into the exercise: + + ``` + $ cd /Users/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +---- + +1. In the terminal window, get the first exercise: + + ``` + $ exercism download --exercise hello-world --track java + + New: 1 problem + Java (Etl) /home/johndoe/exercism/java/hello-world + + unchanged: 0, updated: 0, new: 1 + + ``` + +2. Change directory into the exercise: + + ``` + $ cd /home/johndoe/exercism/java/hello-world + ``` + +3. Run the tests: + + ``` + $ gradle test + ``` + *(Don't worry about the tests failing, at first, this is how you begin each exercise.)* + +4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)). + +Good luck! Have fun! + +## Submitting your solution + +You can submit your solution using the `exercism submit src/main/java/Twofer.java` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Java track's documentation](https://exercism.org/docs/tracks/java) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +If you need some help you can visit these resources: + +* [Stack Overflow](https://stackoverflow.com/questions/tagged/java), +* [The Java subreddit](https://www.reddit.com/r/java), +* [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). \ No newline at end of file diff --git a/two-fer/README.md b/two-fer/README.md new file mode 100644 index 0000000..5a7ee04 --- /dev/null +++ b/two-fer/README.md @@ -0,0 +1,110 @@ +# Two Fer + +Welcome to Two Fer on Exercism's Java Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +In some English accents, when you say "two for" quickly, it sounds like "two fer". +Two-for-one is a way of saying that if you buy one, you also get one for free. +So the phrase "two-fer" often implies a two-for-one offer. + +Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). +You go for the offer and (very generously) decide to give the extra cookie to a friend. + +## Instructions + +Your task is to determine what you will say as you give away the extra cookie. + +If your friend likes cookies, and is named Do-yun, then you will say: + +```text +One for Do-yun, one for me. +``` + +If your friend doesn't like cookies, you give the cookie to the next person in line at the bakery. +Since you don't know their name, you will say _you_ instead. + +```text +One for you, one for me. +``` + +Here are some examples: + +|Name |Dialogue +|:-------|:------------------ +|Alice |One for Alice, one for me. +|Bohdan |One for Bohdan, one for me. +| |One for you, one for me. +|Zaphod |One for Zaphod, one for me. + +Before you start, make sure you understand how to write code that can pass the test cases. +For more context, check out this [tutorial](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial). + +Most Java exercises include multiple test cases. These cases are structured to +support a useful process known as +[test-driven development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development). +TDD involves repeating a structured cycle that helps programmers build complex +functionality piece by piece rather than all at once. That cycle can be +described as follows: + +1. Add a test that describes one piece of desired functionality your code is +currently missing. +2. Run the tests to verify that this newly-added test fails. +3. Update your existing code until: + - All the old tests continue to pass; + - The new test also passes. +4. [Clean up](https://en.wikipedia.org/wiki/Code_refactoring) your code, making +sure that all tests continue to pass. This typically involves renaming +variables, removing duplicated chunks of logic, removing leftover logging, etc. +5. Return to step 1 until all desired functionality has been built! + +The test files in this track contain _all_ the tests your solution should pass +to be considered valid. That doesn't immediately seem to be compatible with the +cycle described above, in which tests are written one by one. However, the +tool that we use to write our tests, [JUnit](http://junit.org), provides an +[@Ignore](http://junit.sourceforge.net/javadoc/org/junit/Ignore.html) +[annotation](https://docs.oracle.com/javase/tutorial/java/annotations/) that +can be used to temporarily skip an already-written test. Using this annotation, +we make sure that the test files we deliver to you satisfy the following rules: + +- The first test in any test file is _not_ skipped by default. +- All but the first test in any test file _are_ skipped by default. + +This allows you to simulate the TDD cycle by following these slightly-modified +steps: + +1. Run the tests to verify that _at most one_ test currently fails. +2. Update your existing code until all the non-skipped tests pass. +3. Clean up your code, making sure that all non-skipped tests continue to pass. +4. Remove the topmost `@Ignore` annotation in the test file. +5. Return to step 1 until no tests are skipped and all tests pass! + +## Source + +### Created by + +- @Smarticles101 + +### Contributed to by + +- @FridaTveit +- @ikhadykin +- @jmrunkle +- @jssander +- @kytrinyx +- @lemoncurry +- @msomji +- @muzimuzhi +- @rdavid1099 +- @sjwarner-bp +- @SleeplessByte +- @sshine +- @stkent +- @uzilan +- @Valkryst +- @ymoskovits + +### Based on + +https://github.com/exercism/problem-specifications/issues/757 \ No newline at end of file diff --git a/two-fer/build.gradle b/two-fer/build.gradle new file mode 100644 index 0000000..8bd005d --- /dev/null +++ b/two-fer/build.gradle @@ -0,0 +1,24 @@ +apply plugin: "java" +apply plugin: "eclipse" +apply plugin: "idea" + +// set default encoding to UTF-8 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation "junit:junit:4.13" + testImplementation "org.assertj:assertj-core:3.15.0" +} + +test { + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/two-fer/build/classes/java/main/Twofer.class b/two-fer/build/classes/java/main/Twofer.class new file mode 100644 index 0000000..31198e0 Binary files /dev/null and b/two-fer/build/classes/java/main/Twofer.class differ diff --git a/two-fer/build/classes/java/test/TwoferTest.class b/two-fer/build/classes/java/test/TwoferTest.class new file mode 100644 index 0000000..8631c03 Binary files /dev/null and b/two-fer/build/classes/java/test/TwoferTest.class differ diff --git a/two-fer/build/reports/tests/test/classes/TwoferTest.html b/two-fer/build/reports/tests/test/classes/TwoferTest.html new file mode 100644 index 0000000..dddf8ef --- /dev/null +++ b/two-fer/build/reports/tests/test/classes/TwoferTest.html @@ -0,0 +1,106 @@ + + + + + +Test results - Class TwoferTest + + + + + +
+

Class TwoferTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
3
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.037s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
aNameGiven0.010spassed
anotherNameGiven0spassed
noNameGiven0.027spassed
+
+
+ +
+ + diff --git a/two-fer/build/reports/tests/test/css/base-style.css b/two-fer/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/two-fer/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/two-fer/build/reports/tests/test/css/style.css b/two-fer/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/two-fer/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/two-fer/build/reports/tests/test/index.html b/two-fer/build/reports/tests/test/index.html new file mode 100644 index 0000000..1545ad6 --- /dev/null +++ b/two-fer/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
3
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.037s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+default-package +3000.037s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+TwoferTest +3000.037s100%
+
+
+ +
+ + diff --git a/two-fer/build/reports/tests/test/js/report.js b/two-fer/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/two-fer/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/two-fer/build/reports/tests/test/packages/default-package.html b/two-fer/build/reports/tests/test/packages/default-package.html new file mode 100644 index 0000000..0fcc62b --- /dev/null +++ b/two-fer/build/reports/tests/test/packages/default-package.html @@ -0,0 +1,103 @@ + + + + + +Test results - Default package + + + + + +
+

Default package

+ +
+ + + + + +
+
+ + + + + + + +
+
+
3
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.037s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+TwoferTest +3000.037s100%
+
+
+ +
+ + diff --git a/two-fer/build/test-results/test/TEST-TwoferTest.xml b/two-fer/build/test-results/test/TEST-TwoferTest.xml new file mode 100644 index 0000000..bda2c9c --- /dev/null +++ b/two-fer/build/test-results/test/TEST-TwoferTest.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/two-fer/build/test-results/test/binary/output.bin b/two-fer/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/two-fer/build/test-results/test/binary/output.bin.idx b/two-fer/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/two-fer/build/test-results/test/binary/output.bin.idx differ diff --git a/two-fer/build/test-results/test/binary/results.bin b/two-fer/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..0442376 Binary files /dev/null and b/two-fer/build/test-results/test/binary/results.bin differ diff --git a/two-fer/build/tmp/compileJava/previous-compilation-data.bin b/two-fer/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..61ee4b7 Binary files /dev/null and b/two-fer/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/two-fer/build/tmp/compileTestJava/previous-compilation-data.bin b/two-fer/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..f04604d Binary files /dev/null and b/two-fer/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/two-fer/gradle/wrapper/gradle-wrapper.jar b/two-fer/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/two-fer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/two-fer/gradle/wrapper/gradle-wrapper.properties b/two-fer/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/two-fer/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/two-fer/gradlew b/two-fer/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/two-fer/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/two-fer/gradlew.bat b/two-fer/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/two-fer/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/two-fer/src/main/java/Twofer.java b/two-fer/src/main/java/Twofer.java new file mode 100644 index 0000000..edf6132 --- /dev/null +++ b/two-fer/src/main/java/Twofer.java @@ -0,0 +1,8 @@ +public class Twofer { + public String twofer(String name) { + String text = "One for "; + if (name == null) text += "you"; + else text += name; + return text += ", one for me."; + } +} diff --git a/two-fer/src/test/java/TwoferTest.java b/two-fer/src/test/java/TwoferTest.java new file mode 100644 index 0000000..fd42572 --- /dev/null +++ b/two-fer/src/test/java/TwoferTest.java @@ -0,0 +1,34 @@ +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TwoferTest { + + private Twofer twofer; + + @Before + public void setup() { + twofer = new Twofer(); + } + + @Test + public void noNameGiven() { + assertThat(twofer.twofer(null)) + .isEqualTo("One for you, one for me."); + } + + @Test + public void aNameGiven() { + assertThat(twofer.twofer("Alice")) + .isEqualTo("One for Alice, one for me."); + } + + @Test + public void anotherNameGiven() { + assertThat(twofer.twofer("Bob")) + .isEqualTo("One for Bob, one for me."); + } + +}