-
-
Save Ry4an/1792078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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