Lesson 4: Classes Part 2 + Text Adventure Checkpoint
Learning Intentions
- Extend classes with inheritance and composition.
- consolidate with a text adventure mini-project.
Success Criteria
- My Hero class inherits from Character and adds a special_attack.
- My text adventure uses 2+ classes.
- I've submitted adventure_v1.py to Classroom.
๐ Do Now โ Error of the Day
What does super().__init__(name, hp) do? Guess first, then we'll unpack it.
๐ I Do โ Teacher Demo
Live-code inheritance: Hero(Character), call super() in __init__, add special_attack method. Show what you inherit for free + what you add on top.
๐ค We Do โ Build Together
Build a 2-class text adventure skeleton together: Hero(Character) + Enemy(Character), main game loop with while-loop, one room function.
๐ You Do โ Your Turn
Finish adventure_v1.py โ your first Python submission this term. At minimum: 2 classes, 2 rooms, works end-to-end. Save as adventure_v1_[yourname].py + upload to Classroom.
- Hero(Character) with special_attack()
- Enemy(Character) with random AI
- Text adventure main loop with hero vs enemy
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
provide a Hero template; fill in 1 method
Core
build both classes from scratch
Extension
3+ inherited classes with polymorphism
Extensions
- 3+ rooms with functions per room.
- Save/load game state via JSON.
๐ Exit Ticket โ Coding Journal
Journal: upload your adventure_v1.py + write 1 sentence on what you're proud of.
Evidence of Learning
adventure_v1.py submitted. Uses 2+ classes. Runs.