From fc957e1e954425981154ce4685d302ca5ff89bce Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Fri, 30 Jun 2023 09:33:43 +0200 Subject: [PATCH] Javadoc enhancements, minor code upgrade (ordering) --- .../mi/sd1/task2/QuadratPolynom.java | 166 ----------- .../mi/sd1/task2/SquarePolynom.java | 192 ++++++++++++ .../mi/sd1/ShowReachedPoints.java | 4 +- .../mi/sd1/task2/Test_SquarePolynom.java} | 32 +- .../mi/sd1/task2/QuadratPolynom.java | 282 ------------------ .../mi/sd1/task2/SquarePolynom.java | 256 ++++++++++++++++ .../mi/sd1/ShowReachedPoints.java | 4 +- .../mi/sd1/task2/TestSquarePolynom.java} | 32 +- 8 files changed, 484 insertions(+), 484 deletions(-) delete mode 100644 Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java create mode 100644 Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java rename Klausuren/Sd1/2021winter/{Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestQuadratPolynom.java => Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_SquarePolynom.java} (84%) delete mode 100644 Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java create mode 100644 Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java rename Klausuren/Sd1/2021winter/{Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_QuadratPolynom.java => Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestSquarePolynom.java} (84%) diff --git a/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java b/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java deleted file mode 100644 index e00c9e875..000000000 --- a/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java +++ /dev/null @@ -1,166 +0,0 @@ -package de.hdm_stuttgart.mi.sd1.task2; - -/** - * <p>Providing zeroes (German: "Nullstellen") of quadratic polynomials.</p> - * - * <p>A quadratic polynomial \( p(x) = a x² + b x + c \) is being defined by its three coefficients - * \(a\), \(b\) and \(c\). This class limits coefficients \(a\), \(b\) and \(c\) to type <code>int</code>. For - * \(a \neq 0\) zeroes are being calculated by:</p> - * - * <p>\[ x_{1,2} = {{-b \pm \sqrt{b^2 - 4 ac}} \over {2a}} \]</p> - * - * <p>For \( a \neq 0 \) depending on \( b^2 - 4 ac \) being positive, zero or negative we have either two, one or no - * real solutions.</p> - * - * <p>The following samples illustrates calculation of zeroes depending on given values of \(a\), \(b\) and \(c\):</p> - * - * <table class="goikTableDefaults"> - * <caption>Sample code illustrating zero values calculation</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="language-java"> final QuadratPolynom poly = // Representing - * new QuadratPolynom(4, -3, -10); // p(x) = 4x² - 3x - 10 - * - * double[] zeroes = poly.getZeroes(); - * - * System.out.println("Found " + zeroes.length + " zeroes:"); - * - * System.out.println("x_1 = " + zeroes[0]); - * System.out.println("x_2 = " + zeroes[1]);</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> Found 2 zeroes: - * x_1 = -1.25 - * x_2 = 2.0</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>Note the two zeroes <code>x_1</code> and <code>x_2</code> being ordered by value.</p> - * - * <p>We allow for re-setting a polynomial's coefficients. Continuing from the above example we have:</p> - * - * <table class="goikTableDefaults"> - * <caption>Changing coefficients</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(1); // Representing - * poly.setB(-8); // p(x) = x² -8x + 16 - * poly.setC(16); - * - * zeroes = poly.getZeroes(); - * System.out.println("Found " + zeroes.length + " zero:"); - * - * System.out.println("x_1 = " + zeroes[0]);</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Found 1 zero: - * x_1 = 4.0</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>Some polynomials do not have any (real valued) solution:</p> - * - * <table class="goikTableDefaults"> - * <caption>Changing coefficients again</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(1); // Representing - * poly.setB(0); // p(x) = x² + 1 - * poly.setC(1); // (No real valued zero) - * - * zeroes = poly.getZeroes(); - * System.out.println("Found " + zeroes.length + " zero");</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Found 0 zero</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>\(a=0\) in \(ax²\) leaves us with just a linear polynomial \(bx + c\) resulting in different cases:</p> - * - * <dl> - * <dt>\(b \neq 0 \)</dt> - * <dd>Exactly one zero</dd> - * - * <dt>\(b = 0 \) and \(c \neq 0\)</dt> - * <dd>No zero at all</dd> - * - * <dt>\(b = 0\) and \(c = 0\)</dt> - * <dd> - * <p>An infinite number of zeroes. Since this cannot be represented by a finite array we throw an - * <a href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/ArithmeticException.html" - * ><code>ArithmeticException</code></a></p> - * - * <table class="goikTableDefaults"> - * <caption>Dealing with 0 value at square coefficient.</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(0); - * poly.setB(0); - * poly.setC(0); - * zeroes = poly.getZeroes();</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Exception in thread "main" java.lang.ArithmeticException: - * Polynomial is identical to zero function</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * </dd> - * - * </dl> - * - * <section class="implementationHints"> - * <h2 class="implementationHints">Hints:</h2> - * - * <ul> - * - * <li>This class is yet unimplemented. The above code snippets provide a clue to an implementation - * satisfying the corresponding unit tests.</li> - * - * <li><a href= - * "https://freedocs.mi.hdm-stuttgart.de/lib/openjdk-17-doc/api/java.base/java/lang/Math.html#sqrt(double)" - * >Math.sqrt(...)</a> - * </li> - * - * </ul> - * - * </section> - * - */ -public class QuadratPolynom { - // Implement me -} diff --git a/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java b/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java new file mode 100644 index 000000000..07a7379d9 --- /dev/null +++ b/Klausuren/Sd1/2021winter/Exam/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java @@ -0,0 +1,192 @@ +package de.hdm_stuttgart.mi.sd1.task2; + +/** + * <p>Representing square polynomials having coefficients of type <code>int</code>.</p> + * + * <p>A square polynomial \( p(x) = a x² + b x + c \) is being defined by its three coefficients + * \(a\), \(b\) and \(c\). We assume all three to be of type <code>int</code>.</p> + * + * + * <h2>Providing zeroes (German: "Nullstellen") of square polynomials, + * case \( \mathbf{a \neq 0}\), true square polynomial</h2> + * + * <p>Zeroes are being calculated using:</p> + * + * <p>\[ x_{1,2} = {{-b \pm \sqrt{b^2 - 4 ac}} \over {2a}} \]</p> + * + * <p>There are thus three cases:</p> + * + * <dl> + * <dt>\(\mathbf{ 0 < b^2 - 4 ac}\):</dt> + * <dd> + * <p>Two zeroes \(x_1\) and \(x_2\) according to above formular:</p> + * + * <table class="goikTableDefaults"> + * <caption>Sample code illustrating zero values calculation</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="language-java"> final SquarePolynom poly = // Representing + * new SquarePolynom(4, -3, -10); // p(x) = 4x² - 3x - 10 + * + * double[] zeroes = poly.getZeroes(); + * + * System.out.println("Found " + zeroes.length + " zeroes:"); + * + * System.out.println("x_1 = " + zeroes[0]); + * System.out.println("x_2 = " + zeroes[1]);</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> Found 2 zeroes: + * x_1 = -1.25 + * x_2 = 2.0</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * + * <p>Note the two values in the <code>double[] zeroes</code> array being ordered by value.</p> + * </dd> + * + * <dt>\(\mathbf{ 0 = b^2 - 4 ac}\):</dt> + * + * <dd> + * <p>One zero \(x = {-b\over 2a}\).</p> + * + * <p>We allow for changing a polynomial's coefficients. Continuing from the above example we have:</p> + * + * <table class="goikTableDefaults"> + * <caption>Changing coefficients</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(1); // Representing + * poly.setB(-8); // p(x) = x² -8x + 16 + * poly.setC(16); + * + * zeroes = poly.getZeroes(); + * System.out.println("Found " + zeroes.length + " zero:"); + * + * System.out.println("x_1 = " + zeroes[0]);</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Found 1 zero: + * x_1 = 4.0</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * <p> </p> + * </dd> + * + * <dt>\(\mathbf{ b^2 - 4 ac < 0 }\):</dt> + * + * <dd> + * <p>Square root of negative thus no real valued solution:</p> + * + * <table class="goikTableDefaults"> + * <caption>Changing coefficients again</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(1); // Representing + * poly.setB(0); // p(x) = x² + 1 + * poly.setC(1); // (No real valued zero) + * + * zeroes = poly.getZeroes(); + * System.out.println("Found " + zeroes.length + " zero");</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Found 0 zero</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * </dd> + * </dl> + * + * <h2>Case \( \mathbf{a = 0}\), linear polynomial</h2> + * + * <p>This leaves us with just a linear polynomial \(bx + c\) also resulting in three different cases:</p> + * + * + * <dl> + * <dt>\( \mathbf{b \neq 0} :\)</dt> + * + * <dd> + * <p>Exactly one zero</p> + * </dd> + * + * <dt>\( \mathbf{b = 0 \ \text{and} \ c \neq 0 :}\)</dt> + * <dd> + * <p>No zero at all</p> + * </dd> + * + * <dt>\(\mathbf{b = 0 \ \text{and} \ c = 0} \):</dt> + * <dd> + * <p>An infinite number of zeroes. Since this cannot be represented by a finite <code>double[]</code> array + * an {@link ArithmeticException} is being thrown like in the subsequent code sample:</p> + * + * <table class="goikTableDefaults"> + * <caption>Dealing with \( \mathbf{a = b = c = 0} \)</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(0); + * poly.setB(0); + * poly.setC(0); + * zeroes = poly.getZeroes();</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Exception in thread "main" java.lang.ArithmeticException: + * <b style="color:red;">Polynomial is identical to zero function</b></code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * + * </dd> + * </dl> + * + * <section class="implementationHints"> + * <h2 class="implementationHints">Hints:</h2> + * + * <ul> + * + * <li>This class is yet unimplemented. The above code snippets provide a clue to an implementation + * satisfying the corresponding unit tests.</li> + * + * <li><a href= + * "https://freedocs.mi.hdm-stuttgart.de/lib/openjdk-17-doc/api/java.base/java/lang/Math.html#sqrt(double)" + * >Math.sqrt(...)</a> + * </li> + * + * </ul> + * + * </section> + */ +public class SquarePolynom { + // Implement me +} diff --git a/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java b/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java index ae8720eb0..b86901bc1 100644 --- a/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java +++ b/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java @@ -3,7 +3,7 @@ package de.hdm_stuttgart.mi.sd1; import de.hdm_stuttgart.mi.exam.unitmarking.RunTests; import de.hdm_stuttgart.mi.sd1.task1.*; -import de.hdm_stuttgart.mi.sd1.task2.Test_QuadratPolynom; +import de.hdm_stuttgart.mi.sd1.task2.Test_SquarePolynom; public class ShowReachedPoints { @@ -17,6 +17,6 @@ public class ShowReachedPoints { "Task 1" , A_TrafficLightTest.class, B_StringHelperTest.class, C_ArrayHelperTest.class, D_TextFrameTest.class ); - RunTests.exec("Task 2", Test_QuadratPolynom.class); + RunTests.exec("Task 2", Test_SquarePolynom.class); } } \ No newline at end of file diff --git a/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestQuadratPolynom.java b/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_SquarePolynom.java similarity index 84% rename from Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestQuadratPolynom.java rename to Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_SquarePolynom.java index 4fbd48f88..3bdea6d97 100644 --- a/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestQuadratPolynom.java +++ b/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_SquarePolynom.java @@ -9,15 +9,15 @@ import org.junit.Test; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestQuadratPolynom extends ExaminationTestDefaults { +public class Test_SquarePolynom extends ExaminationTestDefaults { @Test @Marking(points = 5) public void test_100_NoZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 1, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 1, 1); assertNoZero(poly, composeDescription(1,2,1).toString()); - final ObjectWrapper<QuadratPolynom> poly2 = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 3); + final ObjectWrapper<SquarePolynom> poly2 = new ObjectWrapper<>(SquarePolynom.class,1, 2, 3); assertNoZero(1, 6, 20, poly2); assertNoZero(2, 13, 41, poly2); } @@ -25,24 +25,24 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 1) public void test_200_OneZeroLinearOneZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 1, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 1, 1); assertOneZero(poly, -1, composeDescription(0,1,1).toString()); } @Test @Marking(points = 1) public void test_200_OneZeroLinearNoZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 0, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 0, 1); assertNoZero(poly, composeDescription(0,0,1).toString()); } @Test @Marking(points = 3) public void test_210_OneZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 2, 1); assertOneZero(poly, -1, composeDescription(1,2,1).toString()); - final ObjectWrapper<QuadratPolynom> poly2 = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 3); + final ObjectWrapper<SquarePolynom> poly2 = new ObjectWrapper<>(SquarePolynom.class,1, 2, 3); assertOneZero(6, -84, 294, poly2, 7); assertOneZero(21, 126, 189, poly2, -3); } @@ -51,7 +51,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { @Marking(points = 5) public void test_300_twoZeroes() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 3, 2); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 3, 2); assertTwoZeroes(poly, -2, -1, "x² + 3x + 2"); assertTwoZeroes(3, 7, 4, poly, -4./3, -1); @@ -71,7 +71,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 2) public void test_400_Exception() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 0, 0); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 0, 0); final Class<ArithmeticException> expectedArithmeticException = ArithmeticException.class; @@ -82,7 +82,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 3) public void test_500_TwoZeroExzess() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class, + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class, 46010, 598130,-1960026000); assertTwoZeroes(poly,-213,200, composeDescription(46010, 598130,-1960026000).toString()); @@ -116,7 +116,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { * @param poly Polynomial to be tested * @param description E.g. "-2x² + 4x -3" */ - static private void assertNoZero(final ObjectWrapper<QuadratPolynom> poly, final String description) { + static private void assertNoZero(final ObjectWrapper<SquarePolynom> poly, final String description) { Assert.assertEquals("No zero expected for polynom »" + description + "«", 0, poly.invoke(double[].class, "getZeroes").length); @@ -133,7 +133,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { static private void assertNoZero(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly) { + final ObjectWrapper<SquarePolynom> poly) { poly.invoke(void.class, "setA", a); poly.invoke(void.class, "setB", b); poly.invoke(void.class, "setC", c); @@ -150,7 +150,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { * @param expected zero value * @param description E.g. "-2x² + 4x -3" */ - static private void assertOneZero(final ObjectWrapper<QuadratPolynom> poly, + static private void assertOneZero(final ObjectWrapper<SquarePolynom> poly, double expected, final String description) { final double[] result = poly.invoke(double[].class, "getZeroes"); @@ -170,7 +170,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { static private void assertOneZero(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly, + final ObjectWrapper<SquarePolynom> poly, double expected) { poly.invoke(void.class, "setA", a); poly.invoke(void.class, "setB", b); @@ -193,7 +193,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { * @param expectedUpper Upper zero value * @param description E.g. "-2x² + 4x -3" */ - static private void assertTwoZeroes(final ObjectWrapper<QuadratPolynom> poly, + static private void assertTwoZeroes(final ObjectWrapper<SquarePolynom> poly, double expectedLower, double expectedUpper, final String description) { @@ -219,7 +219,7 @@ public class TestQuadratPolynom extends ExaminationTestDefaults { static private void assertTwoZeroes(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly, + final ObjectWrapper<SquarePolynom> poly, double expectedLower, double expectedUpper) { poly.invoke(void.class, "setA", a); diff --git a/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java b/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java deleted file mode 100644 index 78f5284e3..000000000 --- a/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/QuadratPolynom.java +++ /dev/null @@ -1,282 +0,0 @@ -package de.hdm_stuttgart.mi.sd1.task2; - -/** - * <p>Providing zeroes (German: "Nullstellen") of quadratic and linear polynomials.</p> - * - * <p>A quadratic polynomial \( p(x) = a x² + b x + c \) is being defined by its three coefficients - * \(a\), \(b\) and \(c\). This class limits coefficients \(a\), \(b\) and \(c\) to type <code>int</code>. For - * \(a \neq 0\) zeroes are being calculated by:</p> - * - * <p>\[ x_{1,2} = {{-b \pm \sqrt{b^2 - 4 ac}} \over {2a}} \]</p> - * - * <p>Depending on \( b^2 - 4 ac \) being positive, zero or negative we have either two, one or no real solutions.</p> - * - * <p>The following sample illustrates zeroes calculation depending on given values of \(a\), \(b\) and \(c\):</p> - * - * <table class="goikTableDefaults"> - * <caption>Sample code illustrating zero values calculation</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="language-java"> final QuadratPolynom poly = // Representing - * new QuadratPolynom(4, -3, -10); // p(x) = 4x² - 3x - 10 - * - * double[] zeroes = poly.getZeroes(); - * - * System.out.println("Found " + zeroes.length + " zeroes:"); - * - * System.out.println("x_1 = " + zeroes[0]); - * System.out.println("x_2 = " + zeroes[1]);</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> Found 2 zeroes: - * x_1 = -1.25 - * x_2 = 2.0</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>Note the two zeroes <code>x_1</code> and <code>x_2</code> being ordered by value.</p> - * - * <p>We allow for re-setting a polynomial's coefficients. Continuing from the above example we have:</p> - * - * <table class="goikTableDefaults"> - * <caption>Changing coefficients</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(1); // Representing - * poly.setB(-8); // p(x) = x² -8x + 16 - * poly.setC(16); - * - * zeroes = poly.getZeroes(); - * System.out.println("Found " + zeroes.length + " zero:"); - * - * System.out.println("x_1 = " + zeroes[0]);</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Found 1 zero: - * x_1 = 4.0</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>Some polynomials do not have any (real valued) solution:</p> - * - * <table class="goikTableDefaults"> - * <caption>Changing coefficients again</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(1); // Representing - * poly.setB(0); // p(x) = x² + 1 - * poly.setC(1); // (No real valued zero) - * - * zeroes = poly.getZeroes(); - * System.out.println("Found " + zeroes.length + " zero");</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Found 0 zero</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * - * <p>\(a=0\) in \(ax²\) leaves us with just a linear polynomial \(bx + c\) resulting in different cases:</p> - * - * <dl> - * <dt>\(b \neq 0 \)</dt> - * <dd>Exactly one zero</dd> - * - * <dt>\(b = 0 \) and \(c \neq 0\)</dt> - * <dd>No zero at all</dd> - * - * <dt>\(b = 0\) and \(c = 0\)</dt> - * <dd> - * <p>An infinite number of zeroes. Since this cannot be represented by a finite array we throw an - * <a href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/ArithmeticException.html" - * ><code>ArithmeticException</code></a></p> - * - * <table class="goikTableDefaults"> - * <caption>Dealing with 0 value at square coefficient.</caption> - * <tbody> - * <tr> - * <th>Code</th> - * <th>Result</th> - * </tr> - * <tr> - * <td> - * <pre><code class="java"> ... - * poly.setA(0); - * poly.setB(0); - * poly.setC(0); - * zeroes = poly.getZeroes();</code></pre> - * </td> - * <td> - * <pre><code class="nohighlight"> ... - * Exception in thread "main" java.lang.ArithmeticException: - * Polynomial is identical to zero function</code></pre> - * </td> - * </tr> - * </tbody> - * </table> - * </dd> - * - * </dl> - * - * <section class="implementationHints"> - * <h2 class="implementationHints">Hint:</h2> - * - * <ul> - * - * <li>This class is yet unimplemented. The above code snippets provide a clue to an implementation - * satisfying the corresponding unit tests.</li> - * - * <li><a href= - * "https://freedocs.mi.hdm-stuttgart.de/lib/openjdk-17-doc/api/java.base/java/lang/Math.html#sqrt(double)" - * >Math.sqrt(...)</a> - * </li> - * - * </ul> - * - * </section> - * - */ -public class QuadratPolynom { - private int a, b, c; - - /** - * <p>Defining a polynomial \( p(x) = a x² + b x + c \).</p> - * - * @param a Square coefficient. - * @param b Linear coefficient. - * @param c Constant coefficient. - * @throws ArithmeticException The square coefficient \( a x² \) must not be zero - */ - public QuadratPolynom(int a, int b, int c) throws ArithmeticException { - setA(a); - setB(b); - setC(c); - } - - /** - * <p>Re- setting the square coefficient in \( a x² \).</p> - * @param a The desired new value. - */ - public void setA(final int a) { - this.a = a; - } - /** - * <p>Re- setting the linear coefficient in \( b x \).</p> - * @param b The desired new value. - */ - public void setB(final int b) { - this.b = b; - } - /** - * <p>Re- setting the constant coefficient \( c \).</p> - * @param c The desired new value. - */ - public void setC(final int c) { - this.c = c; - } - - /** - * <p>Zeroes are all values of \(x\) solving \(a x² + b x + c = 0\).</p> - * - * <p>We observe different categories:</p> - * - * <dl> - * - * <dt>\( a = 0\):</dt> - * <dd> - * <dl> - * <dt>\( b = 0\):</dt> - * <dd> - * <dl> - * <dt>\( c = 0 \)</dt> - * <dd>Infinite number of zeroes \mathbb{R}, an {@link ArithmeticException} will be thrown</dd> - * - * <dt>\( c \neq 0 \)</dt> - * <dd>Empty set, no zero at all.</dd> - * </dl> - * - * </dd> - * - * <dt>\( b \neq 0\):</dt> - * <dd>Zero at \(-{c\over b}\)</dd> - * - * </dl> - * - * </dd> - * - * <dt>\( a \neq 0\):</dt> - * <dd> - * <dl> - * <dt>\( b² - 4 a c < 0\):</dt> - * <dd><p>Empty array <code>double[0]</code> indicating the non-existence of any real zero.</p></dd> - * - * <dt>\( b² - 4 a c = 0\):</dt> - * <dd><p>An <code>double[1]</code> array containing the single zero {\(-b \over {2 a} \)}.</p></dd> - * - * <dt>\( b² - 4 a c > 0\):</dt> - * <dd><p>An array <code>double[2]</code> containing two distinct zeroes - * \(-b + \sqrt {b² - 4 a c} \over {2 a} \) - * and \(-b - \sqrt {b² - 4 a c} \over {2 a} \) ordered by size.</p></dd> - * </dl> - * </dd> - * </dl> - * - * @return The finite set of zeroes. In case of an infinite number of zeroes an arithmetic exception is being thrown. - * - * @throws ArithmeticException In case of \(a = b = c = 0 \) an infinite number of zeroes exists which cannot be - * represented by a finite array of double values. - */ - public double[] getZeroes() throws ArithmeticException { - - if (0 != a) { // square polynomial - final long radicand = ((long) b) * b - 4L * a * c; // Avoiding overflow errors - // final int radicand = b * b - 4 * a * c; // failing for higher values due to overflow - - if (0 > radicand) { // No zero (at least no real numbered one) - return new double[]{}; - } else if (0 == radicand) { - return new double[]{-b / 2. / a}; // Exactly one zero - } else { // Two zeroes - final double radicandRoot = Math.sqrt(radicand); - - if (0 < a) { // Ordering of zeroes by size - return new double[]{(-b - radicandRoot) / 2 / a, (-b + radicandRoot) / 2 / a}; - } else { - return new double[]{(-b + radicandRoot) / 2 / a, (-b - radicandRoot) / 2 / a}; - } - } - } else{ // 0 == a, linear polynomial - if (b != 0) { - return new double[]{c * (-1.) / b}; // - } else if (c != 0) { - return new double[]{}; // No zero exists - } else { - throw new ArithmeticException("Polynomial is identical to zero function"); - } - } - } -} diff --git a/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java b/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java new file mode 100644 index 000000000..ec0c8b829 --- /dev/null +++ b/Klausuren/Sd1/2021winter/Solve/src/main/java/de/hdm_stuttgart/mi/sd1/task2/SquarePolynom.java @@ -0,0 +1,256 @@ +package de.hdm_stuttgart.mi.sd1.task2; + +/** + * <p>Representing square polynomials having coefficients of type <code>int</code>.</p> + * + * <p>A square polynomial \( p(x) = a x² + b x + c \) is being defined by its three coefficients + * \(a\), \(b\) and \(c\). We assume all three to be of type <code>int</code>.</p> + * + */ +public class SquarePolynom { + private int a, b, c; + + /** + * <p>Defining a polynomial \( p(x) = a x² + b x + c \).</p> + * + * @param a Square coefficient. + * @param b Linear coefficient. + * @param c Constant coefficient. + */ + public SquarePolynom(int a, int b, int c) { + setA(a); + setB(b); + setC(c); + } + + /** + * <p>Re- setting the square coefficient in \( a x² \).</p> + * + * @param a The desired new value. + */ + public void setA(final int a) { + this.a = a; + } + + /** + * <p>Re- setting the linear coefficient in \( b x \).</p> + * + * @param b The desired new value. + */ + public void setB(final int b) { + this.b = b; + } + + /** + * <p>Re- setting the constant coefficient \( c \).</p> + * + * @param c The desired new value. + */ + public void setC(final int c) { + this.c = c; + } + + /** + * <p>Providing zeroes (German: "Nullstellen") of the given square polynomial.</p> + * + * <p>There are two different cases \( \mathbf{a \neq 0}\) and \( \mathbf{a = 0}\):</p> + * + * <h2>Case \( \mathbf{a \neq 0}\), true square polynomial</h2> + * + * <p>Zeroes are being calculated using:</p> + * + * <p>\[ x_{1,2} = {{-b \pm \sqrt{b^2 - 4 ac}} \over {2a}} \]</p> + * + * <p>There are thus three cases:</p> + * + * <dl> + * <dt>\(\mathbf{ 0 < b^2 - 4 ac}\):</dt> + * <dd> + * <p>Two zeroes \(x_1\) and \(x_2\) according to above formular:</p> + * + * <table class="goikTableDefaults"> + * <caption>Sample code illustrating zero values calculation</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="language-java"> final SquarePolynom poly = // Representing + * new SquarePolynom(4, -3, -10); // p(x) = 4x² - 3x - 10 + * + * double[] zeroes = poly.getZeroes(); + * + * System.out.println("Found " + zeroes.length + " zeroes:"); + * + * System.out.println("x_1 = " + zeroes[0]); + * System.out.println("x_2 = " + zeroes[1]);</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> Found 2 zeroes: + * x_1 = -1.25 + * x_2 = 2.0</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * + * <p>Note the two values in the <code>double[] zeroes</code> array being ordered by value.</p> + * </dd> + * + * <dt>\(\mathbf{ 0 = b^2 - 4 ac}\):</dt> + * + * <dd> + * <p>One zero \(x = {-b\over 2a}\).</p> + * + * <p>We allow for changing a polynomial's coefficients. Continuing from the above example we have:</p> + * + * <table class="goikTableDefaults"> + * <caption>Changing coefficients</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(1); // Representing + * poly.setB(-8); // p(x) = x² -8x + 16 + * poly.setC(16); + * + * zeroes = poly.getZeroes(); + * System.out.println("Found " + zeroes.length + " zero:"); + * + * System.out.println("x_1 = " + zeroes[0]);</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Found 1 zero: + * x_1 = 4.0</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * <p> </p> + * </dd> + * + * <dt>\(\mathbf{ b^2 - 4 ac < 0 }\):</dt> + * + * <dd> + * <p>Square root of negative thus no real valued solution:</p> + * + * <table class="goikTableDefaults"> + * <caption>Changing coefficients again</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(1); // Representing + * poly.setB(0); // p(x) = x² + 1 + * poly.setC(1); // (No real valued zero) + * + * zeroes = poly.getZeroes(); + * System.out.println("Found " + zeroes.length + " zero");</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Found 0 zero</code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * </dd> + * </dl> + * + * <h2>Case \( \mathbf{a = 0}\), linear polynomial</h2> + * + * <p>This leaves us with just a linear polynomial \(bx + c\) also resulting in three different cases:</p> + * + * + * <dl> + * <dt>\( \mathbf{b \neq 0} :\)</dt> + * + * <dd> + * <p>Exactly one zero</p> + * </dd> + * + * <dt>\( \mathbf{b = 0 \ \text{and} \ c \neq 0 :}\)</dt> + * <dd> + * <p>No zero at all</p> + * </dd> + * + * <dt>\(\mathbf{b = 0 \ \text{and} \ c = 0} \):</dt> + * <dd> + * <p>An infinite number of zeroes. Since this cannot be represented by a finite <code>double[]</code> array + * an {@link ArithmeticException} is being thrown like in the subsequent code sample:</p> + * + * <table class="goikTableDefaults"> + * <caption>Dealing with \( \mathbf{a = b = c = 0} \)</caption> + * <tbody> + * <tr> + * <th>Code</th> + * <th>Result</th> + * </tr> + * <tr> + * <td> + * <pre><code class="java"> ... + * poly.setA(0); + * poly.setB(0); + * poly.setC(0); + * zeroes = poly.getZeroes();</code></pre> + * </td> + * <td> + * <pre><code class="nohighlight"> ... + * Exception in thread "main" java.lang.ArithmeticException: + * <b style="color:red;">Polynomial is identical to zero function</b></code></pre> + * </td> + * </tr> + * </tbody> + * </table> + * + * </dd> + * </dl> + * + * @return The finite set of zeroes. In case of an infinite number of zeroes an {@link ArithmeticException} is being + * thrown. + * @throws ArithmeticException In case of \(a = b = c = 0 \) an infinite number of zeroes exists which cannot be + * represented by a finite array of double values. + */ + public double[] getZeroes() throws ArithmeticException { + + if (0 == a) { // 0 == a, linear polynomial + if (b != 0) { + return new double[]{c * (-1.) / b}; // + } else if (c != 0) { + return new double[]{}; // No zero exists + } else { + throw new ArithmeticException("Polynomial is identical to zero function"); + } + } else { // a != 0, square polynomial + final long radicand = ((long) b) * b - 4L * a * c; // Avoiding overflow errors + // Caution! final int radicand = ... may fail due to integer overflow + + if (0 > radicand) { // No zero of real (only complex ones) + return new double[]{}; + } else if (0 == radicand) { + return new double[]{-b / 2. / a}; // Exactly one zero + } else { // Two zeroes + final double radicandRoot = Math.sqrt(radicand), + x1 = (-b - radicandRoot) / 2 / a, + x2 = (-b + radicandRoot) / 2 / a; + + if (0 < a) { // Ordering of zeroes by size + return new double[]{x1, x2}; + } else { + return new double[]{x2, x1}; + } + } + } + } +} \ No newline at end of file diff --git a/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java b/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java index b561c3a7e..e17743839 100644 --- a/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java +++ b/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/ShowReachedPoints.java @@ -3,7 +3,7 @@ package de.hdm_stuttgart.mi.sd1; import de.hdm_stuttgart.mi.exam.unitmarking.RunTests; import de.hdm_stuttgart.mi.sd1.task1.*; -import de.hdm_stuttgart.mi.sd1.task2.TestQuadratPolynom; +import de.hdm_stuttgart.mi.sd1.task2.TestSquarePolynom; public class ShowReachedPoints { @@ -17,6 +17,6 @@ public class ShowReachedPoints { "Task 1" , A_TrafficLightTest.class, B_StringHelperTest.class, C_ArrayHelperTest.class, D_TextFrameTest.class ); - RunTests.exec("Task 2", TestQuadratPolynom.class); + RunTests.exec("Task 2", TestSquarePolynom.class); } } \ No newline at end of file diff --git a/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_QuadratPolynom.java b/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestSquarePolynom.java similarity index 84% rename from Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_QuadratPolynom.java rename to Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestSquarePolynom.java index 5b209d488..5f6de7b47 100644 --- a/Klausuren/Sd1/2021winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task2/Test_QuadratPolynom.java +++ b/Klausuren/Sd1/2021winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/task2/TestSquarePolynom.java @@ -9,15 +9,15 @@ import org.junit.Test; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class Test_QuadratPolynom extends ExaminationTestDefaults { +public class TestSquarePolynom extends ExaminationTestDefaults { @Test @Marking(points = 5) public void test_100_NoZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 1, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 1, 1); assertNoZero(poly, composeDescription(1,2,1).toString()); - final ObjectWrapper<QuadratPolynom> poly2 = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 3); + final ObjectWrapper<SquarePolynom> poly2 = new ObjectWrapper<>(SquarePolynom.class,1, 2, 3); assertNoZero(1, 6, 20, poly2); assertNoZero(2, 13, 41, poly2); } @@ -25,24 +25,24 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 1) public void test_200_OneZeroLinearOneZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 1, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 1, 1); assertOneZero(poly, -1, composeDescription(0,1,1).toString()); } @Test @Marking(points = 1) public void test_200_OneZeroLinearNoZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 0, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 0, 1); assertNoZero(poly, composeDescription(0,0,1).toString()); } @Test @Marking(points = 3) public void test_210_OneZero() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 1); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 2, 1); assertOneZero(poly, -1, composeDescription(1,2,1).toString()); - final ObjectWrapper<QuadratPolynom> poly2 = new ObjectWrapper<>(QuadratPolynom.class,1, 2, 3); + final ObjectWrapper<SquarePolynom> poly2 = new ObjectWrapper<>(SquarePolynom.class,1, 2, 3); assertOneZero(6, -84, 294, poly2, 7); assertOneZero(21, 126, 189, poly2, -3); } @@ -51,7 +51,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { @Marking(points = 5) public void test_300_twoZeroes() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,1, 3, 2); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,1, 3, 2); assertTwoZeroes(poly, -2, -1, "x² + 3x + 2"); assertTwoZeroes(3, 7, 4, poly, -4./3, -1); @@ -71,7 +71,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 2) public void test_400_Exception() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class,0, 0, 0); + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class,0, 0, 0); final Class<ArithmeticException> expectedArithmeticException = ArithmeticException.class; @@ -82,7 +82,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { @Test @Marking(points = 3) public void test_500_TwoZeroExzess() { - final ObjectWrapper<QuadratPolynom> poly = new ObjectWrapper<>(QuadratPolynom.class, + final ObjectWrapper<SquarePolynom> poly = new ObjectWrapper<>(SquarePolynom.class, 46010, 598130,-1960026000); assertTwoZeroes(poly,-213,200, composeDescription(46010, 598130,-1960026000).toString()); @@ -116,7 +116,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { * @param poly Polynomial to be tested * @param description E.g. "-2x² + 4x -3" */ - static private void assertNoZero(final ObjectWrapper<QuadratPolynom> poly, final String description) { + static private void assertNoZero(final ObjectWrapper<SquarePolynom> poly, final String description) { Assert.assertEquals("No zero expected for polynom »" + description + "«", 0, poly.invoke(double[].class, "getZeroes").length); @@ -133,7 +133,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { static private void assertNoZero(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly) { + final ObjectWrapper<SquarePolynom> poly) { poly.invoke(void.class, "setA", a); poly.invoke(void.class, "setB", b); poly.invoke(void.class, "setC", c); @@ -150,7 +150,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { * @param expected zero value * @param description E.g. "-2x² + 4x -3" */ - static private void assertOneZero(final ObjectWrapper<QuadratPolynom> poly, + static private void assertOneZero(final ObjectWrapper<SquarePolynom> poly, double expected, final String description) { final double[] result = poly.invoke(double[].class, "getZeroes"); @@ -170,7 +170,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { static private void assertOneZero(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly, + final ObjectWrapper<SquarePolynom> poly, double expected) { poly.invoke(void.class, "setA", a); poly.invoke(void.class, "setB", b); @@ -193,7 +193,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { * @param expectedUpper Upper zero value * @param description E.g. "-2x² + 4x -3" */ - static private void assertTwoZeroes(final ObjectWrapper<QuadratPolynom> poly, + static private void assertTwoZeroes(final ObjectWrapper<SquarePolynom> poly, double expectedLower, double expectedUpper, final String description) { @@ -219,7 +219,7 @@ public class Test_QuadratPolynom extends ExaminationTestDefaults { static private void assertTwoZeroes(final int a, final int b, final int c, - final ObjectWrapper<QuadratPolynom> poly, + final ObjectWrapper<SquarePolynom> poly, double expectedLower, double expectedUpper) { poly.invoke(void.class, "setA", a); -- GitLab