Java Slot Machine Gui Code
Hi there, as one of my first programs in java, I thought I will do a simple (!) lottery program...needless to say it doesn't compile, and after looking at it for quite awhile trying to unsuccessfully spot the error (I am not sure how to debug in netbeans, any advice on that very welcome too of course) I thought that it is time for some help. here's the program (compiled with netbeans):
What the code is supposed to do is create a 3 reel, 6 icon slot machine in two classes that utilize objects that, when ran, will say something like 'spin x: orange grape cherry, you lost' It will keep running until you win. To win, you have to have all 3 reels be the same ex.' Spin x: cherry cherry cherry, you won' and then stop running. 18+ T&C Apply – To receive the welcome bonus a minimum deposit of £/€/$ 10 is required. The minimum deposit for other offers that require a deposit will be clearly communicated. Maximum bonus offered will be communicated in the details of each specific Java Slot Machine Gui Code promo.
SO the idea behind this is that the computer generates 6 random number in the range of 1 to 49, and store them in an array, the user inputs his own 6 guesses, stores them into an array, then each entry is compared to what the computer has stored and for each right guess the counter is incremented by 1. If the counter is 6 then you win, if not you lose.
Now, netbeans is giving me some strange errors and warnings:
1) with this import java.util.Scanner;
it says thatthis doesn't correspond to the specified code style...?!
2)here int randomNums = new Random().next(49) + 1;
it tells me that next(Int) has protected access, whatever that means;
3) at the else
level it says: 'else' without 'if'...ehm?!
4) at counter+=1;
it says variable counter might not have been initialised
5) the last }
says 'class, inteface or enum expected'
Any idea what I have done wrong? Please take in consideration that as I said I am very new to Java
thanks
- 2 Contributors
- forum5 Replies
- 10,044 Views
- 4 Days Discussion Span
- commentLatest PostLatest Postby Violet_82
Recommended Answers
I found these compilation problems
Jump to PostJava Gui Programs
@Violet_82
There is no problem.
The first value being printed is the user entered value from key board ( which is the the input from user to program).
The second value is from printed from code/program .
Have a look at lines 35 to 37