Create a `KeepInBounds()`

method. Without this method, hitting the boundaries will break the game!

Every time a key is pressed, it will be called twice: once for x and once for y. The method will constrain a coordinate between 0 and its maximum value to keep the character from going off-screen.

The method should:

- have the
`public new static`

modifiers - return an
`int`

- have two arguments: an
`int`

representing the coordinate, and an`int`

representing the maximum value

Here’s how the method will be used. Imagine that the x-coordinate has a maximum of `10`

(exclusive), so it should only take values from `0`

through `9`

:

// newX will be 1 newX = KeepInBounds(1, 10); // newX will be 0 newX = KeepInBounds(-1, 10); // newX will be 9 newX = KeepInBounds(10,10); // newX will be 9 newX = KeepInBounds(11,10);

https://www.codecademy.com/practice/projects/console-game-challenge-project

public static new int KeepInBounds(int dimension, int max = 10)

{

int min = 0;

if (dimension <= min)

{

return dimension = 0;

} else if (dimension >= max)

{

return dimension = 9;

} else { return dimension;}

}

thanks.