object-attributes-lab
Objectives
Define ruby classes.
Define methods that read from and write to instance variables.
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
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
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
Last updated