Created
March 3, 2014 19:14
-
-
Save laurenkruczyk/9332465 to your computer and use it in GitHub Desktop.
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
class Television | |
def initialize(brand, price, size) | |
@brand = brand | |
@price = price | |
@size = size | |
end | |
def brand | |
@brand | |
end | |
def price | |
@price | |
end | |
def size | |
@size | |
end | |
end | |
dougs_tv = Television.new("Sony", 100, 42) | |
puts "Doug has a #{dougs_tv.brand} priced at $#{dougs_tv.price} and it is #{dougs_tv.size} inches." | |
class Channel | |
def initialize(station, number, genre) | |
@station=station | |
@number=number | |
@genre=genre | |
end | |
def station | |
@station | |
end | |
def number | |
@number | |
end | |
def genre | |
@genre | |
end | |
end | |
my_tv = Channel.new("NBC", 12, "news") | |
puts "My TV has #{my_tv.station}, which is on channel #{my_tv.number}. I watch this station everyday for the #{my_tv.genre}." | |
class Show | |
def initialize(fave, dislike, news) | |
@fave=fave | |
@dislike=dislike | |
@news=news | |
end | |
def fave | |
@fave | |
end | |
def dislike | |
@dislike | |
end | |
def news | |
@news | |
end | |
end | |
my_shows = Show.new("House of Cards", "American Idol", "CNN") | |
puts "I love to watch #{my_shows.fave} and avoid #{my_shows.dislike}. I watch #{my_shows.news} to catch up on current events." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment