-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber.java
More file actions
60 lines (58 loc) · 1.21 KB
/
Number.java
File metadata and controls
60 lines (58 loc) · 1.21 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
This class is so we can acces the HistoNode, it was already been wriiten
@author Ta'Rissa Woods
@ version %I% %G%
*/
public class Number
{
/**
instane variable for the value of the number
*/
private int theValue;
/**
Parameterized constructor for the number class
@param for the value wanting to be inputed
*/
public Number(int value)
{
theValue = value;
}
/**
method to get a value
@return the value that is being got
*/
public int getValue()
{
return theValue;
}
/**
method to check if an object equalses the value instance variable
@param the object that is to be compared with the value instance variable
@return true if the values match, false if they don't
*/
public boolean equals(Object obj)
{
if (theValue == obj.getValue()) {
return true;
}
else {
return false;
}
}
/**
method to change the value in a hash code
@return the hash code value of the value instance variable
*/
public int hashCode()
{
return theValue%10;
}
/**
method to print the expresion in string form
@return a string of the expression like "VALUE OF THE NUMBER: 2"
*/
public String toString()
{
return "VALUE OF THE NUMBER: " + theValue;
}
}