American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

6 PM – Python OOP – Bill

September 10, 2022 @ 6:00 pm - 7:00 pm

Today We:
  1. Reviewed the Homework
  2. Continued the Shopping cart V3 project
  3. Added the items to the list instead of the name
  4. Finished the Shopping Cart V3 project
Your HW:
  1. Create a new file called Sep_10_ClassHW4
  2. Create a Robot class with the following attributes:
    • Name – String
    • Action- String
    • Battery – Integer between (0 to 100) default starts at 0
  3. 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)
  4. 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 )”
  5. Create an empty list called garage
  6. Fill the garage list with 3 robot instances
  7. Loop through each Robot and fully charge them all

Details

Date:
September 10, 2022
Time:
6:00 pm - 7:00 pm
Verified by MonsterInsights