Slide 20
Slide 20 text
1 class Song
2 attr_accessor :title, :artist, :length
3
4 def initialize(artist, title, length)
5 @artist, @title, @length = artist, title, length
6 end
7
8 def to_s
9 "#{artist} - #{title} (#{length})"
10 end
11 end
12
13 class Artist
14 attr_accessor :name
15
16 def initialize(name)
17 @name = name
18 end
19
20 def to_s; name; end
21 end