Meowing Cat
Objectives
- Practice defining a class
- Use macros to create setter and getter methods
Introduction
In this lab, you'll be creating a Cat class. Every instance of a Cat should have a name and be able to meow. In other words, I should be able to do:
maru = Cat.new
maru.name = "Maru"
maru.name
# => "Maru"
maru.meow
# "meow!"
# => nil
Instructions
Run the test suite to get started. You'll be writing all your code in the lib/meowing_cat.rb
file.
- Define a class, called Cat.
- Use the
attr_accessor
macro to create a setter and getter method for a cat's name. - Write a method,
.meow
, that outputs "meow!" to the terminal using theputs
method when called on an instance of Cat.
Does this need an update?
Please open a GitHub issue or pull-request. Provide a detailed description that explains the issue you have found or the change you are proposing. Then "@" mention your instructor on the issue or pull-request, and send them a link via Connect.
PHRG Meowing Cat