Question: Python code Define a class Cars, that has the properties describing the make, model, power and displacement, luxury (a Boolean value indicating whether a car
Python code
Define a class Cars, that has the properties describing the make, model, power and displacement, luxury (a Boolean value indicating whether a car is a luxury one), gas (indicating the gasoline left in the tank), MPG (miles per gallon). These properties are not directly accessible, but you have to write methods to GET or SET the values for each property. In addition, write methods to capture the following behavior of a car:
-You can add gasoline to a car by certain gallons
-You can run a car for certain number of miles, which will consume gasoline based on the MPG of the car
-You can figure out how many miles the car can run based on the gasoline left in the tank.
-Write a constructor (in the Cars class) that allows you to construct a Car object given information about its make, model, power, displacement, and luxury.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
