Skip to content

Instantly share code, notes, and snippets.

@kellylougheed
Last active October 7, 2016 22:39
Show Gist options
  • Save kellylougheed/044adbe9ce74213adfa484e45ee98c1d to your computer and use it in GitHub Desktop.
Save kellylougheed/044adbe9ce74213adfa484e45ee98c1d to your computer and use it in GitHub Desktop.
Builds a class for a book and a textbook class that inherits from it. (Firehose Project Quiz #3)
class Book
attr_accessor :title, :author
def initialize(title, author)
@title = title
@author = author
end
def read
puts "I'm reading #{@title} by #{@author}"
end
end
class Textbook < Book
def learn
puts "I'm learning from #{@title} by #{@author}"
end
end
hp = Book.new("Harry Potter", "J. K. Rowling")
hp.read
gibbon = Textbook.new("The Decline and Fall of the Roman Empire", "Edward Gibbon")
gibbon.learn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment