Structuring Your Pets Logically : inheritance « Class « Ruby

Structuring Your Pets Logically

class Pet
  attr_accessor :name, :age, :gender, :color

class Cat < Pet

class Dog < Pet

class Snake < Pet


Related examples in the same category

1.Basing one class on another is called inheritance.
2.Extends class inheritance works in code form
4.Basing One Class on Another: a Demo
5.different types of people
6.If the class Name were in a different file, you would just require that file first
7.Add new constructor
8.Module and class hierarchy
9.Subclass Array class