1
2
3
4
5
6
7
8public
9class Const extends Expr {
10
11 protected
12 Object value;
13
14
15
16 public
17 Const(Object value) {
18 this.value = value;
19 }
20
21
22
23
24
25
26 public
27 Const(int value) {
28 this(new Integer(value));
29 }
30
31
32
33
34
35
36 public
37 Const(double value) {
38 this(new Double(value));
39 }
40
41
42
43 public
44 Object eval() {
45 return
46 value;
47 }
48
49
50 public
51 String toString() {
52 return
53 value.toString();
54 }
55}
56
57