Clement COLMERAUER commited on 2024-10-21 11:08:45
Showing 30 changed files, with 170 additions and 47 deletions.
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
</td> |
| 42 | 42 |
<td> |
| 43 | 43 |
<div class="infoBox" id="duration"> |
| 44 |
-<div class="counter">0.151s</div> |
|
| 44 |
+<div class="counter">0.203s</div> |
|
| 45 | 45 |
<p>duration</p> |
| 46 | 46 |
</div> |
| 47 | 47 |
</td> |
| ... | ... |
@@ -76,7 +76,7 @@ |
| 76 | 76 |
</thead> |
| 77 | 77 |
<tr> |
| 78 | 78 |
<td class="success">testAffichageBase()</td> |
| 79 |
-<td class="success">0.151s</td> |
|
| 79 |
+<td class="success">0.203s</td> |
|
| 80 | 80 |
<td class="success">passed</td> |
| 81 | 81 |
</tr> |
| 82 | 82 |
</table> |
| ... | ... |
@@ -89,7 +89,7 @@ |
| 89 | 89 |
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> |
| 90 | 90 |
</label> |
| 91 | 91 |
</div>Generated by |
| 92 |
-<a href="http://www.gradle.org">Gradle 8.8</a> at 7 oct. 2024, 11:17:20</p> |
|
| 92 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:07:21</p> |
|
| 93 | 93 |
</div> |
| 94 | 94 |
</div> |
| 95 | 95 |
</body> |
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
</td> |
| 42 | 42 |
<td> |
| 43 | 43 |
<div class="infoBox" id="duration"> |
| 44 |
-<div class="counter">0.034s</div> |
|
| 44 |
+<div class="counter">0.018s</div> |
|
| 45 | 45 |
<p>duration</p> |
| 46 | 46 |
</div> |
| 47 | 47 |
</td> |
| ... | ... |
@@ -78,19 +78,19 @@ |
| 78 | 78 |
<tr> |
| 79 | 79 |
<td class="success">addMoney</td> |
| 80 | 80 |
<td class="success">testAddMoney()</td> |
| 81 |
-<td class="success">0s</td> |
|
| 81 |
+<td class="success">0.001s</td> |
|
| 82 | 82 |
<td class="success">passed</td> |
| 83 | 83 |
</tr> |
| 84 | 84 |
<tr> |
| 85 | 85 |
<td class="success">Affichage</td> |
| 86 |
-<td class="success">testAfficage()</td> |
|
| 87 |
-<td class="success">0.008s</td> |
|
| 86 |
+<td class="success">testAffichage()</td> |
|
| 87 |
+<td class="success">0.006s</td> |
|
| 88 | 88 |
<td class="success">passed</td> |
| 89 | 89 |
</tr> |
| 90 | 90 |
<tr> |
| 91 | 91 |
<td class="success">Main</td> |
| 92 | 92 |
<td class="success">testMain()</td> |
| 93 |
-<td class="success">0.013s</td> |
|
| 93 |
+<td class="success">0.001s</td> |
|
| 94 | 94 |
<td class="success">passed</td> |
| 95 | 95 |
</tr> |
| 96 | 96 |
<tr> |
| ... | ... |
@@ -102,7 +102,7 @@ |
| 102 | 102 |
<tr> |
| 103 | 103 |
<td class="success">Natural Tests</td> |
| 104 | 104 |
<td class="success">testNatural()</td> |
| 105 |
-<td class="success">0.003s</td> |
|
| 105 |
+<td class="success">0.002s</td> |
|
| 106 | 106 |
<td class="success">passed</td> |
| 107 | 107 |
</tr> |
| 108 | 108 |
<tr> |
| ... | ... |
@@ -114,25 +114,25 @@ |
| 114 | 114 |
<tr> |
| 115 | 115 |
<td class="success">Sample test</td> |
| 116 | 116 |
<td class="success">testPlayerName()</td> |
| 117 |
-<td class="success">0.001s</td> |
|
| 117 |
+<td class="success">0s</td> |
|
| 118 | 118 |
<td class="success">passed</td> |
| 119 | 119 |
</tr> |
| 120 | 120 |
<tr> |
| 121 | 121 |
<td class="success">removeMoney</td> |
| 122 | 122 |
<td class="success">testRemoveMoney()</td> |
| 123 |
-<td class="success">0.005s</td> |
|
| 123 |
+<td class="success">0.004s</td> |
|
| 124 | 124 |
<td class="success">passed</td> |
| 125 | 125 |
</tr> |
| 126 | 126 |
<tr> |
| 127 | 127 |
<td class="success">ex & lvl</td> |
| 128 | 128 |
<td class="success">testRetrieveLevel()</td> |
| 129 |
-<td class="success">0.002s</td> |
|
| 129 |
+<td class="success">0.001s</td> |
|
| 130 | 130 |
<td class="success">passed</td> |
| 131 | 131 |
</tr> |
| 132 | 132 |
<tr> |
| 133 | 133 |
<td class="success">Construcor UpdatePlayer</td> |
| 134 | 134 |
<td class="success">testUpdatePlayer()</td> |
| 135 |
-<td class="success">0s</td> |
|
| 135 |
+<td class="success">0.001s</td> |
|
| 136 | 136 |
<td class="success">passed</td> |
| 137 | 137 |
</tr> |
| 138 | 138 |
</table> |
| ... | ... |
@@ -145,7 +145,7 @@ |
| 145 | 145 |
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> |
| 146 | 146 |
</label> |
| 147 | 147 |
</div>Generated by |
| 148 |
-<a href="http://www.gradle.org">Gradle 8.8</a> at 7 oct. 2024, 11:17:20</p> |
|
| 148 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:07:21</p> |
|
| 149 | 149 |
</div> |
| 150 | 150 |
</div> |
| 151 | 151 |
</body> |
| ... | ... |
@@ -38,7 +38,7 @@ |
| 38 | 38 |
</td> |
| 39 | 39 |
<td> |
| 40 | 40 |
<div class="infoBox" id="duration"> |
| 41 |
-<div class="counter">0.185s</div> |
|
| 41 |
+<div class="counter">0.221s</div> |
|
| 42 | 42 |
<p>duration</p> |
| 43 | 43 |
</div> |
| 44 | 44 |
</td> |
| ... | ... |
@@ -85,7 +85,7 @@ |
| 85 | 85 |
<td>11</td> |
| 86 | 86 |
<td>0</td> |
| 87 | 87 |
<td>0</td> |
| 88 |
-<td>0.185s</td> |
|
| 88 |
+<td>0.221s</td> |
|
| 89 | 89 |
<td class="success">100%</td> |
| 90 | 90 |
</tr> |
| 91 | 91 |
</tbody> |
| ... | ... |
@@ -112,7 +112,7 @@ |
| 112 | 112 |
<td>1</td> |
| 113 | 113 |
<td>0</td> |
| 114 | 114 |
<td>0</td> |
| 115 |
-<td>0.151s</td> |
|
| 115 |
+<td>0.203s</td> |
|
| 116 | 116 |
<td class="success">100%</td> |
| 117 | 117 |
</tr> |
| 118 | 118 |
<tr> |
| ... | ... |
@@ -122,7 +122,7 @@ |
| 122 | 122 |
<td>10</td> |
| 123 | 123 |
<td>0</td> |
| 124 | 124 |
<td>0</td> |
| 125 |
-<td>0.034s</td> |
|
| 125 |
+<td>0.018s</td> |
|
| 126 | 126 |
<td class="success">100%</td> |
| 127 | 127 |
</tr> |
| 128 | 128 |
</tbody> |
| ... | ... |
@@ -136,7 +136,7 @@ |
| 136 | 136 |
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> |
| 137 | 137 |
</label> |
| 138 | 138 |
</div>Generated by |
| 139 |
-<a href="http://www.gradle.org">Gradle 8.8</a> at 7 oct. 2024, 11:17:20</p> |
|
| 139 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:07:21</p> |
|
| 140 | 140 |
</div> |
| 141 | 141 |
</div> |
| 142 | 142 |
</body> |
| ... | ... |
@@ -40,7 +40,7 @@ |
| 40 | 40 |
</td> |
| 41 | 41 |
<td> |
| 42 | 42 |
<div class="infoBox" id="duration"> |
| 43 |
-<div class="counter">0.185s</div> |
|
| 43 |
+<div class="counter">0.221s</div> |
|
| 44 | 44 |
<p>duration</p> |
| 45 | 45 |
</div> |
| 46 | 46 |
</td> |
| ... | ... |
@@ -83,7 +83,7 @@ |
| 83 | 83 |
<td>1</td> |
| 84 | 84 |
<td>0</td> |
| 85 | 85 |
<td>0</td> |
| 86 |
-<td>0.151s</td> |
|
| 86 |
+<td>0.203s</td> |
|
| 87 | 87 |
<td class="success">100%</td> |
| 88 | 88 |
</tr> |
| 89 | 89 |
<tr> |
| ... | ... |
@@ -93,7 +93,7 @@ |
| 93 | 93 |
<td>10</td> |
| 94 | 94 |
<td>0</td> |
| 95 | 95 |
<td>0</td> |
| 96 |
-<td>0.034s</td> |
|
| 96 |
+<td>0.018s</td> |
|
| 97 | 97 |
<td class="success">100%</td> |
| 98 | 98 |
</tr> |
| 99 | 99 |
</table> |
| ... | ... |
@@ -106,7 +106,7 @@ |
| 106 | 106 |
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> |
| 107 | 107 |
</label> |
| 108 | 108 |
</div>Generated by |
| 109 |
-<a href="http://www.gradle.org">Gradle 8.8</a> at 7 oct. 2024, 11:17:20</p> |
|
| 109 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:07:21</p> |
|
| 110 | 110 |
</div> |
| 111 | 111 |
</div> |
| 112 | 112 |
</body> |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
-<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-10-07T09:17:20" hostname="a206pc27L.local.isima.fr" time="0.151"> |
|
| 2 |
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-10-21T09:07:21" hostname="a206pc27L.local.isima.fr" time="0.203"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.151"/> |
|
| 4 |
+ <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.203"/> |
|
| 5 | 5 |
<system-out><![CDATA[]]></system-out> |
| 6 | 6 |
<system-err><![CDATA[]]></system-err> |
| 7 | 7 |
</testsuite> |
| ... | ... |
@@ -1,16 +1,16 @@ |
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
-<testsuite name="re.forestier.edu.UnitTests" tests="10" skipped="0" failures="0" errors="0" timestamp="2024-10-07T09:17:20" hostname="a206pc27L.local.isima.fr" time="0.041"> |
|
| 2 |
+<testsuite name="re.forestier.edu.UnitTests" tests="10" skipped="0" failures="0" errors="0" timestamp="2024-10-21T09:07:21" hostname="a206pc27L.local.isima.fr" time="0.021"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.013"/> |
|
| 5 |
- <testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.005"/> |
|
| 6 |
- <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.002"/> |
|
| 7 |
- <testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 8 |
- <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 4 |
+ <testcase name="Affichage" classname="re.forestier.edu.UnitTests" time="0.006"/> |
|
| 5 |
+ <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 6 |
+ <testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.004"/> |
|
| 7 |
+ <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 8 |
+ <testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 9 |
+ <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 9 | 10 |
<testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.001"/> |
| 10 | 11 |
<testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.001"/> |
| 11 |
- <testcase name="Affichage" classname="re.forestier.edu.UnitTests" time="0.008"/> |
|
| 12 |
- <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.003"/> |
|
| 13 |
- <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 12 |
+ <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.002"/> |
|
| 13 |
+ <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 14 | 14 |
<system-out><![CDATA[]]></system-out> |
| 15 | 15 |
<system-err><![CDATA[]]></system-err> |
| 16 | 16 |
</testsuite> |
| ... | ... |
@@ -0,0 +1,118 @@ |
| 1 |
+package re.forestier.edu.lib; |
|
| 2 |
+ |
|
| 3 |
+public class Natural implements Comparable<Natural>, Cloneable |
|
| 4 |
+{
|
|
| 5 |
+ private int value; |
|
| 6 |
+ public static final Natural ZERO = new ZERO(); |
|
| 7 |
+ |
|
| 8 |
+ public Natural() |
|
| 9 |
+ {
|
|
| 10 |
+ this.value = 0; |
|
| 11 |
+ } |
|
| 12 |
+ |
|
| 13 |
+ private Natural(Integer i) |
|
| 14 |
+ {
|
|
| 15 |
+ if(i == null) |
|
| 16 |
+ throw new IllegalArgumentException(); |
|
| 17 |
+ if(i < 0) |
|
| 18 |
+ throw new IllegalArgumentException("Natural >=0");
|
|
| 19 |
+ this.value = i; |
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+ private Natural(int i) |
|
| 23 |
+ {
|
|
| 24 |
+ if(i < 0) |
|
| 25 |
+ throw new IllegalArgumentException("Natural >=0");
|
|
| 26 |
+ this.value = i; |
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 29 |
+ public Integer toInteger() |
|
| 30 |
+ {
|
|
| 31 |
+ return Integer.valueOf(this.value); |
|
| 32 |
+ } |
|
| 33 |
+ |
|
| 34 |
+ public int toInt() |
|
| 35 |
+ {
|
|
| 36 |
+ return this.value; |
|
| 37 |
+ } |
|
| 38 |
+ |
|
| 39 |
+ public static Natural valueOf(Integer i) |
|
| 40 |
+ {
|
|
| 41 |
+ if(i == null) |
|
| 42 |
+ throw new IllegalArgumentException(); |
|
| 43 |
+ return new Natural(i); |
|
| 44 |
+ } |
|
| 45 |
+ |
|
| 46 |
+ public static Natural valueOf(int i) |
|
| 47 |
+ {
|
|
| 48 |
+ return new Natural(i); |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ public void add(Natural n) |
|
| 52 |
+ {
|
|
| 53 |
+ if(n == null) |
|
| 54 |
+ throw new IllegalArgumentException(); |
|
| 55 |
+ this.value += n.toInt(); |
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ |
|
| 59 |
+ public void substract(Natural n) |
|
| 60 |
+ {
|
|
| 61 |
+ if(n == null || this.compareTo(n) == 1) |
|
| 62 |
+ throw new IllegalArgumentException(); |
|
| 63 |
+ this.value -= n.toInt(); |
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ public void divide(Natural n) |
|
| 67 |
+ {
|
|
| 68 |
+ if(n == null || n == Natural.ZERO) |
|
| 69 |
+ throw new IllegalArgumentException(); |
|
| 70 |
+ this.value /= n.toInt(); |
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ |
|
| 74 |
+ @Override |
|
| 75 |
+ public Object clone() |
|
| 76 |
+ {
|
|
| 77 |
+ return Natural.valueOf(this.value); |
|
| 78 |
+ } |
|
| 79 |
+ |
|
| 80 |
+ @Override |
|
| 81 |
+ public String toString() |
|
| 82 |
+ {
|
|
| 83 |
+ return String.valueOf(this.value); |
|
| 84 |
+ } |
|
| 85 |
+ |
|
| 86 |
+ @Override |
|
| 87 |
+ public boolean equals(Object o) |
|
| 88 |
+ {
|
|
| 89 |
+ if(o == null) |
|
| 90 |
+ return false; |
|
| 91 |
+ if(o == this) |
|
| 92 |
+ return true; |
|
| 93 |
+ if(!(o instanceof Natural)) |
|
| 94 |
+ return false; |
|
| 95 |
+ return this.value == ((Natural)o).value; |
|
| 96 |
+ } |
|
| 97 |
+ |
|
| 98 |
+ @Override |
|
| 99 |
+ public int compareTo(Natural n) |
|
| 100 |
+ {
|
|
| 101 |
+ if(n == null) |
|
| 102 |
+ throw new IllegalArgumentException(); |
|
| 103 |
+ if(n.value > this.value) |
|
| 104 |
+ return 1; |
|
| 105 |
+ else if(n.value == this.value) |
|
| 106 |
+ return 0; |
|
| 107 |
+ else |
|
| 108 |
+ return -1; |
|
| 109 |
+ } |
|
| 110 |
+ |
|
| 111 |
+ private static class ZERO extends Natural |
|
| 112 |
+ {
|
|
| 113 |
+ private ZERO() |
|
| 114 |
+ {
|
|
| 115 |
+ super(0); |
|
| 116 |
+ } |
|
| 117 |
+ } |
|
| 118 |
+} |
|
| 0 | 119 |
\ No newline at end of file |
| ... | ... |
@@ -3,6 +3,7 @@ package re.forestier.edu.rpg; |
| 3 | 3 |
import java.util.Random; |
| 4 | 4 |
import java.util.ArrayList; |
| 5 | 5 |
import java.util.HashMap; |
| 6 |
+import re.forestier.edu.lib.Natural; |
|
| 6 | 7 |
|
| 7 | 8 |
public class Player {
|
| 8 | 9 |
private static final Integer[] xpForlevel = {0,10,27,57,111}; //Level = i+1
|
| ... | ... |
@@ -15,7 +16,7 @@ public class Player {
|
| 15 | 16 |
private Integer money; |
| 16 | 17 |
private Float __real_money__; |
| 17 | 18 |
|
| 18 |
- private int level; |
|
| 19 |
+ private Natural level; |
|
| 19 | 20 |
private int healthpoints; |
| 20 | 21 |
private int currenthealthpoints; |
| 21 | 22 |
private int xp; |
| ... | ... |
@@ -34,7 +35,7 @@ public class Player {
|
| 34 | 35 |
AvatarClass = avatarClass; |
| 35 | 36 |
this.money = Integer.valueOf(money); |
| 36 | 37 |
this.inventory = inventory; |
| 37 |
- this.level = 1; |
|
| 38 |
+ this.level = Natural.valueOf(1); |
|
| 38 | 39 |
this.xp = 0; |
| 39 | 40 |
this.abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(AvatarClass).get(1); |
| 40 | 41 |
} |
| ... | ... |
@@ -56,7 +57,7 @@ public class Player {
|
| 56 | 57 |
|
| 57 | 58 |
public int getLevel() |
| 58 | 59 |
{
|
| 59 |
- return this.level; |
|
| 60 |
+ return this.level.toInt(); |
|
| 60 | 61 |
} |
| 61 | 62 |
|
| 62 | 63 |
public int getHealthPoints() |
| ... | ... |
@@ -94,7 +95,7 @@ public class Player {
|
| 94 | 95 |
} |
| 95 | 96 |
|
| 96 | 97 |
public void addXp(int xp) {
|
| 97 |
- int ancientLevel = this.level; |
|
| 98 |
+ Natural ancientLevel = (Natural)this.level.clone(); |
|
| 98 | 99 |
this.xp += xp; |
| 99 | 100 |
int i = 0; |
| 100 | 101 |
while(i < xpForlevel.length && this.xp >= xpForlevel[i]) |
| ... | ... |
@@ -102,9 +103,9 @@ public class Player {
|
| 102 | 103 |
i++; |
| 103 | 104 |
} |
| 104 | 105 |
|
| 105 |
- this.level = i; |
|
| 106 |
+ this.level = Natural.valueOf(i); |
|
| 106 | 107 |
|
| 107 |
- if (this.level != ancientLevel) {
|
|
| 108 |
+ if (!ancientLevel.equals(this.level)) {
|
|
| 108 | 109 |
// Player leveled-up! |
| 109 | 110 |
// Give a random object |
| 110 | 111 |
; |
| ... | ... |
@@ -112,7 +113,7 @@ public class Player {
|
| 112 | 113 |
this.inventory.add(UpdatePlayer.objectList[random.nextInt(UpdatePlayer.objectList.length)]); |
| 113 | 114 |
|
| 114 | 115 |
// Add/upgrade abilities to player |
| 115 |
- HashMap<String, Integer> abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(this.getAvatarClass()).get(this.level); |
|
| 116 |
+ HashMap<String, Integer> abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(this.getAvatarClass()).get(this.level.toInt()); |
|
| 116 | 117 |
abilities.forEach((ability, level) -> {
|
| 117 | 118 |
this.abilities.put(ability, abilities.get(ability)); |
| 118 | 119 |
}); |
| ... | ... |
@@ -189,7 +189,7 @@ public class UnitTests {
|
| 189 | 189 |
|
| 190 | 190 |
@Test |
| 191 | 191 |
@DisplayName("Affichage")
|
| 192 |
- void testAfficage() {
|
|
| 192 |
+ void testAffichage() {
|
|
| 193 | 193 |
Affichage a = new Affichage(); |
| 194 | 194 |
assertNotNull(a); |
| 195 | 195 |
|
| ... | ... |
@@ -212,6 +212,7 @@ public class UnitTests {
|
| 212 | 212 |
{
|
| 213 | 213 |
Natural n = new Natural(); |
| 214 | 214 |
assertNotNull(n); |
| 215 |
+ assertNotNull(Natural.valueOf(2)); |
|
| 215 | 216 |
assertEquals(n.toInt(),0); |
| 216 | 217 |
|
| 217 | 218 |
n = Natural.valueOf(2); |
| ... | ... |
@@ -224,18 +225,21 @@ public class UnitTests {
|
| 224 | 225 |
assertThrows(IllegalArgumentException.class, () -> Natural.valueOf(Integer.valueOf(-2))); |
| 225 | 226 |
assertThrows(IllegalArgumentException.class, () -> Natural.valueOf(null)); |
| 226 | 227 |
|
| 227 |
- assertEquals(n.add(Natural.valueOf(2)),Natural.valueOf(4)); |
|
| 228 |
+ n.add(Natural.valueOf(2)); |
|
| 229 |
+ assertEquals(n,Natural.valueOf(4)); |
|
| 228 | 230 |
assertThrows(IllegalArgumentException.class, () -> Natural.valueOf(0).add(null)); |
| 229 |
- assertEquals(n.substract(Natural.valueOf(2)),Natural.valueOf(0)); |
|
| 231 |
+ n.substract(Natural.valueOf(4)); |
|
| 232 |
+ assertEquals(n,Natural.valueOf(0)); |
|
| 230 | 233 |
assertThrows(IllegalArgumentException.class, () -> Natural.valueOf(0).substract(Natural.valueOf(4))); |
| 231 | 234 |
|
| 232 |
- assertEquals(n.toString(),"2"); |
|
| 233 |
- assertTrue(n.equals(Natural.valueOf(2))); |
|
| 235 |
+ assertEquals(n.toString(),"0"); |
|
| 236 |
+ assertTrue(n.equals(Natural.valueOf(0))); |
|
| 234 | 237 |
assertTrue(n.equals(n)); |
| 235 | 238 |
assertFalse(n.equals(Natural.valueOf(3))); |
| 236 |
- assertFalse(n.equals(Integer.valueOf(0))); |
|
| 239 |
+ assertFalse(n.equals(Integer.valueOf(4))); |
|
| 237 | 240 |
assertFalse(n.equals(null)); |
| 238 | 241 |
|
| 242 |
+ n.add(Natural.valueOf(2)); |
|
| 239 | 243 |
assertEquals(n.compareTo(Natural.valueOf(2)),0); |
| 240 | 244 |
assertEquals(n.compareTo(Natural.valueOf(3)),1); |
| 241 | 245 |
assertEquals(n.compareTo(Natural.valueOf(1)),-1); |
| 242 | 246 |