Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Python, A class Item has an itemcode and an amount. Below is the getter methods, setter methods and the sttring method: class Item: def

For Python,

A class Item has an itemcode and an amount. Below is the getter methods, setter methods and the sttring method: class Item: def __init__(self, itemcode, amount): self._itemcode = itemcode self._amount = amount @property def itemcode(self): return self._itemcode @property def amount(self): return self._amount @amount.setter def amount(self, amount): self._amount = amount def __str__(self): return "Itemcode: {:6s} Amount: {:4d}". format(self._itemcode, self._amount)

Create 2 user exception classes and the class Itemlist: For the 2 user exception classes, ItemExcept which is a subclass of Exception and SpecificItemExcept which is a subclass of ItemExcept. SpecificItemExcept has an instance variable: the failed item(s) and it has also a getter method to return the failed item(s). For class Itemlist, it has these below: A dictionary to record a collection of Item objects. Using Itemcode as the key in the dictionary. A search method that returns a item given the itemcode. The method reutnrs None if the item is not in the collection. An add method which adds an item into the collection when given an itemcode and an amount. Raise a ItemExcept if the item exists in the collection with a "Item exist!" message which inculde the itemcode. Or else, return the item added.

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions