Question

Python programming I need help with the following: Create a class Vehicle. The class should have...

Python programming I need help with the following:

Create a class Vehicle. The class should have name, weight, fuel, number of wheels and move attributes/methods. Create child class that are semi, car, sail boat and bicycle. Give the class the ability to have a constructor that sets the name. Have the other attributes hard coded to suit the vehicle. Give each a way of speaking their attributes as well as the type of animal. For example “Hi I am Lightening McQueen the race car, I use extra special fuel have four wheels, weigh 2000 lbs and speed from place to place”. Create a call to instantiate one of each child.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Vehicle(object): # no instance of this class should be created

def __init__(self, typ, make, model, color, year, miles):
self.typ = typ
self.make = make
self.model = model
self.color = color.lower()
self.year = year
self.miles = miles

def vehicle_print(self):
print('Vehicle Type: ' + str(self.typ))
print('Make: ' + str(self.make))
print('Model: ' + str(self.model))
print('Color: ' + str(self.color))
print('Year: ' + str(self.year))
print('Miles driven: ' + str(self.miles))


class GasVehicle(Vehicle):

def __init__(self, fuel_tank, *args):
self.fuel_tank = fuel_tank
Vehicle.__init__(self, *args)

def vehicle_print(self):
Vehicle.vehicle_print(self)
print('Fuel capacity (gallons): ' + str(self.fuel_tank))


class ElectricVehicle(Vehicle):

def __init__(self, energy_storage, *args):
self.energy_storage = energy_storage
Vehicle.__init__(self, *args)

def vehicle_print(self):
Vehicle.vehicle_print(self)
print('Energy Storage (Kwh): ' + str(self.energy_storage))


class HeavyVehicle(GasVehicle): # no instance of this class should be created

def __init__(self, max_weight, wheels, length, *args):
self.max_weight = max_weight
self.wheels = wheels
self.length = length
GasVehicle.__init__(self, *args)

def vehicle_print(self):
GasVehicle.vehicle_print(self)
print('Maximum load (tons): ' + str(self.max_weight))
print('Wheels: ' + str(self.wheels))
print('Length (m): ' + str(self.length))


class ConstructionTruck(HeavyVehicle):

def __init__(self, cargo, *args):
self.cargo = cargo
HeavyVehicle.__init__(self, *args)

def vehicle_print(self):
HeavyVehicle.vehicle_print(self)
print('Cargo: ' + str(self.cargo))


class Bus(HeavyVehicle):

def __init__(self, seats, * args):
self.seats = seats
HeavyVehicle.__init__(self, *args)

def vehicle_print(self):
HeavyVehicle.vehicle_print(self)
print('Number of seats: ' + str(self.seats))


class HighPerformance(GasVehicle): # no instance of this class should be created

def __init__(self, hp, top_speed, *args):
self.hp = hp
self.top_speed = top_speed
GasVehicle.__init__(self, *args)

def vehicle_print(self):
GasVehicle.vehicle_print(self)
print('Horse power: ' + str(self.hp))
print('Top speed: ' + str(self.top_speed))


class SportCar(HighPerformance):

def __init__(self, gear_box, drive_system, *args):
self.gearbox = gear_box
self.drive_system = drive_system
HighPerformance.__init__(self, *args)

def vehicle_print(self):
HighPerformance.vehicle_print(self)
print('Gear box: ' + self.gearbox)
print('Drive system: ' + self.drive_system)


bmw = GasVehicle(30, 'SUV', 'BMW', 'X5', 'silver', 2003, 120300) # regular car
bmw.vehicle_print()
print
tesla = ElectricVehicle(85, 'Sport', 'Tesla', 'Model S', 'red', 2014, 1243) # electric car
tesla.vehicle_print()
print
lambo = SportCar('manual', 'rear wheel', 650, 160, 23, 'race car', 'Lamborgini', 'Enzo', 'dark silver', 2014, 3500) # sportscar
lambo.vehicle_print()
print
truck = ConstructionTruck('cement', 4, 12, 21, 190, 'transport', 'Dirt Inc.', 'Dirt Blaster 100', 'blue', 1992, 120030) # Construction truck
truck.vehicle_print()

Add a comment
Know the answer?
Add Answer to:
Python programming I need help with the following: Create a class Vehicle. The class should have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Vehicle Inheritance USE PYTHON TO WRITE THE CODES. Create a Vehicles class that holds instances of...

    Vehicle Inheritance USE PYTHON TO WRITE THE CODES. Create a Vehicles class that holds instances of cars; this class is completely separate from the Car class. In other words, the Car class does not inherit from the Vehicle class. Then assign three car instances to an instance of the Vehicle class. Your output should look like this: I have 3 cars: The Mercedes is a black suv. The BMW is a silver sedan. The ferrari is a red supercar ....

  • Part I: Create a program class named TestArrays This class should have a main() method that...

    Part I: Create a program class named TestArrays This class should have a main() method that behaves as follows: Create an integer array of size 10. Using a loop, fill the elements with increments of 5, starting with 5 in the first element. Using the array elements, sum the second, fifth and seventh elements. Display the sum with a label. Change the fourth element to 86. Subtract 9 from the ninth element. Using a loop, display the elements of the...

  • Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a...

    Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a float Speed and string Name, an abstract method Drive, and include a constructor. Create a Tesla class - Tesla inherits from Vehicle. - Tesla has an int Capacity. - Include a constructor with the variables, and use super to set the parent class members. - Override Drive to increase the speed by 1 each time. - Add a toString to print the name, speed,...

  • Python 3 Problem: I hope you can help with this please answer the problem using python...

    Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks! Code the program below . The program must contain and use a main function that is called inside of: If __name__ == “__main__”: Create the abstract base class Vehicle with the following attributes: Variables Methods Manufacturer Model Wheels TypeOfVehicle Seats printDetails() - ABC checkInfo(**kwargs) The methods with ABC next to them should be abstracted and overloaded in the child class Create three...

  • 10q I need help this is a python language For the following question, refer to the...

    10q I need help this is a python language For the following question, refer to the Python module on the right, as well as the name of the file that contains each module. 1) What is the output of the following code?. import animals alist = [animals.cat('Garfield'), animals.Dog('odie'), animals. Fox ('Nicholas P. wilde'), animals. Animal ('Judy Hopps')] File animals.py class Animal: def _init__(self, name): self.name = name def getName(self): return self.name for a in alist: print( a.getName() + ', '...

  • C++ HELP! Create a class and name it Payslip. This class should have the following attributes...

    C++ HELP! Create a class and name it Payslip. This class should have the following attributes or properties: name, pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. Define the accessors and mutators of the Payslip class based on its attributes or properties. This class should also have the following methods: determinePayGradeAndTaxRate and computePay. Create another class and name it Employee. This class will contain the main method. In the main method, instantiate an...

  • I need this in java please Create an automobile class that will be used by a...

    I need this in java please Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class: private string make private string model private string color private int year private int mileage. Your program should have appropriate methods such as: default constructor parameterized constructor add a new vehicle method list vehicle information (return string array) remove a vehicle method update vehicle attributes method. All methods...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • I have a java class that i need to rewrite in python. this is what i...

    I have a java class that i need to rewrite in python. this is what i have so far: class Publisher: __publisherName='' __publisherAddress=''    def __init__(self,publisherName,publisherAddress): self.__publisherName=publisherName self.__publisherAddress=publisherAddress    def getName(self): return self.__publisherName    def setName(self,publisherName): self.__publisherName=publisherName    def getAddress(self): return self.__publisherAddress    def setAddress(self,publisherAddress): self.__publisherAddress=publisherAddress    def toString(self): and here is the Java class that i need in python: public class Publisher { //Todo: Publisher has a name and an address. private String name; private String address; public Publisher(String...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT