
7.11 Static Class Members 413
117 + gallonsFormat.format( gallonsOfGas );
118 }
119
120 // equals: returns true if fields of parameter object
121 // are equal to fields in this object
122 public boolean equals( Object o )
123 {
124 if ( ! ( o instanceof Auto ) )
125 return false;
126 else
127 {
128 Auto objAuto = ( Auto ) o;
129 if ( model.equals( objAuto.model )
130 && milesDriven == objAuto.milesDriven
131 && Math.abs( gallonsOfGas - objAuto.gallonsOfGas )
132 < 0.0001 )
133 return true;
134 else
135 return false;
136 }
137 }
138 }
EXAMPLE 7.12 Auto Class,Version 6
Example 7.13 shows Version 6 of our AutoClient class. In line 11, we call the
getCountAutos method ...