user
10/04/2017, 11:28 AMclass Position(val x: Int, val y: Int) {
fun right(units: Int) = Position(x + units.assertAsPositive, y)
fun left(units: Int) = Position(x - units.assertAsPositive, y)
fun up(units: Int) = Position(x, y + units.assertAsPositive)
fun down(units: Int) = Position(x, y - units.assertAsPositive)
val Int.assertAsPositive: Int
get() = if (this < 0) throw IllegalArgumentException() else this
}