0

I am facing the following scenario:

I need a square shape in which there will be three people with points of (x,y) with 0 ≤ x ≤ 100 and 0 ≤ y ≤ 100. I need to use a method that assigns a random point of (x,y) between 0-100 to these three people

My question is how can I assign a random point?

This is something I come up with to help me understand Java properly.

sepp2k
  • 363,768
  • 54
  • 674
  • 675

1 Answers1

0

you can make use of the Random class to generate random values for your x and y values.

Random r = new Random();
int x = r.nextInt(101); //generate a value between 0 and 100
int y = r.nextInt(101); 

//...
William Ku
  • 798
  • 5
  • 17