class Animal
 def initialize
 puts "Creating a New Animal"
 end
def set_name(new_name)
 @name = new_name # @name : instance variable?
 end
def get_name
 @name
 end
def name
 @name
 end
def name=(new_name) # Balls! what's this "=" doing here?
 if new_name.is_a?(Numeric)
 puts "Name can't be a number"
 else
 @name = new_name
 end
 end
end
# silly thing in ruby is these "end"s, it is so confusing.
# the same thing with java, c, javascript, PHP... etc
# python has a cleaner way to handle this
cat = Animal.new
cat.set_name("Horatio")
puts cat.name
cat.name = "Silly"
puts cat.name
class Dog
 # the two following statements creates getters
 # and setters automatically, each on one line
 # attr_reader :name, :height, :width
 # attr_writer :name, :height, :width
 # but there's a short way to do this
 attr_accessor :name, :height, :width
 # by the way these are called symbols, ex. :name
def bark
 return "Generic Bark"
 end
end
rover = Dog.new
rover.name = "Rover"
puts rover.name
# Inheritance
class GermanShepard < Dog
 def bark
 return "Loud Bark"
 end
end
max = GermanShepard.new
max.name = "Max"
# Like c++
printf "%s goes %s \n", max.name, max.bark()