LEARN OOP · JUST CLICK

Pocket OOP

Play the battle on the left — every click runs a method, and the exact lines of code that fire light up on the right — great for showing a class what objects actually do.

CLASS OBJECT INHERITANCE POLYMORPHISM ENCAPSULATION
HOW TO USE

How to play

  1. Click a creature to choose it. A wild one appears to fight.
  2. Click ATTACK (the shared move) or SPECIAL (each type's own move).
  3. Watch the code on the right light up — those are the exact lines that just ran.
  4. Fire > Earth > Water > Fire. Hitting a type you're strong against does double damage ("super effective").
  5. Click NEW BATTLE to start again with a fresh creature.

What it teaches

  • Class & Object: choosing a creature runs new Fire(...) — an object built from a class.
  • Inheritance: every creature shares attack() from the base Pokemon class.
  • Polymorphism: SPECIAL calls specialMove() — same name, different behaviour per type.
  • Encapsulation: health only ever changes through takeDamage().
  • The five tags near the top flash as each idea happens.
◄ CLICK A CREATURE TO CHOOSE ►
pokemon.js — live
call log — methods that have run click a step to replay its code →