Can't declare variables not in main?
All of my variables in Main and playLottery have the error line underneath them. How come
5 Replies
the problem is that they are instance variables of
Program
it means you need an instance of Program
to access them
e.g. new Program().r
and you could of course make multiple different instances of Program
, which all have different values, which is probably not what you wantah so make them static
yes, that one one way to fix it
sweet ty
One pattern I really like for making games like this is a game instance
Could easily make the game replayable too, and make resetting the game state super easy