Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Vehicle class Represents selected information about a vehicle. Class variables base_sale_price = 0 Instance variables Attributes: wheels: An integer representing the number of wheels the

Vehicle class

Represents selected information about a vehicle.

Class variables

base_sale_price = 0

Instance variables

"""Attributes:

wheels: An integer representing the number of wheels the car has.

miles: The integral number of miles driven on the vehicle.

make: The make of the vehicle as a string.

model: The model of the vehicle as a string.

year: The integral year the vehicle was built.

sold_on: The date the vehicle was sold.

"""

Constructor

Vehicle

arguments:

wheels, miles, make, model, year, sold_on

State change:

A new object of type Car is created.

Return:

That newly created Car object.

Methods

sale_price

No arguments

Return:

If the date is not none, Return the sale price for this vehicle by an agent as a float amount. Assume the sale price is $6000 per wheels

purchase_price

No arguments.

Return:

Return the price for which agent would pay to purchase the vehicle. The vehicle would be purchased by an agent for base_sale_price - (.10 * miles)

Now create a Car subclass and Truck subclass for Vehicle parent class.

Constructor

arguments:

wheels, miles, make, model, year, sold_on , base_sale_price

State change:

A new object is created.

Return:

That newly created object.

Implementation:

s = Truck(6, 10000, 'MTVR', '2500', 2014,12/12/12,15000)

t = Truck(6, 10000, 'MTVR', '2500', 2014,None,15000)

u = Car(4, 10000, 'Honda', 'Accord', 2014,None,10000)

v = Car(4, 10000, 'Honda', 'Accord', 2014,10/12/12,10000)

print ("Purchase price of Truck is ",s.purchase_price())

print ("Sale price of Truck is ",s.sale_price())

print ("Purchase price of Truck is ",t.purchase_price())

print ("Sale price of Truck is ",t.sale_price())

print ("Purchase price of Car is ",u.purchase_price())

print ("Sale price of Car is ",u.sale_price())

print ("Purchase price of Truck is ",v.purchase_price())

print ("Sale price of Truck is ",v.sale_price())

Now create an abstract method inside the parent class and implement in the child classes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago