« All Events
6 PM – Python OOP – Gamas
November 30, 2022 @ 6:00 pm - 7:00 pm
Today We Did
- We went over Restaurant class homework
- We reviewed at Restaurant.set_number_served(sefl, num) method that will change Restaurant.number_served attribute.
- We reviewed at Restaurant.increment_number_served(self, num) method that will increase Restaurant.number_served attribute.
- We also went over how to use class inside ShoppingCart project.
- I uploaded all the files that we did in the class into google drive if you need to see: https://drive.google.com/drive/folders/1pqzz7Xd0Hf5MVGyQsoMqXdixRIqrZ5AH?usp=sharing
Homework
- If you did not finish last week’s homework, please finish it by next week.
- Inside Nov16_GrocceryShoppingCartUsingClass.py add the following features.
- Add one more attribute to GroceryItem class: frozen_food
- Add one more parameter in GrocerryItem.__init__ method: frozen_food
- Inside items_dictionary variable update the creation of GroceryItem so you would add one more parameter which is the frozen_food parameter. Use “yes” or “false”. For example, for “frozen pizza”, you would do GroceryItem(“frozen pizza”, 10, “yes”) because “frozen pizza” is a frozen food.
- Inside the while loop, add code that will check if gi.frozen_food is equal to “yes” then add the name to frozen_item list.
- When you do all above codes, then your program should not be able to list all frozen foods that you purchase like below
-
What do you want to purchase:
0. Frozen Pizza - $10
1. Milk - $5
2. Ice Cream - $4
3. Bread - $6
4. I am done, checkout please
Enter your selection: 0
You have purchased frozen pizza for $10
What do you want to purchase:
0. Frozen Pizza - $10
1. Milk - $5
2. Ice Cream - $4
3. Bread - $6
4. I am done, checkout please
Enter your selection: 1
You have purchased milk for $5
What do you want to purchase:
0. Frozen Pizza - $10
1. Milk - $5
2. Ice Cream - $4
3. Bread - $6
4. I am done, checkout please
Enter your selection: 2
You have purchased ice cream for $4
What do you want to purchase:
0. Frozen Pizza - $10
1. Milk - $5
2. Ice Cream - $4
3. Bread - $6
4. I am done, checkout please
Enter your selection: 4
You have purchased the following items:
FROZEN PIZZA
MILK
ICE CREAM
Please pay $19, thank you for your business.
Do not forget to put the following items in FREEZER
FROZEN PIZZA
ICE CREAM