Instance Methods Lab Ruby

Objectives

  1. Define a class.
  2. Build instance methods for the class.

Overview

You're going to be adding 2 instance methods to a Dog and Person class.

Instructions

Open this lab with learn open and run your tests with learn.

1. Define Dog in lib/dog.rb

Open lib/dog.rb and add a class definition for a Dog class.

2. Define #bark in Dog

Add an instance method #bark to your Dog class in lib/dog.rb that will puts "Woof!"

3. Define #sit in Dog

Add an instance method #sit to your Dog class in lib/dog.rb that will puts "The Dog is sitting".

4. Define a Person in lib/person.rb

Open lib/person.rb and add a class definition for a Person class.

5. Define #talk in Person

Add an instance method #talk to your Person class in lib/person.rb that will puts "Hello World!"

6. Define #walk in Person

Add an instance method #walk to your Person class in lib/person.rb that will puts "The Person is walking".

When you're done, submit the lab with learn submit.

View Instance Methods Lab Ruby on Learn.co and start learning to code for free.