American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

6pm – Python OOP – Joshua Widjanarko

May 22 @ 6:00 pm - 7:00 pm

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

Details

Date:
May 22
Time:
6:00 pm - 7:00 pm