Question: python Program Specifications Write a FancyCar class to support basic operations such as drive, add gas, honk horn and start engine. fancy _ car.py is
python Program Specifications Write a FancyCar class to support basic operations such as drive, add gas, honk horn and start engine.
fancycar.py is provided with function stubs. Follow each step to gradually complete all instance methods.
Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main program includes basic calls to the instance methods. Add statements in the main program as instance methods are completed to support development mode testing.
Step : Complete the constructor to initialize the model and miles per gallon MPG with the values of the parameters. Initialize the odometer to five miles and the tank to be full of gas. By default, the model is initialized to "Old Clunker", and MPG is initialized to Note the provided constant variable indicates the gas tank capacity of gallons.
Step pts Complete the instance methods to check the odometer, check the gas gauge, get the model, and get the miles per gallon. Submit for grading to confirm tests pass.
Step pt Complete the honkhorn instance method to output the following statement with the car model:
The Honda Civic says beep beep!
Submit for grading to confirm tests pass.
Step pt Complete the drive instance method. Miles driven should increase by the distance parameter, and amount of gas should decrease by distance MPG Attributes are updated only if distance is positive. Submit for grading to confirm tests pass.
Step pts Complete the addgas instance method. Increase gas tank by the amount parameter only if amount is positive, up to a maximum of FULLTANK. Submit for grading to confirm tests pass.
Step pts Update drive to determine if the car runs out of gas. If so the parameter distance will not be achieved and the gas tank will have gallons. Ex: drive will not be possible with only three gallons of gas and MPG of The maximum driving distance is miles with three gallons of gas and MPG of Therefore, the odometer will only increase by instead of the requested and the gas tank will have gallons not a negative amount Submit for grading to confirm tests pass.
Step pts Add a boolean attribute to indicate if the car engine is on or off. Complete the the startengine instance method to set the boolean attribute to True. Complete the stopengine instance method to set the boolean attribute to false. Update the constructor to start with the engine off. Update drive to only update attributes if the engine is on and the engine turns off if the car runs out of gas. Update addgas to only add gas if the engine is off. Submit for grading to confirm all tests pass.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
