Ruby Object Attributes Lab

Objectives

  1. Define ruby classes.
  2. Define methods that read from and write to instance variables.
  3. Create object properties using methods and instance variables.

Overview

This lab is all about using instance variables within a class to create methods that represent attributes or properties of an object.

Instructions

Get started with this lab by opening it with learn open and running learn.

Dog and lib/dog.rb

Give a Dog a Name

You'll be teaching Dog about their names through two methods, #name, and #name= that read and write to a corresponding instance variable @name.

Give a Dog a Breed

You'll be teaching Dog about their breed through two methods, #breed, and #breed= that read and write to a corresponding instance variable @breed.

Person and lib/person.rb

Give a Person a Name

You'll be teaching Person about their names through two methods, #name, and #name= that read and write to a corresponding instance variable @name.

Give a Person a Job

You'll be teaching Person about their jobs through two methods, #job, and #job= that read and write to a corresponding instance variable @job.

When you're done submit the lab with learn submit

View Object Attributes Lab on Learn.co and start learning to code for free.