private WideningConversion(char type, Calculator calc, Primitive arg) throws InvalidOperandException, InvalidTypeException { super(type, calc); // checks on parameters if (arg == null) { throw new InvalidOperandException("null operand in widening construction"); } if (!Type.widens(type, arg.getType())) { throw new InvalidTypeException("cannot widen type " + arg.getType() + " to type " + type); } this.arg = arg; // calculates hashCode final int prime = 281; int result = 1; result = prime * result + arg.hashCode(); result = prime * result + type; this.hashCode = result; // calculates toString this.toString = "WIDEN-" + this.getType() + "(" + arg.toString() + ")"; }