Skip to content

Instantly share code, notes, and snippets.

@Ry4an

Ry4an/gist:1792078

Forked from anonymous/gist:1791986
Created Feb 10, 2012
Embed
What would you like to do?
// the solution
// 1. declare the class Number(Int)
// 2. define method Number.inc(): Number
// 3. define method Number.dec(): Number
// 4. define getNumber():Int
class Number(val n : Int) { // n cannot be changed!
def inc(): Number = new Number(n + 1)
def dec(): Number = new Number(n - 1)
def getNumber() : Int = n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment