A function which returns a random int with the range [minVal, maxVal].

Code taken from ["Generating random numbers in a range with Java" on StackOverflow](http://stackoverflow.com/a/363732/940217)