From 4bc15bfce9b4b8f48d67b7e001d84330acb2cac5 Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Tue, 1 Oct 2019 15:48:41 +0200
Subject: [PATCH 1/8] Implement Resistor Color Duo
Implement, with the example using enumeration.
---
config.json | 12 ++++
exercises/resistor-color-duo/.classpath | 18 +++++
.../src/reference/java/ResistorColorDuo.java | 15 +++++
exercises/resistor-color-duo/.project | 23 +++++++
.../org.eclipse.buildship.core.prefs | 13 ++++
exercises/resistor-color-duo/README.md | 59 ++++++++++++++++
.../bin/starterSource/ResistorColorDuo.class | Bin 0 -> 558 bytes
exercises/resistor-color-duo/build.gradle | 18 +++++
.../src/main/java/ResistorColorDuo.java | 5 ++
.../src/test/java/ResistorColorDuoTest.java | 63 ++++++++++++++++++
exercises/settings.gradle | 1 +
11 files changed, 227 insertions(+)
create mode 100644 exercises/resistor-color-duo/.classpath
create mode 100644 exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
create mode 100644 exercises/resistor-color-duo/.project
create mode 100644 exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
create mode 100644 exercises/resistor-color-duo/README.md
create mode 100644 exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class
create mode 100644 exercises/resistor-color-duo/build.gradle
create mode 100644 exercises/resistor-color-duo/src/main/java/ResistorColorDuo.java
create mode 100644 exercises/resistor-color-duo/src/test/java/ResistorColorDuoTest.java
diff --git a/config.json b/config.json
index 82eb0baed..0fd7fab37 100644
--- a/config.json
+++ b/config.json
@@ -49,6 +49,18 @@
"strings"
]
},
+ {
+ "slug":"resistor-color-duo",
+ "uuid": "0ae1989d-df46-414d-ad1f-4bd0f0f78421",
+ "core": false,
+ "unlocked_by": "two-fer",
+ "difficulty": 3,
+ "topics": [
+ "arrays",
+ "strings",
+ "enumerations"
+ ]
+ },
{
"slug": "darts",
"uuid": "4d400a44-b190-4a0c-affb-99fad8ea18da",
diff --git a/exercises/resistor-color-duo/.classpath b/exercises/resistor-color-duo/.classpath
new file mode 100644
index 000000000..c6d091f29
--- /dev/null
+++ b/exercises/resistor-color-duo/.classpath
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
new file mode 100644
index 000000000..815776428
--- /dev/null
+++ b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
@@ -0,0 +1,15 @@
+/**
+ * Example Class
+ */
+public class ResistorColorDuo {
+ public enum Color {
+ black, brown, red, orange, yellow, green, blue, violet, grey, white;
+ };
+
+ int colorCode(String[] colors) {
+ int resistance = 0;
+ resistance += 10 * Color.valueOf(colors[0]).ordinal();
+ resistance += Color.valueOf(colors[1]).ordinal();
+ return resistance;
+ }
+}
diff --git a/exercises/resistor-color-duo/.project b/exercises/resistor-color-duo/.project
new file mode 100644
index 000000000..69abdd77e
--- /dev/null
+++ b/exercises/resistor-color-duo/.project
@@ -0,0 +1,23 @@
+
+
+ resistor-color-duo
+ Project resistor-color-duo created by Buildship.
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.buildship.core.gradleprojectnature
+
+
diff --git a/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs b/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 000000000..7338097b8
--- /dev/null
+++ b/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,13 @@
+arguments=
+auto.sync=false
+build.scans.enabled=false
+connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.4))
+connection.project.dir=
+eclipse.preferences.version=1
+gradle.user.home=
+java.home=
+jvm.arguments=
+offline.mode=false
+override.workspace.settings=true
+show.console.view=true
+show.executions.view=true
diff --git a/exercises/resistor-color-duo/README.md b/exercises/resistor-color-duo/README.md
new file mode 100644
index 000000000..ac0656df0
--- /dev/null
+++ b/exercises/resistor-color-duo/README.md
@@ -0,0 +1,59 @@
+# Resistor Color Duo
+
+If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know two things about them:
+
+* Each resistor has a resistance value.
+* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
+To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band has a position and a numeric value. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.
+
+In this exercise you are going to create a helpful program so that you don't have to remember the values of the bands. The program will take color names as input and output a two digit number, even if the input is more than two colors!
+
+
+The band colors are encoded as follows:
+
+- Black: 0
+- Brown: 1
+- Red: 2
+- Orange: 3
+- Yellow: 4
+- Green: 5
+- Blue: 6
+- Violet: 7
+- Grey: 8
+- White: 9
+
+From the example above:
+brown-green should return 15
+brown-green-violet should return 15 too, ignoring the third color.
+
+
+## Setup
+
+Go through the setup instructions for Java to install the necessary
+dependencies:
+
+[https://exercism.io/tracks/java/installation](https://exercism.io/tracks/java/installation)
+
+# Running the tests
+
+You can run all the tests for an exercise by entering the following in your
+terminal:
+
+```sh
+$ gradle test
+```
+
+> Use `gradlew.bat` if you're on Windows
+
+In the test suites all tests but the first have been skipped.
+
+Once you get a test passing, you can enable the next one by removing the
+`@Ignore("Remove to run test")` annotation.
+
+## Source
+
+Maud de Vries, Erik Schierboom [https://github.com/exercism/problem-specifications/issues/1464](https://github.com/exercism/problem-specifications/issues/1464)
+
+## Submitting Incomplete Solutions
+It's possible to submit an incomplete solution so you can see how others have
+completed the exercise.
diff --git a/exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class b/exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class
new file mode 100644
index 0000000000000000000000000000000000000000..312460b76f26a69f142c4d936b232245106227f6
GIT binary patch
literal 558
zcmZvZNlyYn5QSd@vWyD|g4<3ZXaA=A?%;USH}8di{HC=R3&XOri9Vjk-Owk
zVQBY7D6H_^yMAoB6=R{S&(+AE8cD*7o)}+Gl`qFpn1~6b>7j(GYp%vnt^Z?&rjSh>
zQ$Lk|+%kBV#16!XbmOQlciePszz2<#eh84FMWduRN4FN8%w-N|$iF7CN4t|jYnAr3
yc>$g46agD3QpSDUC8Wc7?
Date: Fri, 4 Oct 2019 18:54:04 +0200
Subject: [PATCH 2/8] Apply requested changes
---
exercises/resistor-color-duo/.classpath | 18 --------------
.../src/reference/java/ResistorColorDuo.java | 11 +++------
exercises/resistor-color-duo/.project | 23 ------------------
.../org.eclipse.buildship.core.prefs | 13 ----------
.../bin/starterSource/ResistorColorDuo.class | Bin 558 -> 0 bytes
.../src/main/java/ResistorColorDuo.java | 2 +-
.../src/test/java/ResistorColorDuoTest.java | 20 +++++++--------
7 files changed, 15 insertions(+), 72 deletions(-)
delete mode 100644 exercises/resistor-color-duo/.classpath
delete mode 100644 exercises/resistor-color-duo/.project
delete mode 100644 exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
delete mode 100644 exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class
diff --git a/exercises/resistor-color-duo/.classpath b/exercises/resistor-color-duo/.classpath
deleted file mode 100644
index c6d091f29..000000000
--- a/exercises/resistor-color-duo/.classpath
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
index 815776428..66ca4b671 100644
--- a/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
+++ b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
@@ -1,15 +1,12 @@
/**
* Example Class
*/
-public class ResistorColorDuo {
- public enum Color {
+class ResistorColorDuo {
+ private enum Color {
black, brown, red, orange, yellow, green, blue, violet, grey, white;
};
- int colorCode(String[] colors) {
- int resistance = 0;
- resistance += 10 * Color.valueOf(colors[0]).ordinal();
- resistance += Color.valueOf(colors[1]).ordinal();
- return resistance;
+ int value(String[] colors) {
+ return 10 * Color.valueOf(colors[0]).ordinal() + Color.valueOf(colors[1]).ordinal();
}
}
diff --git a/exercises/resistor-color-duo/.project b/exercises/resistor-color-duo/.project
deleted file mode 100644
index 69abdd77e..000000000
--- a/exercises/resistor-color-duo/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- resistor-color-duo
- Project resistor-color-duo created by Buildship.
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.buildship.core.gradleprojectbuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.buildship.core.gradleprojectnature
-
-
diff --git a/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs b/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
deleted file mode 100644
index 7338097b8..000000000
--- a/exercises/resistor-color-duo/.settings/org.eclipse.buildship.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-arguments=
-auto.sync=false
-build.scans.enabled=false
-connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.4))
-connection.project.dir=
-eclipse.preferences.version=1
-gradle.user.home=
-java.home=
-jvm.arguments=
-offline.mode=false
-override.workspace.settings=true
-show.console.view=true
-show.executions.view=true
diff --git a/exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class b/exercises/resistor-color-duo/bin/starterSource/ResistorColorDuo.class
deleted file mode 100644
index 312460b76f26a69f142c4d936b232245106227f6..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 558
zcmZvZNlyYn5QSd@vWyD|g4<3ZXaA=A?%;USH}8di{HC=R3&XOri9Vjk-Owk
zVQBY7D6H_^yMAoB6=R{S&(+AE8cD*7o)}+Gl`qFpn1~6b>7j(GYp%vnt^Z?&rjSh>
zQ$Lk|+%kBV#16!XbmOQlciePszz2<#eh84FMWduRN4FN8%w-N|$iF7CN4t|jYnAr3
yc>$g46agD3QpSDUC8Wc7?
Date: Thu, 10 Oct 2019 11:55:09 +0200
Subject: [PATCH 3/8] remove unnecessary javadoc
---
.../.meta/src/reference/java/ResistorColorDuo.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
index 66ca4b671..88fee4c20 100644
--- a/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
+++ b/exercises/resistor-color-duo/.meta/src/reference/java/ResistorColorDuo.java
@@ -1,6 +1,3 @@
-/**
- * Example Class
- */
class ResistorColorDuo {
private enum Color {
black, brown, red, orange, yellow, green, blue, violet, grey, white;
From 7752b91a32ef37eac9b78aec5c95e62e300c9097 Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Sat, 12 Oct 2019 13:31:32 +0200
Subject: [PATCH 4/8] Add version file
---
exercises/resistor-color-duo/.meta/version | 1 +
1 file changed, 1 insertion(+)
create mode 100644 exercises/resistor-color-duo/.meta/version
diff --git a/exercises/resistor-color-duo/.meta/version b/exercises/resistor-color-duo/.meta/version
new file mode 100644
index 000000000..7ec1d6db4
--- /dev/null
+++ b/exercises/resistor-color-duo/.meta/version
@@ -0,0 +1 @@
+2.1.0
From 5149cd2c6571b56a7a4cde988e503d8b7d4a84a0 Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Sat, 12 Oct 2019 14:01:11 +0200
Subject: [PATCH 5/8] Setup Resistor-Color-Trio
Include resistor-color-trio
---
config.json | 14 +++-
.../src/reference/java/ResistorColorTrio.java | 9 +++
exercises/resistor-color-trio/.meta/version | 1 +
exercises/resistor-color-trio/README.md | 76 +++++++++++++++++++
exercises/resistor-color-trio/build.gradle | 18 +++++
.../src/main/java/ResistorColorTrio.java | 5 ++
.../src/test/java/ResistorColorTrioTest.java | 8 ++
exercises/settings.gradle | 1 +
8 files changed, 131 insertions(+), 1 deletion(-)
create mode 100644 exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
create mode 100644 exercises/resistor-color-trio/.meta/version
create mode 100644 exercises/resistor-color-trio/README.md
create mode 100644 exercises/resistor-color-trio/build.gradle
create mode 100644 exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
create mode 100644 exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
diff --git a/config.json b/config.json
index 0fd7fab37..ee6341385 100644
--- a/config.json
+++ b/config.json
@@ -50,7 +50,7 @@
]
},
{
- "slug":"resistor-color-duo",
+ "slug": "resistor-color-duo",
"uuid": "0ae1989d-df46-414d-ad1f-4bd0f0f78421",
"core": false,
"unlocked_by": "two-fer",
@@ -61,6 +61,18 @@
"enumerations"
]
},
+ {
+ "slug": "resistor-color-trio",
+ "uuid": "080f18d8-fb29-44f5-882f-65e772cb5324",
+ "core": false,
+ "unlocked_by": "two-fer",
+ "difficulty": 3,
+ "topics": [
+ "arrays",
+ "strings",
+ "enumerations"
+ ]
+ },
{
"slug": "darts",
"uuid": "4d400a44-b190-4a0c-affb-99fad8ea18da",
diff --git a/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
new file mode 100644
index 000000000..189fba356
--- /dev/null
+++ b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
@@ -0,0 +1,9 @@
+class ResistorColorTrio {
+ private enum Color {
+ black, brown, red, orange, yellow, green, blue, violet, grey, white;
+ };
+
+ int value(String[] colors) {
+ return 10 * Color.valueOf(colors[0]).ordinal() + Color.valueOf(colors[1]).ordinal();
+ }
+}
diff --git a/exercises/resistor-color-trio/.meta/version b/exercises/resistor-color-trio/.meta/version
new file mode 100644
index 000000000..3eefcb9dd
--- /dev/null
+++ b/exercises/resistor-color-trio/.meta/version
@@ -0,0 +1 @@
+1.0.0
diff --git a/exercises/resistor-color-trio/README.md b/exercises/resistor-color-trio/README.md
new file mode 100644
index 000000000..4109b80e7
--- /dev/null
+++ b/exercises/resistor-color-trio/README.md
@@ -0,0 +1,76 @@
+# Resistor Color Trio
+
+If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know only three things about them:
+
+- Each resistor has a resistance value.
+- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
+ To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values.
+- Each band acts as a digit of a number. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.
+ In this exercise, you are going to create a helpful program so that you don't have to remember the values of the bands. The program will take 3 colors as input, and outputs the correct value, in ohms.
+ The color bands are encoded as follows:
+
+* Black: 0
+* Brown: 1
+* Red: 2
+* Orange: 3
+* Yellow: 4
+* Green: 5
+* Blue: 6
+* Violet: 7
+* Grey: 8
+* White: 9
+
+In `resistor-color duo` you decoded the first two colors. For instance: orange-orange got the main value `33`.
+The third color stands for how many zeros need to be added to the main value. The main value plus the zeros gives us a value in ohms.
+For the exercise it doesn't matter what ohms really are.
+For example:
+
+- orange-orange-black would be 33 and no zeros, which becomes 33 ohms.
+- orange-orange-red would be 33 and 2 zeros, which becomes 3300 ohms.
+- orange-orange-orange would be 33 and 3 zeros, which becomes 33000 ohms.
+
+(If Math is your thing, you may want to think of the zeros as exponents of 10. If Math is not your thing, go with the zeros. It really is the same thing, just in plain English instead of Math lingo.)
+
+This exercise is about translating the colors into a label:
+
+> "... ohms"
+
+So an input of `"orange", "orange", "black"` should return:
+
+> "33 ohms"
+
+When we get more than a thousand ohms, we say "kiloohms". That's similar to saying "kilometer" for 1000 meters, and "kilograms" for 1000 grams.
+So an input of `"orange", "orange", "orange"` should return:
+
+> "33 kiloohms"
+
+## Setup
+
+Go through the setup instructions for Java to install the necessary
+dependencies:
+
+[https://exercism.io/tracks/java/installation](https://exercism.io/tracks/java/installation)
+
+# Running the tests
+
+You can run all the tests for an exercise by entering the following in your
+terminal:
+
+```sh
+$ gradle test
+```
+
+> Use `gradlew.bat` if you're on Windows
+
+In the test suites all tests but the first have been skipped.
+
+Once you get a test passing, you can enable the next one by removing the
+`@Ignore("Remove to run test")` annotation.
+
+## Source
+
+Maud de Vries, Erik Schierboom [https://github.com/exercism/problem-specifications/issues/1549](https://github.com/exercism/problem-specifications/issues/1549)
+
+## Submitting Incomplete Solutions
+It's possible to submit an incomplete solution so you can see how others have
+completed the exercise.
diff --git a/exercises/resistor-color-trio/build.gradle b/exercises/resistor-color-trio/build.gradle
new file mode 100644
index 000000000..019e5f323
--- /dev/null
+++ b/exercises/resistor-color-trio/build.gradle
@@ -0,0 +1,18 @@
+apply plugin: "java"
+apply plugin: "eclipse"
+apply plugin: "idea"
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testCompile "junit:junit:4.12"
+}
+
+test {
+ testLogging {
+ exceptionFormat = 'full'
+ events = ["passed", "failed", "skipped"]
+ }
+}
diff --git a/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java b/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
new file mode 100644
index 000000000..319887c11
--- /dev/null
+++ b/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
@@ -0,0 +1,5 @@
+class ResistorColorTrio {
+ int value(String[] colors) {
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
+ }
+}
diff --git a/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
new file mode 100644
index 000000000..6da66890a
--- /dev/null
+++ b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
@@ -0,0 +1,8 @@
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+
+import static org.junit.Assert.assertEquals;
+
+public class ResistorColorTrioTest {
+}
diff --git a/exercises/settings.gradle b/exercises/settings.gradle
index f32fb42aa..b73051177 100644
--- a/exercises/settings.gradle
+++ b/exercises/settings.gradle
@@ -76,6 +76,7 @@ include 'rational-numbers'
include 'rectangles'
include 'resistor-color'
include 'resistor-color-duo'
+include 'resistor-color-trio'
include 'reverse-string'
include 'rna-transcription'
include 'robot-name'
From 8b0e4614e7bdf70dd34ad4584cd9fa623e6258aa Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Sat, 12 Oct 2019 14:38:12 +0200
Subject: [PATCH 6/8] Add Test
---
config.json | 6 +-
.../src/reference/java/ResistorColorTrio.java | 12 +++-
.../src/main/java/ResistorColorTrio.java | 2 +-
.../src/test/java/ResistorColorTrioTest.java | 55 +++++++++++++++++++
4 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/config.json b/config.json
index ee6341385..0bfbb291b 100644
--- a/config.json
+++ b/config.json
@@ -54,7 +54,7 @@
"uuid": "0ae1989d-df46-414d-ad1f-4bd0f0f78421",
"core": false,
"unlocked_by": "two-fer",
- "difficulty": 3,
+ "difficulty": 2,
"topics": [
"arrays",
"strings",
@@ -70,7 +70,9 @@
"topics": [
"arrays",
"strings",
- "enumerations"
+ "enumerations",
+ "math",
+ "conditionals"
]
},
{
diff --git a/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
index 189fba356..0333765e5 100644
--- a/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
+++ b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
@@ -3,7 +3,15 @@ private enum Color {
black, brown, red, orange, yellow, green, blue, violet, grey, white;
};
- int value(String[] colors) {
- return 10 * Color.valueOf(colors[0]).ordinal() + Color.valueOf(colors[1]).ordinal();
+ String value(String[] colors) {
+ int intValue = (10 * Color.valueOf(colors[0]).ordinal() + Color.valueOf(colors[1]).ordinal())
+ * (int) Math.pow(10, Color.valueOf(colors[2]).ordinal());
+ String stringValue;
+ if (intValue >= 1000) {
+ stringValue = String.valueOf(intValue / 1000) + " kiloohms";
+ } else {
+ stringValue = String.valueOf(intValue) + " ohms";
+ }
+ return stringValue;
}
}
diff --git a/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java b/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
index 319887c11..3331db205 100644
--- a/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
+++ b/exercises/resistor-color-trio/src/main/java/ResistorColorTrio.java
@@ -1,5 +1,5 @@
class ResistorColorTrio {
- int value(String[] colors) {
+ String value(String[] colors) {
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
}
}
diff --git a/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
index 6da66890a..a94187029 100644
--- a/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
+++ b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
@@ -5,4 +5,59 @@
import static org.junit.Assert.assertEquals;
public class ResistorColorTrioTest {
+ private ResistorColorTrio resistorColorTrio;
+
+ @Before
+ public void setup() {
+ resistorColorTrio = new ResistorColorTrio();
+ }
+
+ @Test
+ public void testOrangeOrangeBlack() {
+ String[] input = { "orange", "orange", "black" };
+ String expected = "33 ohms";
+ String actual = resistorColorTrio.value(input);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ @Ignore("Remove to run test")
+ public void testBluegreyBrown() {
+ String[] input = { "blue", "grey", "brown" };
+ String expected = "680 ohms";
+ String actual = resistorColorTrio.value(input);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ @Ignore("Remove to run test")
+ public void testRedBlackRed() {
+ String[] input = { "red", "black", "red" };
+ String expected = "2 kiloohms";
+ String actual = resistorColorTrio.value(input);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ @Ignore("Remove to run test")
+ public void testGreenBrownOrange() {
+ String[] input = { "green", "brown", "orange" };
+ String expected = "51 kiloohms";
+ String actual = resistorColorTrio.value(input);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ @Ignore("Remove to run test")
+ public void testYellowVioletYellow() {
+ String[] input = { "yellow", "violet", "yellow" };
+ String expected = "470 kiloohms";
+ String actual = resistorColorTrio.value(input);
+
+ assertEquals(expected, actual);
+ }
}
From b0ea2cef298e581ed26d53afe69a5b381c8209db Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Sun, 22 Dec 2019 14:27:37 +0100
Subject: [PATCH 7/8] Update Build exception format
---
exercises/resistor-color-trio/build.gradle | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/exercises/resistor-color-trio/build.gradle b/exercises/resistor-color-trio/build.gradle
index 019e5f323..82d705dfd 100644
--- a/exercises/resistor-color-trio/build.gradle
+++ b/exercises/resistor-color-trio/build.gradle
@@ -12,7 +12,8 @@ dependencies {
test {
testLogging {
- exceptionFormat = 'full'
+ exceptionFormat = 'short'
+ showStandardStreams = true
events = ["passed", "failed", "skipped"]
}
}
From 417065cb75f56afc7317092c2dd330a6db63edda Mon Sep 17 00:00:00 2001
From: Paul Adriaanse
Date: Mon, 27 Apr 2020 18:07:15 +0200
Subject: [PATCH 8/8] Resolve some suggestions
- upper snake case for enum
- typo & simplification in test
---
.../.meta/src/reference/java/ResistorColorTrio.java | 2 +-
.../src/test/java/ResistorColorTrioTest.java | 9 ++-------
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
index 0333765e5..af72c2e85 100644
--- a/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
+++ b/exercises/resistor-color-trio/.meta/src/reference/java/ResistorColorTrio.java
@@ -1,6 +1,6 @@
class ResistorColorTrio {
private enum Color {
- black, brown, red, orange, yellow, green, blue, violet, grey, white;
+ BLACK, BROWN, RED, ORANGE, YELLOW, GREEN, BLUE, VIOLET, GREY, WHITE;
};
String value(String[] colors) {
diff --git a/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
index a94187029..68ab63d4f 100644
--- a/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
+++ b/exercises/resistor-color-trio/src/test/java/ResistorColorTrioTest.java
@@ -5,12 +5,7 @@
import static org.junit.Assert.assertEquals;
public class ResistorColorTrioTest {
- private ResistorColorTrio resistorColorTrio;
-
- @Before
- public void setup() {
- resistorColorTrio = new ResistorColorTrio();
- }
+ private ResistorColorTrio resistorColorTrio = new ResistorColorTrio();
@Test
public void testOrangeOrangeBlack() {
@@ -23,7 +18,7 @@ public void testOrangeOrangeBlack() {
@Test
@Ignore("Remove to run test")
- public void testBluegreyBrown() {
+ public void testBlueGreyBrown() {
String[] input = { "blue", "grey", "brown" };
String expected = "680 ohms";
String actual = resistorColorTrio.value(input);