that you studied and learned in your previous classes. In this assignment, you w
ID: 3875351 • Letter: T
Question
that you studied and learned in your previous classes. In this assignment, you will implement the classic word guessing game Hangman. The user interface of the game is shown below. You are required to implement the game with exact functional and user interface specifications. The "File" and "Help" menu choices are not important. Upon start of the application, user shall see following screen. Basic Application Example File Help Welcome to Hangman CR-1 Start Game Go to screen 2 Game is still not started. The keyboard is inactive in this mode. "XXXX... Indicates that no word is ready to be guessed. Pressing the "Start Game" button, game will move to playing mode. The game will select a random word less then 16 character long andExplanation / Answer
JButton start = new JButton("Start Game");
// add the listener to the jbutton to handle the "pressed" event
start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Random rnd = new Random();
for (int i = 0; i < charString.length; i++) {
charString[i] = (char) (rnd.nextInt(26) + 'a');
}
char guessHelp[] = Arrays.copyOf(charString, charString.length);
for (int i = 0; i < (charString.length / 2); i++) {
guessHelp[rnd.nextInt(15)] = '*';
}
// now set the jlabel to guessHelp and math the string received from text field against charString
}
});
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.