GitLab wurde erfolgreich aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Danke für Ihre Geduld.

Commit a487f13d authored by Dominikus Herzberg's avatar Dominikus Herzberg

Neues HTML mit Korrekturen zu equals

parent f44096b2
......@@ -651,7 +651,7 @@ false</pre>
<span class="local-variable">this</span>.x = x;
<span class="local-variable">this</span>.y = y;
}
<span class="directive">public</span> equals(<span class="predefined-type">Object</span> other) {
<span class="directive">public</span> <span class="type">boolean</span> equals(<span class="predefined-type">Object</span> other) {
<span class="keyword">if</span> (other <span class="keyword">instanceof</span> <span class="predefined-type">Point</span>) { <i class="conum" data-value="1"></i><b>(1)</b>
<span class="predefined-type">Point</span> otherPoint = (<span class="predefined-type">Point</span>) other; <i class="conum" data-value="2"></i><b>(2)</b>
<span class="keyword">return</span> otherPoint.x == <span class="local-variable">this</span>.x &amp;&amp; otherPoint.y == <span class="local-variable">this</span>.y;
......@@ -665,11 +665,12 @@ false</pre>
Car(<span class="type">double</span> tachometer) {
<span class="local-variable">this</span>.tachometer = tachometer;
}
<span class="directive">public</span> equals(<span class="predefined-type">Object</span> other) {
<span class="directive">public</span> <span class="type">boolean</span> equals(<span class="predefined-type">Object</span> other) {
<span class="keyword">if</span> (other <span class="keyword">instanceof</span> Car) { <i class="conum" data-value="1"></i><b>(1)</b>
Car otherCar = (Car) other; <i class="conum" data-value="2"></i><b>(2)</b>
<span class="keyword">return</span> otherCar.tachometer == <span class="local-variable">this</span>.tachometer;
}
<span class="keyword">return</span> <span class="predefined-constant">false</span>;
}
}
......@@ -684,7 +685,7 @@ false</pre>
<span class="local-variable">this</span>.numerator = numerator;
<span class="local-variable">this</span>.denominator = denominator;
}
<span class="directive">public</span> equals(<span class="predefined-type">Object</span> other) {
<span class="directive">public</span> <span class="type">boolean</span> equals(<span class="predefined-type">Object</span> other) {
<span class="keyword">if</span> (other <span class="keyword">instanceof</span> Fraction) { <i class="conum" data-value="1"></i><b>(1)</b>
Fraction otherFrac = (Fraction) other; <i class="conum" data-value="2"></i><b>(2)</b>
<span class="keyword">return</span> otherFrac.numerator == <span class="local-variable">this</span>.numerator
......@@ -692,7 +693,15 @@ false</pre>
}
<span class="keyword">return</span> <span class="predefined-constant">false</span>;
}
}</code></pre>
}
<span class="keyword">assert</span> !<span class="keyword">new</span> Fraction(<span class="integer">1</span>,<span class="integer">2</span>).equals(<span class="keyword">new</span> Car(<span class="float">123.0</span>));
<span class="keyword">assert</span> <span class="keyword">new</span> Fraction(<span class="integer">1</span>,<span class="integer">2</span>).equals(<span class="keyword">new</span> Fraction(<span class="integer">1</span>,<span class="integer">2</span>));
<span class="keyword">assert</span> <span class="keyword">new</span> Fraction(<span class="integer">2</span>).equals(<span class="keyword">new</span> Fraction(<span class="integer">2</span>,<span class="integer">1</span>));
<span class="keyword">assert</span> !<span class="keyword">new</span> Car(<span class="integer">12</span>).equals(<span class="keyword">new</span> Car(<span class="float">12.1</span>));
<span class="keyword">assert</span> <span class="keyword">new</span> Car(<span class="integer">12</span>).equals(<span class="keyword">new</span> Car(<span class="float">12.0</span>));
<span class="keyword">assert</span> !<span class="keyword">new</span> <span class="predefined-type">Point</span>(<span class="integer">3</span>,<span class="integer">4</span>).equals(<span class="keyword">new</span> <span class="predefined-type">Point</span>(<span class="integer">4</span>,<span class="integer">3</span>));
<span class="keyword">assert</span> <span class="keyword">new</span> <span class="predefined-type">Point</span>(<span class="integer">3</span>,<span class="integer">4</span>).equals(<span class="keyword">new</span> <span class="predefined-type">Point</span>(<span class="integer">3</span>,<span class="integer">4</span>));</code></pre>
</div>
</div>
<div class="colist arabic">
......@@ -819,7 +828,7 @@ false</pre>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2017-11-10 14:43:57 Mitteleuropõische Zeit
Last updated 2017-11-10 14:49:32 Mitteleuropõische Zeit
</div>
</div>
</body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment