... that contained multiple instances of class Craps
, they’d all share this one SecureRandom
object.
Method main
’s Local Variables
The game is reasonably involved. The player may win or lose on the first roll, or may win or lose on any subsequent roll. Method main
(lines 20–66) uses
-
local variable
myPoint
(line 21) to store the “point” if the player doesn’t win or lose on the first roll, -
local variable
gameStatus
(line 22) to keep track of the overall game status and -
local variable
sumOfDice
(line 24) to hold the sum of the dice for the most recent roll.
Variable myPoint
is initialized to 0
to ensure that the application will compile. If you do not initialize myPoint
, the compiler issues an error, because myPoint
is not assigned a value in ...
Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.