Skip to content

Commit ac8d6a4

Browse files
committed
HackerRank - Ruby - 30 days of code: added days 10 and 11
1 parent a1cdf8c commit ac8d6a4

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: hackerrank/ruby/30_days_of_code/day12_inheritance.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Student <Person
2+
def initialize(firstName, lastName, id, scores)
3+
super(firstName, lastName, id)
4+
@scores = scores
5+
end
6+
7+
def calculate
8+
avg = @scores.sum / @scores.size
9+
case avg
10+
when 90..100
11+
'O'
12+
when 80..89
13+
'E'
14+
when 70..79
15+
'A'
16+
when 55..69
17+
'P'
18+
when 40..54
19+
'D'
20+
when 0..39
21+
'T'
22+
end
23+
end
24+
end
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def initialize(title, author, price)
2+
@title = title
3+
@author = author
4+
@price = price
5+
end
6+
7+
def display
8+
puts "Title: #{@title}"
9+
puts "Author: #{@author}"
10+
puts "Price: #{@price}"
11+
end

0 commit comments

Comments
 (0)