Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python question. I have uploaded a pic of the question and a pic of the python template to answer the question. Problem 2 (40 points):

Python question. I have uploaded a pic of the question and a pic of the python template to answer the question.

image text in transcribed

image text in transcribed

Problem 2 (40 points): Implement the Inventory class as demonstrated by the screenshots below. See docstrings for more info. Notes: You can decide the name of the file you want. Point break down: 10 points: Constructor, getCount, addCar, addCars, getCars, _iter__ 10 points: getCarCountByValue, getAllCarsCountByVendor, getAllCarsin Year 10 points:_contains_ __getitem__ 10 points: loadCars, save Cars >>> cars=[] >>> cars. append (Car('WW', 'Passat', 'Grey', '2001')) >>> cars.append (Car('WW', 'Bettle', 'Blue', 2005')) >>> cars.append(Car('WW', 'Bettle', 'Pink', '2009')) >>> cars.append (Car ('Ford', 'Mustang', 'Blue', '2020')) >>> cars.append(Car('Ford', 'Bronco', 'Black', '2021')) >>> cars.append (Car('Chevy','Impala', 'Silver','2011')) 11 >>> i=Inventory () >>> i.addCars (cars) >>> for cin cars: print (c) VW: Passat:Grey:2001 VW:Bettle:Blue: 2005 VW:Bettle: Pink: 2009 Ford: Mustang:Blue: 2020 Ford: Bronco:Black:2021 Chevy:Impala:Silver:2011 class Inventory(vuject: det __init__(self): constructor pass def pet Count(self): 'get count ur was in the inventory! pass dat adonar self,GAT): 'add car to inventory' pass def addCarsinull,car: adds a list of cars to the inventory. should not create a sublist!! pass dot get Cars(salt): get cars in inventory pass def getCarCount ByValue(self, prop, value): return the count of cars based on a propery propery is string Value sithat lower case (nadel, year, van dor,color). value is a string pass def HetAllCarsCountByVendor (self): returns a dictionary of wil the vendor of car in the inventory and their count pass det gat All Car Intear salt, yaar): returns a list of cars nade in a specific year pass der Liter__self): returns an iterator pass dot contains (self, nedel): 'checks if a car is in the library based on its model model is a string' pass det getiten__tself, index! : returns a car from the inventory AAN on index pass def loadCars(self): "loads the car from a file as Car objects. Clears existing cars in memory before it loads. returns True if successful and False ir nol.' pass det SAVACATS (ST): 'writes (does not append) the cars ta a filc. returns True if successful and also it nat.' pass

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

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago