For example a player might click button 7 revealing a

This preview shows page 14 - 18 out of 23 pages.

For example, a player might click Button 7, revealing a 4. Then the player clicks Button 4, revealing a 2. Then the player clicks Button 2, revealing a 7. The player loses because Button 7 is already “used.”14
You win!Exit
Interactivity DiagramObject dictionaryObject nameScreen numberVariables affectedScript?Button box1Button1numbers[], countmarkBox1(), checkWinner()Button box2Button1numbers[], countmarkBox2(), checkWinner()Button box3Button1numbers[], countmarkBox3(), checkWinner()Button box4Button1numbers[], countmarkBox4(), checkWinner()Button box5Button1numbers[], countmarkBox5(), checkWinner()Button box6Button1numbers[], countmarkBox6(), checkWinner()Button box7Button1numbers[], countmarkBox7(), checkWinner()Label box1Label1noneLabel box2Label1noneLabel box3Label1noneLabel box4Label1noneLabel box5Label1noneLabel box6Label1noneLabel box7Label1noneLabel winnerLabel2nonenoneButton exitButton2noneexitRoutine()Script// please note that numbers[] is a global num array// of size 7; it has been initialized with random values// ranging from 1 to 7// and count is a global num that has been initialized to 0public void markBox1() Declarationsnum newNumnewNum = numbers[0]box1Label.setText(newNum)box1Button.remove()15Screen 1Screen 2
numbers[0] = 0count = count + 1checkWinner(numbers, newNum)returnpublic void markBox2() Declarationsnum newNumnewNum = numbers[1]box2Label.setText(newNum)box2Button.remove()numbers[1] = 0count = count + 1checkWinner(numbers, newNum)returnpublic void markBox3() Declarationsnum newNumnewNum = numbers[2]box3Label.setText(newNum)box3Button.remove()numbers[2] = 0count = count + 1checkWinner(numbers, newNum)returnpublic void markBox4() Declarationsnum newNumnewNum = numbers[3]box4Label.setText(newNum)box4Button.remove()numbers[3] = 0count = count + 1checkWinner(numbers, newNum)returnpublic void markBox5() Declarationsnum newNumnewNum = numbers[4]box5Label.setText(newNum)box5Button.remove()numbers[4] = 0count = count + 1checkWinner(numbers, newNum)returnpublic void markBox6() Declarationsnum newNumnewNum = numbers[5]box6Label.setText(newNum)box6Button.remove()numbers[5] = 0count = count + 116
2.In the Game Zone sections of Chapters 6 and 9, you designed and fine-tuned the logicfor the game Hangman, in which the user guesses letters in a series of hidden words.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture