Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created March 5, 2020 22:42
Show Gist options
  • Save harrisonmalone/43ec5d7eec89cf2bb110f662988456c2 to your computer and use it in GitHub Desktop.
Save harrisonmalone/43ec5d7eec89cf2bb110f662988456c2 to your computer and use it in GitHub Desktop.
class Artist
def initialize(name)
@name = name
@albums = []
end
def add_album(album)
@albums.push(album)
end
end
class Album
def initialize(title, date)
@title = title
@date = date
@songs = []
end
def add_song(song)
@songs << song
end
end
class Song
def initialize(title, duration, genre)
@title = title
@duration = duration
@genre = genre
end
end
eminem = Artist.new('Eminem')
a_bocelli = Artist.new('Andrea Bocelli')
encore = Album.new("Encore","07/03/2004")
relaspe = Album.new("Relaspe","09/09/2000")
puke = Song.new("Puke", "4min7sec", "hiphop")
my_mum = Song.new("My mum", "5min19sec", "hiphop")
eminem.add_album(encore)
encore.add_song(puke)
encore.add_song(my_mum)
pp eminem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment