num prod string answer prod usersEntry1getText usersEntry2getText answer The

Num prod string answer prod usersentry1gettext

This preview shows page 24 - 29 out of 644 pages.

num prod string answer prod = usersEntry1.getText() * usersEntry2.getText() answer = "The product of the numbers is ", prod result.setText(answer) screen1.add(result) return Find the Bugs Debug 12-01 // This is a Label class // It defines a label that can appear on a GUI screen class Label Declarations private string text private num horizontalPosition private num verticalPosition public void setText(string message) // setText() method requires a parameter text = message return public void setPosition(num x, num y) horizontalPosition = x verticalPosition = y // vertical position should be the second parameter 1. Your downloadable files for Chapter 12 include DEBUG12-01.txt, DEBUG12-02.txt, and D Answer :
return // setPosition() returns nothing endClass Debug 12-02 // This program creates a screen with a button. // When the user clicks the button, a label displays "Hello". start Declarations Screen screen1 Button helloButton Label helloLabel screen1.setSize(200, 200) helloButton.setText("Click to see a greeting") helloButton.registerListener(greetingMethod()) screen1.add(helloButton) // helloButton should be added to the screen helloLabel.setText("Hello") // helloLabel should not be added to the screen here // It should be added in greetingMethod() stop greetingMethod() screen1.add(helloLabel) // helloLabel should be added to the // screen when the user clicks the button return Debug 12-03 // This program creates a screen with a textbox and a button. // When the user clicks the button, a label displays the result // which is 10% of the number in the textbox start Declarations Screen screen1 Button calcButton Textbox usersEntry Label result screen1.setSize(200, 200) calcButton.setText("Click to calculate 10% tax") calcButton.registerListener(calculateTax()) // calculateTax() shoud be registered with the button screen1.add(usersEntry) screen1.add(calcButton) stop
calculateTax() Declarations Label result num tax num RATE = 0.10 string answer tax = usersEntry.getText() * RATE answer = "The tax is ", tax result.setText(answer) // answer should be added to result screen1.add(result) return Game Zone Instead of cards, you will use seven buttons labeled 1 through 7 from left to right. Randomly ass For example, a player might click Button 7, revealing a 4. Then the player clicks Button 4, revea Answer: Storyboards Screen 1 2. Your downloadable files for Chapter 12 include a file named DEBUG12-04.jpg that contain Answer : 1. Design the wireframes and storyboard, interactivity diagram, object dictionary, and any nece 1 2 3 4 5 6 7
Screen 2 Interactivity Diagram Object dictionary Script? Object name Screen number Variable s affected Screen 1 Screen 2 You win! Exit
1 1 1 1 1 1 1 1 none 1 none 1 none 1 none 1 none Button box1Butt on numbers[ ], count markBox 1(), checkWi nner() Button box2Butt on numbers[ ], count markBox 2(), checkWi nner() Button box3Butt on numbers[ ], count markBox 3(), checkWi nner() Button box4Butt on numbers[ ], count markBox 4(), checkWi nner() Button box5Butt on numbers[ ], count markBox 5(), checkWi nner() Button box6Butt on numbers[ ], count markBox 6(), checkWi nner() Button box7Butt on numbers[ ], count markBox 7(), checkWi nner() Label box1Lab el Label box2Lab el Label box3Lab el Label box4Lab el Label box5Lab el

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture