This example is similar to the Classes in Ruby example. It demonstrates a superclass for representing a car. Two subclasses are used for representing a hero car and a villain car, they inherit from the superclass.
Advertisement
Categories
This example is similar to the Classes in Ruby example. It demonstrates a superclass for representing a car. Two subclasses are used for representing a hero car and a villain car, they inherit from the superclass.
Ruby is an object-oriented programming language. This example demonstrates a superclass for representing a car. Two subclasses are used for representing a hero car and a villain car, they inherit from the superclass.
Classes can contain subclasses and subclasses can in turn contain superclasses. For example, the class Person could be the superclass of the class PizzaDeliveryGuy.