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 16PE
Program Plan Intro

Adding “Target” class to Cannonball animation

Program Plan:

Tracker.py:

  • Import the required packages.
  • Definition of class “Tracker”.
    • Condition to show the ball in the window.
    • Create an object to report the current position.
    • Condition to track the X and Y position.
    • Calling the Point using the position.
    • Determining the size.
    • Call the method Circle.
  • Definition of method “initializeTracker ()”.
    • Get the size of the ball.
    • Setting the color of the ball.
    • Draw the window.
  • Definition of method “move”.
    • Tracking the current position.
    • Call the method Point by passing the parameter.
    • Call the method “initializeTracker()”.
  • Definition of “getPosition()”.
    • Return the center value

Main.py:

  • Import the require packages.
  • Definition of method “main()”.
    • Create an interface.
    • Call the method “Tracker()”.
    • Create the button “X”.
    • Activate the button.
    • Call the “Point()” by passing the arguments
    • Check the condition whether the “target” is clicked.
      • Call the update method.
      • Get the “x” and “y” position.
      • Move the ball.
      • Print the current position.
      • Check whether “dy” is less than 0.
        • Print the angle, velocity, initial height.
  • Call the main method.

Blurred answer
Students have asked these similar questions
Challenge (3 marks): Make the program animate the tour. The program should show the salesman starting from the first city and smoothly moving between all the cities leaving the tour as a trail behind them until they reach the last city and return back to the first one. You can loop this animation if you wish. in javascript
Create the VisualCounter class, which supports both increment and decrement operations. Take the constructor's two arguments N and max, where N indicates the maximum operation number and max specifies the counter's maximum absolute value. Make a plot that displays the value of the counter each time its tally changes as a byproduct.
Subject Name: Advanced Object-Oriented Programming 2. Write a JAVA GUI code to create the following: Use the Suitable layout and panel to show the below described output • The Frame is Titled as "MyFrame". • Add the title in the JPanel as Text Area and insert 2 colored radio buttons on selecting each button the color of the frame should change between two colors • Add two Text Field by name with title "Me"and "MyFriend" • Add Two buttons down which must copy the text from text1 to text 2 on pressing it and the other should clear the content. • Names of the Button "Print Text", "Cancel"
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    CMPTR
    Computer Science
    ISBN:9781337681872
    Author:PINARD
    Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage