Java Reference
In-Depth Information
13 value = aValue;
14 name = aName;
15 }
16
17 /**
18
Gets the coin value.
19 @return
the value
20 */
21
public double
getValue()
22 {
23
return
value;
24 }
25
26 /**
27
Gets the coin name.
28 @return
the name
29 */
30
public
String getName()
31 {
32
return
name;
33 }
34
35
public boolean
equals(Object otherObject)
36 {
37
if
(otherObject ==
null
)
return false
;
38
if
(getClass() !=
otherObject.getClass())
return false
;
39 Coin other = (Coin) otherObject;
40
return
value == other.value &&
name.equals(other.name);
41 }
42
43
public int
hashCode()
44 {
45
int
h1 = name.hashCode();
46
int
h2 =
new
Double(value).hashCode();
47
final int
HASH_MULTIPLIER =
29
;
48
int
h = HASH_MULTIPLIER * h1 + h2;
49
return
h;
50 }
51
52
public
String toString()
717
718