Question: Topics: class, method, object instantiation, inheritance, print Problem Statement: In this assignment, you will design one child class 'MountainBike' of a parent class 'Bicycle'. The

 Topics: class, method, object instantiation, inheritance, print Problem Statement: In this

assignment, you will design one child class 'MountainBike' of a parent class

'Bicycle'. The purpose of this lab is to gain experience in python's

Topics: class, method, object instantiation, inheritance, print Problem Statement: In this assignment, you will design one child class 'MountainBike' of a parent class 'Bicycle'. The purpose of this lab is to gain experience in python's basic inheritance lass Definition: Bicycle Class (Parent class This class will have following instance variables and methods. Most Definition is provided in the template file. Attribute name/Instance varibales gear speed Data type Description int float Gear number includes 1-3 Speed of the cycle in mile per hour Method name Parameter gear, speed decrement Return type Description Initialize the instance attributes Decrease the speed by 'decrement variable init none applyBrake none Increase the speed by increment variable speedUp increment none Your Task: Design a MountainBike Class (Child class) with the following instance variables and methods Attribute name/Instance variables gear speed seatHeight Data type int float float Description Gear number includes 1-3 Speed of the cycle in mile per hour Height of the seat in cm Method name Parameter gear, speed, seatHeight none Return type none string Description Initialize the instance attributes Returns the current information of object. See sample lI/O Set the seatHeight to 'newValue' init str setHeight newValue none Object Creation/Instantiation: You need to create two objects m1' and 'm2' of 'MountainBike, class. Sample code has been provided in the template file. Sample output Object m1 No of gear: 3 Current speed: 10 Current seat height: 100 Object m2 No of gear: 2 Current speed: 5 Current seat height: 90 No of gear: 2 Current speed: 5 Current seat height: 76 class Bicycle (object): #parent class def _init__(self, gear, speed): self.geargear self. speed = speed def applyBrake (self, decrement): self.speed -decrement def speedUp (self, increment): #your code here #same as applyBrake #increase the speed by increment class MountainBike (Bicycle): def _init__(self, gear, speed, seatHeight): #your code here #super() call to invoke parents init method- gear and speed com #initialize seatHelght - an added attribute of child class def setHeight (self, newvalue): #an added meth d of child class #your code here #set the seatHelght to newvalue def-str-(self): #a method to print object for child #your code here #return a string #see sample I/O #object creation m1MountainBike (3, 10, 100) m2MountainBike (2, 5, 90) print (m1) print (m2) m2.setHeight (76) #reset the value of seatHeight print (m2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!