Math.random not zero
I am trying to create a initial value for a mystery win.
When you win this mystery prize in dollars it is between the -100 and 100.
I do not want zero as it is not achieves nothing.
I do not want to write a long winded method for this.
It is easy to generate a loss/win amount but I want to skip 0 dollars.
I am doing ther following
int rand = -101 + (int)(Math.random()*202);
The problem is I get zero sometimes.
The mystery win is set when the games runs and is only offered once.
I am inplementing this in the constructor so is set once.
How do I ignore zero without to much code in the constructor? ie. if statements.
Thanks in advance.
I think that will work...
I need to use Math.random though.
It makes it harder if I have to create a random object and then do work on that.
I really wanted to do it all in a couple of statements.
Its late and I have had a few beverages. Mind cloudy and I cannt work out how to elimate zero simply.
sorry, meant Math.random() not rand.nextInt()