-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScalarSymbol.java
50 lines (43 loc) · 902 Bytes
/
ScalarSymbol.java
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
package apps;
/**
* This class encapsulates a (name, integer value) pair for a scalar (non-array) variable.
* The variable name is a sequence of one or more letters.
*
* @author ru-nb-cs112
*
*/
public class ScalarSymbol {
/**
* Name, sequence of letters
*/
public String name;
/**
* Integer value
*/
public int value;
/**
* Initializes this symbol with given name, and zero value
*
* @param name Variable name
*/
public ScalarSymbol(String name) {
this.name = name;
value = 0;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return name + "=" + value;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object o) {
if (o == null || !(o instanceof ScalarSymbol)) {
return false;
}
ScalarSymbol ss = (ScalarSymbol)o;
return name.equals(ss.name);
}
}