CHALLENGE EXERCISE #1
- Read the "17. Classes & Objects: The Basics" and complete the "Exercises".
- Read the "18. Classes & Objects: Digging a Little Deeper" and complete the "Exercises".
TASK:
A review of the object-oriented programming model.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
Create the Hero class.
HINT:
Define the Hero class at the top of your program following the syntax found in Runestone Academy chapter 17 and 18.
You will need to think about what data the hero is going to need through his journey and create instance variables for each.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
Define the update_energy method.
HINT:
The update_energy method will need to have a parameter that will
represent the value that the hero's energy should increment or decrement by. Then the body should make that calculation whose result is stored in the energy instance variable.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
Write the equip method.
HINT:
The equip method should first change the value of the weapon instance variable to the value of the weapon that the hero wants to equip.
Once that's in place, you can use the weapon instance variable as the index in the weapon_array and the weapon_damage to figure out how much damage to deal out and what weapon name the hero is carrying at the moment.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #3
- Write the update_gold method.
- Use the update_gold method to modify the value of Hero's gold.
- Use the hero object and it's associated methods to implement RPG.
- Check your program with the rubric.
Congratulations!
You have just objectified a program!
You have just objectified a program!