Question: Need in Python: How to you write the below specification for Automobile class from the Base Policy class and Have to run unit test for

Need in Python: How to you write the below specification for Automobile class from the Base Policy class and Have to run unit test for the methods with in the program.

Base Policy class already mentioned below.

Specifications:

AutomobilePolicy class(this will be a derived class from your Policy class)

Attributes:(we do not need to repeat the attributes of the base class here)

Number of tickets in the last three years

Number of accidents in the last three years

Age risk (a string of Low, Medium, or High)

Methods:

Constructor that receives the same parameters the Base constructor receives and as well as the values for this classes attributes. The constructor will call the base class constructor and then initialize its own attributes with the passed in values.

Get and set methods for all attributes of this class

__str__

Calls the base str method and returns a string containing labels and data for all the attributes.

CalculatePremium

Will calculate the premium and store the result in the Policy class's premium attribute based on the following:

Add an additional amount to the base premium dependent on the following:

Number of tickets is between 0-2 add $25

Number of tickets is between 3-4add $50

Number of tickets over 4 add $100

Number of accidents is between 0-1 add nothing

Number of accidents is between 2-3add $50

Number of accidents over 3 add $100

Age risk factorLow add nothing

Age risk factor Medium add $40

Age risk factor High add $120

Base Policy Class Codes:

class Policy:

def __init__(self, policyN, policyO, cadd, prem=0.0,policyD =" "):

self.policyNumber = policyN

self.policyOwner = policyO

self.premium = prem

self.policyissusancedate = policyD

self.policyowneraddress = cadd

def getPolicyNumber(self):

return self.policyNumber

def getPolicyOwner(self):

return self.policyOwner

def setPolicyNumber(self, s):

self.policyNumber = s

def setPolicyOwner(self, s):

self.policyOwner = s

def getPremium(self):

return self.premium

def setPremium(self, f):

self.premium = f

def getPolicyissusancedate(self):

return self.policyissusancedate

def getPolicyowneraddress(self):

return self.policyowneraddress

def setPolicyissusancedate(self,s):

self.setPolicyissusancedate = s

def setPoloicyowneraddress(self,s):

self.setPoloicyowneraddress = s

def __str__(self):

s ="Policy Number - "+self.getPolicyNumber()+" Policy Owner - "+self.getPolicyOwner()+" Premium - "+str(self.getPremium())+" Policy issuance date-"+str(self.getPolicyissusancedate())+" Policy holder's address -"+self.getPolicyowneraddress()

return s

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 Programming Questions!