public class SmartInteger { private int n; /** Returns new SmartInteger on <aNumber> */ public SmartInteger(int aNumber) { this.n = aNumber; } /** Returns friendly string of this object */ public String toString() { return "n: " + this.n; } /** Returns square of this number */ public int squared() { return this.n * this.n; } /** Returns cube of this number */ public int cubed() { return this.n * this.n * this.n; } /** Returns the square root (rounded) of this number */ public int squareRoot() { return (int)Math.round(Math.sqrt(this.n)); } /** Returns the quotient (rounded) of this number divided by the passed divisor */ public int dividedBy(int divisor) { return (int)Math.round((double)this.n / (double)divisor); } }