« All Events
6 PM – Python OOP – Bill
September 10, 2022 @ 6:00 pm - 7:00 pm
Today We:
- Reviewed the Homework
- Continued the Shopping cart V3 project
- Added the items to the list instead of the name
- Finished the Shopping Cart V3 project
Your HW:
- Create a new file called Sep_10_ClassHW4
- Create a Robot class with the following attributes:
- Name – String
- Action- String
- Battery – Integer between (0 to 100) default starts at 0
- Give the Robot class a method called charge with 1 parameter: energy
- When called, it will add energy to the battery attribute of the robot
- Make it so the battery cannot go above 100 (if the battery amount goes over 100, the battery attribute is set to 100 after adding energy to battery)
- Give the class a method called Perform_Action that does the following:
- Subtract a random number (1-10) from battery attribute
- Prints out statement like this: “<name> robot completes the action: <action> – Battery Remaining: (<battery> / 100 )”
- Create an empty list called garage
- Fill the garage list with 3 robot instances
- Loop through each Robot and fully charge them all