Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Goal: Implement and test the Vehicle class as shown in the Vehicle/Automobile UML Diagram. Relevant Examples: Person Pet Card Details: Implement the Vehicle class in

  • Goal: Implement and test the Vehicle class as shown in the Vehicle/Automobile UML Diagram.
  • Relevant Examples: Person Pet Card
  • Details:
    1. Implement the Vehicle class in the module vehicle.py as specified by the Vehicle/Automobile UML Diagram.
    2. The __init__ method should validate its inputs:
      1. before assigning the vin to the instance variable, convert to upper case, then remove all non letters and digits;
      2. year should not be later than the current_year. If year > current_year, set year to current_year
      3. set sales_tax_paid to False;
      4. The is_sales_tax_paid method returns "Yes" if the value of self.sales_tax_paid, "No" otherwise;
      5. The pay_sales_tax method sets self.sales_tax_paid to True.
    3. Write the traditional test script test1.py and the unit test script test2.py that test all of the instance variables and methods in the Vehicle class. Test these instance members in this suggested order:
      __init__ __str__ __repr__ vin year color owner is_sales_tax_paid pay_sales_tax 
    4. Test all possibilities of method inputs. For example, for the vin field, test cases such as A3847V, which have no non-letter or non-digit characters, and AV#S38$@47, which contains the non-letteron-digit characters #$@. AV#S38$@47 should be changed to AVS3847 before assigning it to the instance variable. For the year field, test at least one year less than current_year and at least one year that is greater than current_year Compute current_year as
      import datetime current_year = datetime.datetime.now( ).year 
    5. After you finish test1.py, convert it to the unit test file test2.py. Use the outputs from test1.py to guide you.
    6. Write a script test3.txt that loads the the data from vehicles.txt into a list of Vehicle objects, the prints the resulting list like this:
      for v in vehicles: print(v)
vin, year, color, owner R7682T,2011,red,Ted Z5211W,2015,silver,Elaine M1032F,2018,gold,susan S0987F,2017,black,Fred N3128B,2017,black,Fred N3129B,2020,white,Oscar U3813W,2013.blue,Stephanie C4921Y,2015,red,Morgan D5019H,2019,yellow,William R1235T,2017,silver,Alice W9632D,2019,green,Mary

image text in transcribed

Vehicle + vinstr + year: int + color: str + owner: str - sales_tax_paid: bool _init__(vin: str, year: int color: str, owner: str) + is_sales_tax_paid(): bool + pay_sales_tax() _str_0 : str Automobile + make: str + model : str + num_cylinders: int + horse_power: double + miles : int + accessories : str[l + __init__(vin: str, year:int, color: str, make: str, model : str, num_cylinders: int, horse_power: double, miles: int) + add_miles(the_miles : int) + add_accessory(the_item: str) _str_0:str _repr_0:str -_Il_0:bool Vehicle + vinstr + year: int + color: str + owner: str - sales_tax_paid: bool _init__(vin: str, year: int color: str, owner: str) + is_sales_tax_paid(): bool + pay_sales_tax() _str_0 : str Automobile + make: str + model : str + num_cylinders: int + horse_power: double + miles : int + accessories : str[l + __init__(vin: str, year:int, color: str, make: str, model : str, num_cylinders: int, horse_power: double, miles: int) + add_miles(the_miles : int) + add_accessory(the_item: str) _str_0:str _repr_0:str -_Il_0:bool

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

How are budgets used as monitoring and control tools?

Answered: 1 week ago