Last active
December 29, 2015 11:09
-
-
Save jmoon90/7661574 to your computer and use it in GitHub Desktop.
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 Channel | |
| attr_accessor :channel_number | |
| def initialize(channel_number) | |
| @channel_number = channel_number | |
| end | |
| def change_channel(channel_number) | |
| puts "You are changing channels" | |
| @channel_number = channel_number | |
| end | |
| end | |
| channel = Channel.new(35) | |
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 Show | |
| def initilize(channel) | |
| @channel = channel | |
| end | |
| def sports | |
| if channel.even? | |
| puts "You are watching ESPN nba" | |
| else | |
| puts "You are watching ESPN soccer" | |
| end | |
| end | |
| def movies | |
| if channel.even? | |
| puts "You are now watching LOL Live" | |
| else | |
| puts "you are now watching John code" | |
| end | |
| end | |
| end | |
| show = Show.new(30) | |
| show.sports | |
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
| #Quick Challenge | |
| class Television | |
| def turn_on | |
| puts "TV on" | |
| end | |
| def turn_off | |
| puts "TV OFF" | |
| end | |
| def change_channel | |
| puts "changing channel" | |
| end | |
| def sound_on | |
| puts "on" | |
| end | |
| def sound_off | |
| puts "off" | |
| end | |
| end | |
| tv = Television.new | |
| tv.turn_on | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment