Skip to content

Instantly share code, notes, and snippets.

@Ry4an
Forked from anonymous/gist:1791986
Created February 10, 2012 19:41
Show Gist options
  • Save Ry4an/1792078 to your computer and use it in GitHub Desktop.
Save Ry4an/1792078 to your computer and use it in GitHub Desktop.
// 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