Question: python Docs needed: https://drive.google.com/open?id=1QQhlp-kQDNIESen61fVanpLoApl51YaK 1. 25 Points: Write a class Bag that represents a collection of items. You must write the entire class yourself. A


python
Docs needed:
https://drive.google.com/open?id=1QQhlp-kQDNIESen61fVanpLoApl51YaK
1. 25 Points: Write a class Bag that represents a collection of items. You must write the entire class yourself. A template is not included in the py file, you must create the Bag class and Iterator yourself. The class supports six methods Bag Class: a init O which takes an optional parameter representing the maximum amount of items that can be stored in the locker. It sets the maximum size of the collection to the vided value or to the value 10 if no number is given as a parameter. It also creates an empty list to store the items in the collection but does not allow passing a list via the constructor as a parameter b_contains _() which takes an item as a parameter and returns True if the item is alreadv in the collection and False otherwise. The function must return a Boolean and not a string. Note: The in operator uses contains c. addO which adds a new item to the Locker. It does this by first checking that the maximum capacity for the collection hasn't been reached. If the maximum capacity has been reached, then the method returns False without modifying the collection. If the maximum capacity has not yet been reached, the method checks that the item is not already in the collection using the contains method described above. If the item is already there, the method returns False and does not modify the collection. If the item is not present and the maximum capacity has not yet been reached, the method adds the item to the collection and returns True The function must return a Boolean and not a string d. size0 which returns the number of items currently in the collection. Q which returns a string representing the obiect as seen in the sample output e str below g iter () which returns an iterator for the class. The iterator should move from the mostly recently added item to the item first added to the Bag. See the sample output below for examples. Please note that whatever classes you need for this questiorn should be included in the file you submit. You should not reference any files other than the csc242hw4.py file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
