Skip to content

Instantly share code, notes, and snippets.

@see-why
Created January 11, 2022 07:58
Show Gist options
  • Save see-why/d1d44f67e8a06224d12fe08597ab816e to your computer and use it in GitHub Desktop.
Save see-why/d1d44f67e8a06224d12fe08597ab816e to your computer and use it in GitHub Desktop.
HackerRank 30 days of code, Day 13 Abstract classes challenge
#https://www.hackerrank.com/challenges/30-abstract-classes/problem?isFullScreen=true
class MyBook < Book
attr_accessor :price
attr_accessor :author, :title
# Class Constructor
#
# Parameters:
# title - The book's title.
# author - The book's author.
# price - The book's price.
#
# Write your constructor here
def initialize(title, author, price)
@title = title
@author = author
@price = price
end
# Function Name: display
# Print the title, author, and price in the specified format.
#
# Write your function here
def display()
puts "Title: #{@title}"
puts "Author: #{@author}"
puts "Price: #{@price}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment