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 Ruby Object Attributes Lab on Learn.co and start learning to code for free.

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

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

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us