Created
May 29, 2017 23:43
-
-
Save matt297/886f0eee576bd67466621b81b9edea94 to your computer and use it in GitHub Desktop.
Lighthouse Labs - Intro to Web Dev - W4D1 - May 2017 Cohort
This file contains hidden or 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
class DiskJockey | |
def initialize | |
@song_history = [] | |
end | |
def set_song(song, artist) | |
@song = song | |
@artist = artist | |
end | |
def current_song | |
"#{@song}, by #{@artist}" | |
end | |
def play | |
puts "Now playing: #{current_song}" | |
@song_history << current_song | |
end | |
def song_history | |
puts @song_history | |
end | |
end | |
# Create an instance of the DiskJockey class | |
dj = DiskJockey.new | |
# Set a song, then play it | |
dj.set_song('Lion King Theme Song', 'Disney') | |
dj.play | |
# Set a song, then play it | |
dj.set_song('Wrecking Ball', 'Miley Cyrus') | |
dj.play | |
# Set a song, then play it | |
dj.set_song('Blank Space', 'Taylor Swift') | |
dj.play | |
# List out all the songs we've played tonight | |
puts "Tonight, we've listened to:" | |
dj.song_history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment