Question: PLEASE WRITE CODE IN PYTHON. PROBLEM: You are writing a simple application to help Ernies Car Consignment, to keep track of his inventory. Ernie sells

PLEASE WRITE CODE IN PYTHON.

PROBLEM:

You are writing a simple application to help Ernies Car Consignment, to keep track of his inventory. Ernie sells cars and truck for their owner. The following diagrams describe the classes you will need for this project.

Vehicle

manufacturer

engineSize

owner

desiredPrice

__init__(manu, esize, name, price)

__str__()

setManu(manu)

setEng(esize)

setOwner(name)

setPrice(price)

getManu()

getSize()

getOwner()

regCost() #returns desiredPrice

totalCost()

^ ^

| | | | |

| |

Truck

Car

LoadCapacity

TowCapacity

Door

__init__(manu, esize, name, load, tow)

__str__()

setLoad(load)

setTow(tow)

getLoad()

getTow()

regCost() # returns selling price

__init__(manu, esize, name, doors)

__str__()

setDoor(door)

getDoor()

regCost() # returns selling price

Part I

You will first need to code Person, Vehicle, Car and Truck class. As you can see, Vehicle is the base class from which the Truck and Auto classes inherit. The two derived classes describe two types of Vehicle. Note that the owner field is of class Person described by the diagram:

Person

Name

__init__(name = Nobody)

__str__()

setName(name)

getName()

The Vehicle class provides a constructor which initializes its instance data variables, in addition to accessor methods for each instance variable. Each of the subclasses provide additional data members specific to the type of Vehicle, plus additional methods needed to maintain the object. The desiredPrice is the price that the owner wants for the Vehicle.

Each of these classes provides a specific regCost method to compute the price the vehicle. Ernies pricing works as follows: each vehicle cost computation begins with the amount the owner wants for the vehicle. Ernie then adds 33% if it is a Car and 25% if it is a Truck. The totalCost for any vehicle is its regCost plus tax, which is 8.25%.

Part II

You are to write an application that will allow the user to store vehicle information. Your program should allow the user to do any of the following, until the user decides to exit.

enter a new Car

enter a new Truck

print out all Cars currently stored

print out all Trucks currently stored

accept a price as input, and output all Cars which are available under that price (before tax)

accept a price as input, and output all Trucks which are available under that price (before tax)

accept a price as input, and output all vehicles which are available for that price (before tax)

accept a car manufacturer, and output all Vehicles which are made by that manufacturer

Each object created must be stored for the remainder of the program, so you must have ONE list to store all vehicles.

I STARTED THE CODE BUT I NEED HELP PLEASE!

CODE:

class Person: def __init__(self, name = "No Name"): self.name = name def __str__(self): return self.name

def setName(self, name): self.name = name

def getName(self): return self.name

# add the Vehicle class definition here # add the Car class definition here # add the Truck class definition here

def addCar(): print("Please enter car info:") manu = input("Manufacturer: ") owner = input("Owner: ") engineSize = input("Engine Size: ") desiredPrice = input("Price: ") # add remaining code

def addTruck(): # remove pass statement and add code here pass

def printCars(): # remove pass statement and add code here pass

def printTrucks(): # remove pass statement and add code here pass

def printCarPrice(): # remove pass statement and add code here pass

def printTruckPrice(): # remove pass statement and add code here pass def printAllPrice(): # remove pass statement and add code here pass

def printVehicleManu(): # remove pass statement and add code here pass def main(): carList = [] more = True

while more: print("Welcome to Ernie's Car Consignment Program.") print("(1) Enter a new car") print("(2) Enter a new truck") print("(3) Print out all cars currently stored") print("(4) Print out all trucks currently stored") print("(5) Print out all cars avalaible under the entered price") print("(6) Print out all trucks avalaible under the entered price") print("(7) Print out all vehicles avalaible under the entered price") print("(8) Print out all vehicles made by the entered manufacturer") print() choice = input("Please enter your choice (1-8): ") if choice == "1": addCar() elif choice == "2": addTruck() elif choice == "3": printCars() elif choice == "4": printTrucks() elif choice == "5": printCarPrice() elif choice == "6": printTruckPrice() elif choice == "7": printAllPrice() elif choice == "8": printVehicleManu() else: more = False

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!