yay last min uni work part 2.... I need help

jcb33 said:
Im currently trying to scan grid 2 for any number over 0, and each time it finds a number over 0 to add one to the "Uncovered" score but Im not doing very well

This:
for(int x=0;x<7;x++){
for(int y=0;y<8;y++){

if(grid2[x][y]>0);
uncovered++;

}
}
Not that I've actually written any Java code in the last 5 years, but I think you might want to check the correct syntax for an "if" statement.

vonhelmet said:
You're making the array too complicated. There's no need to make one 56 length array. Can you imagine the work in parsing that to generate the output?
In C: int i, b[56]; for(i=0;i<56;i++)printf("%c%s"," " *£"[b<3 ? b : 0],i%8==0?"\n":""); :D

(Not a terribly serious suggestion, but 1D arrays are often actually a good choice for these things if efficiency matters and you know what you're doing).
 
== Compares the references (I.e if they both refer to the same string object on the heap). .equals() is what you wish to use to compare string literals as you say.
 
Currently im trying to get the game to replay... at the beginging of my code I have:


and near the end My replay code is:


I realy cannot see how to get it to loop back ground to the beginging though
 
Last edited:
Best way to do is is to have a game loop.

while (!gameOver)
{
// Do some stuff
}

Then when its game over you just set gameOver to true and your program terminates.

and obviously your missing a semicolon on play();

:)
 
Rossmac said:
your call to method play() must be followed by a semi-colon to make it a legal statement.

ie.

play();
Added ; But now I cant launch the program at all

Code:
 
Last edited:
Una said:
Best way to do is is to have a game loop.

while (!gameOver)
{
// Do some stuff
}

Then when its game over you just set gameOver to true and your program terminates.

and obviously your missing a semicolon on play();

:)
That could be usefull save the fact that i want the game to replay, not terminate if the user selects replay
 
jcb33 said:
That could be usefull save the fact that i want the game to replay, not terminate if the user selects replay

Yeah then you have a switch/if statement somelogic inside your loop.

Different methods to display different bits of text....

One method that restarts the game etc...

When you want to replay you just call your play method again.
 
guys i've got a 2000 word essay on gibbon's the fall of rome i need it in for next week

12pt times new roman double spaced

thanks guys you'd better make it good
 
Una said:
Yeah then you have a switch/if statement somelogic inside your loop.

Different methods to display different bits of text....

One method that restarts the game etc...

When you want to replay you just call your play method again.

I have no idea how I would go about that :/
 
Back
Top Bottom