Created
January 11, 2022 07:58
-
-
Save see-why/d1d44f67e8a06224d12fe08597ab816e to your computer and use it in GitHub Desktop.
HackerRank 30 days of code, Day 13 Abstract classes challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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