Today we Did
– Reviewing and editing our grocery program to use objects and classes
– Showing how using multiple files with import to use classes made elsewhere
HOMEWORK
- Step 1: In your GroceryItem class, add an attribute called allergy (Hint. Make sure to add it both to the () and set it to self
- Step 2: Fix you old GroceryItem objects. Now that we added an attribute allergy, set each objects allergy to True or False
- Step 3: Now, when the user purchases an item, we need to keep track of what items they have purchased with allergies.
- step 3.1 outside the loop, have a place/list that stores the items they could be allergic to (should start empty)
- step 3.2 when they select a valid item, you need to grab the allergy from the object (GroceryItem) that they chose
- If it is True, then you may add it to the “allergy list”
- If false do nothing
- Step 4 in a for loop, print out all possibly allergic items, and then warn them that it is a possible allergen