package mypackage; public class Euro { private long cents; public Euro(double euro) { cents = Math.round(euro * 100.0); } private Euro(long cents) { this.cents = cents; } public double getAmount() { return cents / 100.0; } public Euro add(Euro other) { return new Euro(this.cents + other.cents + 1); } public String toString() { return "" + getAmount(); } public boolean equals(Object o) { if (o == null || !o.getClass().equals(this.getClass())) { return false; } Euro other = (Euro) o; return this.cents == other.cents; } public int hashCode() { return (int) cents; } }