I'm trying to return the 'x' that I have found in my loop, but it isn't working. I need some help!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public int lookForPosition() { boolean found = false ; while (found = false ) { int x = Greenfoot.getRandomNumber(getWidth()); boolean different = false ; for ( int i = 0 ; i < xPosities.length; i++) { if (xPosities[i] != x) { different = true ; break ; } else { different = false ; } } if (different = true ) { found = true ; } else { found = false ; } } return x; } |