What does this mean
int next //bye
int game //is amount of teams entered
next = (game % 2 == 0) ? -1 : ((Teams)iList.get(game-1)).getNum();
game /= 2;
matches =newint[game][3];
what do each of these lines mean, am i correct. what does ?-1 mean
int next //bye
int game //is amount of teams entered
next = (game % 2 == 0) ? -1 : ((Teams)iList.get(game-1)).getNum();
game /= 2;
matches =newint[game][3];
what do each of these lines mean, am i correct. what does ?-1 mean
I can explain the syntax. But the meaning of what they do is up to you.
// line 1
next = something ? a : b;
means
if (something) next=a; else next=b;
// line 2
game /= 2;
means
game = game / 2;
// line 3
matches = new int[game][3];
means
matches = a new 2-dimensional integer array with game*3 entries
> int next //bye
> int game //is amount of teams entered
>
>
> next = (game % 2 == 0) ? -1 :
> ((Teams)iList.get(game-1)).getNum();
> game /= 2;
> matches = new int[game][3];
>
>
what do each of these lines mean, am i
> correct. what does ?-1 mean
// ternary - means: if game 'modulus' 2 'equals' 0, set next to -1, else set next to that other expression ...
// which is the 'element (game-1)' of a 'List', cast to a 'Teams' Object, upon which the getNum() method is called ...
// which apparently is - or should be - an int.
next = (game % 2 == 0) ? -1 : ((Teams)iList.get(game-1)).getNum();
// This is the 'divide-equals' operator(s). means same as: game = game / 2
game /= 2;
// This you know right?
matches = new int[game][3];
ok brill, so
public void setNum(int x)
{
Num= x;
}
public int getNum()
{
return Num;
}
how would that connect to last line, sorry been here all day and just all over my head
> ok brill, so
> > public void setNum(int x)
> {
> Num= x;
> }
>
> public int getNum()
> {
> return Num;
> }
>
> how would that connect to last line, sorry been here
> all day and just all over my head
You mean 2nd line, or 2nd to last line? It's just what I said it returns an int. int getNum() ... returns the int value Num.