This site requires JavaScript, please enable it in your browser!
Greenfoot back
plsFast
plsFast wrote ...

2019/3/29

Method head

plsFast plsFast

2019/3/29

#
If u want to give a method parameters like
public void example(int x, int y)
{
  Code
}
how can you limit x and y, so that u can only type 1-7 for example?
danpost danpost

2019/3/29

#
As first line inside the method:
if (x < 1 || x > 7) return;
plsFast plsFast

2019/3/29

#
but i want the input to be limited because i only need numbers from 1-7 and the method doesnt work because u could pick 8 or so
danpost danpost

2019/3/30

#
plsFast wrote...
but i want the input to be limited because i only need numbers from 1-7 and the method doesnt work because u could pick 8 or so
if (x > 0 && x < 8) example(x, y);
You need to login to post a reply.