Skip to content

LaSkilzs/ruby-object-initialize-lab-dumbo-web-102918

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Object Initialize Lab

Objectives

  1. Define a class with a custom initialize routine.
  2. Set instance variable attributes from initialize.
  3. Include a default argument for an initialize argument.

Overview

You're going to be building a Person class that accepts a person's name when a person is initialized. You're also going to be building a Dog class that accepts a dog's name and breed on initialization. If no value for the dog's breed is provided, it should default to "Mutt"

Instructions

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

1. Person#initialize with a Name

Define a Person class in lib/person.rb that provides an #initialize method that accepts an argument for the person's name. That argument should be stored within a @name instance variable.

2. Dog#initialize with Name and Breed defaulting to "Mutt"

Define a Dog class in lib/dog.rb that provides an #initialize method that accepts an argument for the dog's name. That argument should be stored within a @name instance variable.

Additionally, Dog#initialize should accept a second optional argument for the dog's breed stored in an instance variable @breed. When none is provided, it should default to "Mutt".

Submit your solution with learn submit.

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%