1public
2class Mult extends BinaryExpr {
3
4
5
6 public
7 Mult(Expr left, Expr right) {
8 super(left, right);
9 }
10
11
12
13 protected
14 Object op2(Object v1, Object v2) {
15
16
17
18 if ( v1 instanceof Integer
19 &&
20 v2 instanceof Integer ) {
21
22 return
23 new Integer( ((Integer)v1).intValue()
24 *
25 ((Integer)v2).intValue() );
26 }
27
28
29
30 if ( v1 instanceof Double
31 &&
32 v2 instanceof Double ) {
33
34 return
35 new Double( ((Double)v1).doubleValue()
36 *
37 ((Double)v2).doubleValue() );
38 }
39
40
41
42 throw
43 new IllegalArgumentException(" * : illegal operand types");
44 }
45
46
47
48 public
49 String op2ToString() {
50 return
51 "*";
52 }
53}
54
55
56