Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
Question
Book Icon
Chapter 10, Problem 7PE
Program Plan Intro

Rolling the dice

Program Plan:

CButton.py:

  • Import the required packages.
  • Definition of “__init__” method.
    • Get the x and y position
    • Set the center and radius value.
    • Create a circle and radius.
    • Call the method “draw()”.
    • Assign the label.
    • Call the method “draw()”.\
  • Add the method “getLabel()”, “activate()”, “deactivate()” from the “button.py” module.
  • Define the “clicked()” method.
    • Return “true” if button is active and “p” is inside.

roller.py:

  • Import the required packages.
  • Definition of main.
    • Create the application window.
    • Draw the interface widgets.
    • Create button “Roll Dice”.
    • Activate the button.
    • Create button “Quit”.
    • Call the method “getMouse()”.
    • Check the condition if the button is clicked.
      • Roll the die.
      • Call the activate method for quit button.
      • Call the “getMouse()”.
    • Close the window.
  • Call the main function.

Blurred answer
Students have asked these similar questions
PLEASE ENSURE TO USE THE FRAMEWORK PROVIDED IN THE IMAGES, AND THAT IT WORKS WITH THE TESTER CLASS. Write a class RangeInput that allows users to enter a value within a range of values that is provided in the constructor. An example would be a temperature control switch in a car that allows inputs between 60 and 80 degrees Fahrenheit. The input control has “up” and “down” buttons. Provide up and down methods to change the current value. The initial value is the midpoint between the limits. As with the preceding exercises, use Math.min and Math.max to limit the value. Write a sample program that simulates clicks on controls for the passenger and driver seats.
Create a VisualCounter class that supports both increment and decrement operations. Take the constructor inputs N and max, where N indicates the maximum number of operations and max specifies the maximum absolute value for the counter. Create a plot that shows the value of the counter each time its tally changes as a side effect.
This is for pygame Text Class The Text class inherits from Drawable and it will be used to display the player’s score. You must implement at the very least the required methods of the base class (draw and get_rect), as well as a constructor. You may need to implement other methods as part of the public interface. This is the Drawable Class
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education