Skip to content

Commit cac7e73

Browse files
committed
correcting use of term tag
1 parent e15fa0c commit cac7e73

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void setDenominator(Integer denominator) { // setter method
215215
<section xml:id="writing-a-constructor">
216216
<title>Writing a constructor</title>
217217

218-
<p>
218+
<p><idx><h>constructor</h></idx>
219219
Once you have identified the instance variables for your class the next thing to consider is the constructor.
220220
In Java, <term>constructors</term> have the same name as the class and are declared public.
221221
They are declared without a return type.
@@ -278,8 +278,8 @@ public Fraction(Integer num, Integer den) {
278278
<li>
279279
<p>
280280
<idx>pass-by-value</idx>
281-
<idx>value of the reference</idx>
282-
<term>Java is strictly pass-by-value.</term> For primitive types (like <c>int</c>), a copy of the value is passed. For object types (like our <c>Fraction</c>), a copy of the <em><term>value of the reference</term></em> (the memory address) is passed.
281+
282+
Java is strictly <term>pass-by-value</term>. For primitive types (like <c>int</c>), a copy of the value is passed. For object types (like our <c>Fraction</c>), a copy of the <term>reference</term>(Namely, the memory address) is passed.
283283
</p>
284284
</li>
285285
<li>
@@ -571,7 +571,7 @@ public String toString() {
571571
In Java, when two objects are compared using the <c>==</c> operator they are tested to see if they are exactly the same object (that is, do the two objects occupy the same exact space in the computer&#x2019;s memory?).
572572
This is also the default behavior of the <c>equals</c> method provided by <c>Object</c>.
573573
The <c>equals</c> method allows us to decide if two objects are equal by looking at their instance variables.
574-
However it is important to remember that since Java does not have operator overloading <term>if you want to use your</term> <c>equals</c> <term>method you must call it directly</term>.
574+
However it is important to remember that since Java does not have operator overloading <em>if you want to use your</em> <c>equals</c> <em>method you must call it directly</em>.
575575
Therefore once you write your own <c>equals</c> method:
576576
</p>
577577

@@ -631,7 +631,7 @@ public boolean equals(Fraction other) {
631631
If you look at the documentation for <c>Integer</c> you will see that <c>Integer</c>&#x2019;s parent class is <c>Number</c>.
632632
Number is an <term>abstract class</term> that specifies several methods that all of its children must implement.
633633
In Java an abstract class is more than just a placeholder for common methods.
634-
In Java an abstract class has the power to specify certain methods that all of its children <term>must</term> implement.
634+
In Java an abstract class has the power to specify certain methods that all of its children <em>must</em> implement.
635635
You can trace this power back to the strong typing nature of Java.
636636
</p>
637637

@@ -650,7 +650,7 @@ public class Fraction extends Number {
650650
</listing>
651651

652652
<p>
653-
<idx><c>extends</c></idx>
653+
<idx><c>extending a class</c></idx>
654654
The keyword <term><c>extends</c></term> tells the compiler that the class <c>Fraction</c> extends, or adds new functionality to the <c>Number</c> class.
655655
A child class always extends its parent.
656656
</p>
@@ -720,7 +720,7 @@ public long longValue() {
720720
</p>
721721

722722
<p>
723-
However, and this is a big however, it is important to remember that if you specify <c>Number</c> as the type of a particular parameter then the Java compiler will <term>only let you use the methods of a</term> <c>Number</c>: <c>longValue</c>, <c>intValue</c>, <c>floatValue</c>, and <c>doubleValue</c>.
723+
However, and this is a big however, it is important to remember that if you specify <c>Number</c> as the type of a particular parameter then the Java compiler will <em>only let you use the methods of a</em> <c>Number</c>: <c>longValue</c>, <c>intValue</c>, <c>floatValue</c>, and <c>doubleValue</c>.
724724
</p>
725725

726726
<p>
@@ -739,7 +739,7 @@ public void test(Number a, Number b) {
739739

740740
<p>
741741
The Java compiler would give an error because <c>add</c> is not a defined method of the <c>Number</c> class.
742-
You will <term>still get this error</term> even if all your code that calls this <c>test</c> method passes two <c>Fractions</c> as parameters (remember that <c>Fraction</c> does implement <c>add</c>).
742+
You will <em>still get this error</em> even if all your code that calls this <c>test</c> method passes two <c>Fractions</c> as parameters (remember that <c>Fraction</c> does implement <c>add</c>).
743743
</p>
744744
</subsection>
745745
</section>
@@ -748,7 +748,6 @@ public void test(Number a, Number b) {
748748
<title>Interfaces</title>
749749

750750
<p>
751-
<idx><c>Comparable</c></idx>
752751
<idx>single inheritance</idx>
753752
Lets turn our attention to making a list of fractions sortable by the standard Java sorting method <c>Collections.sort</c>.
754753
In Python, we would just need to implement the <c>__cmp__</c> method.

0 commit comments

Comments
 (0)