Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
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
Write a modified Button class that creates circular buttons. Call your class CButton and implement the exact same methods that are in the existing Button class. Your constructor should take the center of the button and its radius as normal parameters. Place your class in a module called cbutton . py. Test your class by modifying roller . py to use your buttons.
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