-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber.java
More file actions
42 lines (35 loc) · 844 Bytes
/
Number.java
File metadata and controls
42 lines (35 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package hashtableintlab;
public class Number {
private int theValue;
/* Parameterized constructor
* @param value value for theValue*/
public Number(int value) {
theValue = value;
}
/* Returns theValue
* @return int theValue */
public int getValue() {
return theValue;
}
/* Checks if two number objects are equal
* @return true objects equal
* @return false objects not equal */
public boolean equals(Number obj) {
if (theValue == obj.getValue()) {
return true;
}
else {
return false;
}
}
/* Returns the generated hashCode value
* @return int hashCode */
public int hashCode() {
return theValue%10;
}
/* Prints information about the Number object
* @return String theValue */
public String toString() {
return "" + theValue;
}
}