Created
January 21, 2015 22:18
-
-
Save troyleach/d5b118f0c5e48a754041 to your computer and use it in GitHub Desktop.
screen cast 13 and 14
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 Person | |
| def musical_instruments | |
| instrument = Drums.new | |
| puts "I own a #{instrument.size} #{instrument.set_name} set of drums" | |
| end | |
| def own_a_dog | |
| milo = Dog.new | |
| "My dogs name is #{milo.name}" | |
| end | |
| end | |
| class Dog | |
| def initialize | |
| @eating = Food.new | |
| end | |
| def name | |
| "Milo" | |
| end | |
| def eat | |
| puts "When my dad isn't looking I will eat his #{@eating.pepperoni_pizza}" | |
| end | |
| end | |
| class Food | |
| def pepperoni_pizza | |
| "Large pepperoni pizza" | |
| end | |
| def steak | |
| "Porter House" | |
| end | |
| end | |
| class Bird | |
| def fly | |
| puts "I can fly" | |
| end | |
| def music | |
| puts "I can make music in the morning" | |
| end | |
| end | |
| class Drums | |
| def size | |
| "10 piece" | |
| end | |
| def set_name | |
| "ludwig" | |
| end | |
| end | |
| troy = Person.new | |
| puppy = Dog.new | |
| pizza = Food.new | |
| robin = Bird.new | |
| ludwig = Drums.new | |
| puts troy.own_a_dog | |
| puts troy.musical_instruments | |
| puts puppy.eat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess a dog will eat about anything - including pepperoni pizza 😄