Re: A little help please =D
In the future, could you please surround your code in CODE tags, such as the ones found in my signature.
Is there a reason you don't want to use loops? As It will tidy up your code a lot more than if you were to go down the route of ifs.
By using a loop, it can endlessly re-prompt the user for an answer by sticking to a single true/false condition, whereas if's get messy.
Also be sure to always surround your if, if-else blocks with braces as It shows the execution path clearer and makes the code easier to read.
Additionally, look into the Random class from the Java API, specifically nextInt(int n) to generate a random number, as your approach could generate zeros as well.
Re: A little help please =D
The only reason why I don't want to use a loop is because my teacher doesn't want us to use a loop. =(
I barely joined this website today and I am still getting use to it. When I paste my code in do I put [*Code in here*] in those brackets so everyone knows which is part of the code?
Re: A little help please =D
On General note whenever you write Game there is suppose to be a Game thread which is an while loop continuously running until game is over or stopped, in this loop you check condition, take action and forward the game. you probably would like to structure your program like that.
Re: A little help please =D
Quote:
Originally Posted by
valenciajv
The only reason why I don't want to use a loop is because my teacher doesn't want us to use a loop. =(
I barely joined this website today and I am still getting use to it. When I paste my code in do I put [*Code in here*] in those brackets so everyone knows which is part of the code?
At the end and beginning of your code, example
I did this, without the spaces
[ code]
your code here
[/code ]
It's hard to read your code with out that, if you put it in the correct format perhaps I could help.