Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab assignment, students will demonstrate the abilities to: - design objects - define classes - (create) and use objects - control accessibility to

In this lab assignment, students will demonstrate the abilities to:

- design objects

- define classes

- (create) and use objects

- control accessibility to class members

PLEASE NO BREAK STATEMENTS OR IF TRUE STATEMENTS

(Create) a Python project fly_drone.Add a Python file drone.py to this project.Define a class Drone in this file.This class has the following five methods:

(a)__init__ : (Create) two instance variables to store the speed and the height of the drone.Initialize them to 0.0. This method has no parameters other than self and no return value.

(b) accelerate : Increase the speed of the drone by 10.This method has no parameters other than self and no return value.

(c)decelerate : Decrease the speed of the drone by 10.The new speed cannot be negative.This method has no parameters other than self and no return value.

(d) ascend : Increase the height of the drone by 10.This method has no parameters other than self and no return value.

(e)descend : Decrease the height of the drone by 10.The new height cannot be negative.This method has no parameters other than self and no return value.

The following class diagram shows the design of this class:

Drone

+speed: Float

+height: Float

+Drone()

+accelerate()

+decelerate()

+ascend()

+descend()

Add a file fly_drone_main.py to this project.In this main module, (create) an instance of Drone.(Write) a loop to control the speed and height of the drone.In the loop, ask the user to enter 1 for acceleration, 2 for deceleration, 3 for ascending, 4 for descending, or 0 for exit.Call the appropriate method of the Drone object to change the speed or height of the drone.Every time the speed or height of the drone changes, display the speed and height.

The following shows a sample test run:

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 1

Speed: 10Height: 0

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 1

Speed: 20Height: 0

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 3

Speed: 20Height: 10

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 3

Speed: 20Height: 20

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 3

Speed: 20Height: 30

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 2

Speed: 10Height: 30

Enter 1 for accelerate, 2 for decelerate, 3 for ascend, 4 for descend, 0 for exit: 0

Speed: 10Height: 30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

=+3. What are five factors that cause the AD curve to shift?

Answered: 1 week ago