49.1k views
2 votes
The NumberGuess class should be a simple program with a GUI. It should contain instructions for a user should guess a number which is randomly generated in the range 1−100 inclusive.

Your program should contain the following components (use meaningful identifiers):
- A Jababl containing instructions for enter a guess.
- A JTextField that allows users to enter a guess.
- A JButton that allows users to submit a guess.
- A JButton that allows users to get a new secret number.
- A Jabel that displays the results of the previous guess.
Your program should compare the person's guess to the secret number and indicate if their guess was "too high", "too low", or "correct". Note that you should use those exact values or the unit test may not function properly.

1 Answer

2 votes

Final answer:

The NumberGuess class involves creating a GUI for a guessing game, where users guess a secret number between 1-100, using JLabels, JTextFields, JButtons, and programming logic to compare guesses.

Step-by-step explanation:

The specific task at hand is to create a NumberGuess class with a graphical user interface (GUI) for a guessing game. The program should generate random numbers between 1 and 100 and allow the user to input guesses to find the secret number. To accomplish this task, you would need to:

  • Create a JLabel to display instructions.
  • Implement a JTextField for user input.
  • Add a JButton for submitting guesses.
  • Include another JButton for generating a new secret number.
  • Use a JLabel to show results ('too high', 'too low', or 'correct').

After the guess is submitted, the program should compare the input to the secret number and display the appropriate result.

User Pedro S Cord
by
8.8k points