Question: IN PYTHON! Write another class named Inventory that will maintain a list of vehicles in inventory. The constructor should start with a Null list. Add

IN PYTHON!

Write another class named Inventory that will maintain a list of vehicles in inventory. The constructor should start with a Null list. Add the following methods to the Inventory class:

addVehicle(vehicle) : A mutator that will add the vehicle object to the inventory list

Display( ) : An accessor that will print out the vehicle information for every vehicle in the inventory. Separate each vehicle's information with two blank lines

For the Following:

#super/base class Vehicle class Vehicle: #constructor def __init__(self, make, year, model, mileage, price): self.make = make self.year = year self.model = model self.mileage = mileage self.price = price

#accessor methods def getMake(self): return self.make

def getModel(self): return self.model

def getYear(self): return self.year def getMileage(self): return self.mileage def getPrice(self): return self.price

#Display() method def Display(self): print("Make: ", self.make) print("Year: ", self.year) print("Model: ", self.model) print("Mile: ", self.mileage) print("Price: $", self.price)

#sub_class/derieved_class Car from Vehicle class Car(Vehicle): #constructor def __init__(self, make, model, year, mileage, price, doors): Vehicle.__init__(self, make, model, year, mileage, price) self.doors = doors #accessor method def getDoors(self): return self.doors

#Display() method def Display(self): Vehicle.Display(self) print("Number of doors: ", self.doors)

#sub_class/derieved_class Truck from Vehicle class Truck(Vehicle): #constructor def __init__(self, make, model, year, mileage, price, wheels): Vehicle.__init__(self,make, model, year, mileage, price) self.wheels = wheels

#accessor methods def getWheels(self): return self.wheels

#Display() method def Display(self): Vehicle.Display(self) print("Number of wheels: ", self.wheels)

#sub_class/derieved_class SUV from Vehicle class SUV(Vehicle): #constructor def __init__(self, make, model, year, mileage, price, passengers): Vehicle.__init__(self,make, model, year, mileage, price) self.passengers = passengers

#accessor methods def getPassengers(self): return self.passengers

#Display() method def Display(self): Vehicle.Display(self) print("Number of passengers: ", self.passengers)

#define the main method def main():

#create a vehicle array vehicle = []

#append five class objects of type Car, Truck, SUV vehicle.append(Car("Audi", 1987, "A6", 185000, 25000.00, 4)) vehicle.append(Car("Volkswagen", 1963, "Beetle", 240000, 50000.00, 4)) vehicle.append(Truck("Ford ", 2007, "F-150", 82000, 750000.00, 4)) vehicle.append(SUV("Chevrolet ", 2001, "Suburban ", 118000, 12000.00, 8)) vehicle.append(SUV("Kia ", 2010, "Sorento ", 29000, 25500.00, 5))

#call the Display() method of each object for i in range(len(vehicle)): vehicle[i].Display() print()

#call the main method main()

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!