Hi - I’m struggling with Game Logic Pt 1. There isn’t a cheat sheet or a video to help for this project.
I have seen the other post regarding this project, but I still don’t understand what it is I’m meant to be writing.
This is the code I’ve written so far:
public class MainActivity {
}
// Add generateRandomNumber() here
int generateRandomNumber(int max) {
double randomNum = Math.random();
return randomNum;
}
// Add getGameOverMessage() here
}
This is step 6 - Use Math.random() to generate a random decimal value.
All Java objects have access to the built-in Math object.
And Math provides a method named random() which returns a randomly chosen double value greater than or equal to 0, but less than 1.
For example, some possible return values are 0.2312, 0, or 0.999999.
Call Math.random() within generateRandomNumber() and save it to a local variable.
and this is the following step -
Calculate a random number between 0 and max
Use the result from task 6 to calculate a random number between 0 and max (the parameter you pass into generateRandomNumber()) and save it to a local double variable.
I don't understand how they expect us to write that. I don't know if I've copied the code correctly. Any help is greatly appreciated.
THANKS!