Skip to content

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

  1. Enter a dog's name, breed, and age in the input fields at the top
  2. Click "Create Dog" to add a new Dog object to the kennel
  3. Click method buttons on any dog card to see the output in the console
  4. 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
<iframe src="https://dmccreary.github.io/computer-science/sims/dog-class-playground/main.html"
        height="600px"
        width="100%"
        scrolling="no"></iframe>

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

  1. Exploration (5 min): Create several dogs and experiment with each method button.
  2. Guided Practice (5 min): Predict what each method will output before clicking.
  3. 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.

References

  1. Python Classes - Python Documentation