Dog Class Interactive Playground
Run the Dog Class Playground MicroSim Fullscreen
Edit in the p5.js Editor
About This MicroSim
This interactive playground lets you create Dog objects by entering a name, breed, and age. Each dog appears as a card in the "kennel" area with buttons to call methods like bark(), describe(), birthday(), print (str), and repr (repr). All output appears in the console below.
How to Use
- Enter a dog's name, breed, and age in the input fields at the top
- Click "Create Dog" to add a new Dog object to the kennel
- Click method buttons on any dog card to see the output in the console
- Notice how "Birthday" changes the dog's age on the card
Iframe Embed Code
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan
Grade Level
9-12 (High School Computer Science)
Duration
10-15 minutes
Prerequisites
Understanding of classes, objects, constructors, and methods from Chapter 12.
Activities
- Exploration (5 min): Create several dogs and experiment with each method button.
- Guided Practice (5 min): Predict what each method will output before clicking.
- Assessment (5 min): Explain the difference between str and repr output.
Assessment
Students can explain how creating a Dog object calls init, and how each method operates on that specific object's data.