trying to make a program(game) for two players. the game has an interface and three text fields "player1","player2", and "winning amount". the interface also has a button called rand which when pressed generates random numbers from 1 to 10 and assigns them to a particular field. assuming that the first player to click rand is player1 and the second is player2. the game should end when two consecutive numbers generated are the same. the sum of all the generated numbers should be added and sent to the winning amount text field. there is also a clear button which resets the text fields for starting a new game. please help me with code am a beginner in java.
Jump to Post
Be more than happy to help you. Once you show us what you have. We are not going to do it for you, though.
You need, JFrame, JLabel, JTextField, JButton, GridLayout (as the easiest), ActionListener, and Random.
Jump to Post
And? What's it doing?
Are you getting compiler messages?
Are you getting an exception?
Are you seeing an unexpected effect?
In short, what is wrong?
Post the complete messages, and, if it's the third, a complete description of what you expect and a complete description …
All 10 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.