Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UPDATE: above pic is the template Python problem. The out put should resemble the sample pics above any questions feel free to ask. Response to

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

UPDATE: above pic is the template

Python problem. The out put should resemble the sample pics above any questions feel free to ask.

Response to your comment: I don't know how you want the template as opposed to a pic of it?

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 >>> c=Car('Porsche','911', 'White', '2021') >>> i.addCar (c) >>> for item in i: print (item) VW: Passat:Grey: 2001 VW: Bettle:Blue: 2005 VW:Bettle: Pink: 2009 Ford:Mustang:Blue: 2020 Ford: Bronco:Black: 2021 Chevy: Impala: Silver:2011 Porsche: 911: White:2021 >>> i.SaveCars () True 1 Inventory.txt file contents: inventory - Notepad File Edit Format View Help WW:Passat:Grey: 2001 VW:Bettle:Blue: 2005 VW:Bettle:Pink: 2009 Ford Mustang: Blue: 2020 Ford: Bronco:Black: 2021 Chevy: Impala: Silver:2011 Porsche: 911: White: 2021 100% Windows (CRLF) UTF-8 Restart the Inventory and load the cars from the file: >>> i=Inventory () >>> i.loadCars () True >>> for c in i: 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 Porsche: 911:White: 2021 >>> print(i.getAllCarsCountByVendor ()) {'V': 3, 'Ford': 2, 'Chevy': 1, 'Porsche': 1} >>> >>> >>> cars=i.getAllCarsInYear('2021') >>> for cin cars: print(c) Ford: Bronco:Black: 2021 Porsche: 911: White: 2021 >>> print(i.getAllCarsCountByVendor()) { 'VW': 3, 'Ford': 2, "Chevy': 1, "Porsche': 1} 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 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 >>> c=Car('Porsche','911', 'White', '2021') >>> i.addCar (c) >>> for item in i: print (item) VW: Passat:Grey: 2001 VW: Bettle:Blue: 2005 VW:Bettle: Pink: 2009 Ford:Mustang:Blue: 2020 Ford: Bronco:Black: 2021 Chevy: Impala: Silver:2011 Porsche: 911: White:2021 >>> i.SaveCars () True 1 Inventory.txt file contents: inventory - Notepad File Edit Format View Help WW:Passat:Grey: 2001 VW:Bettle:Blue: 2005 VW:Bettle:Pink: 2009 Ford Mustang: Blue: 2020 Ford: Bronco:Black: 2021 Chevy: Impala: Silver:2011 Porsche: 911: White: 2021 100% Windows (CRLF) UTF-8 Restart the Inventory and load the cars from the file: >>> i=Inventory () >>> i.loadCars () True >>> for c in i: 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 Porsche: 911:White: 2021 >>> print(i.getAllCarsCountByVendor ()) {'V': 3, 'Ford': 2, 'Chevy': 1, 'Porsche': 1} >>> >>> >>> cars=i.getAllCarsInYear('2021') >>> for cin cars: print(c) Ford: Bronco:Black: 2021 Porsche: 911: White: 2021 >>> print(i.getAllCarsCountByVendor()) { 'VW': 3, 'Ford': 2, "Chevy': 1, "Porsche': 1} 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

More Books

Students also viewed these Databases questions

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago