Last active
December 16, 2018 19:57
-
-
Save W-Mills/c4e1991884a54beed6aececeae08c4e2 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
# greenspace.rb | |
class GreenSpace | |
attr_reader :name, :num_trees | |
def initialize(name, num_trees) | |
@name = name | |
@num_trees = num_trees | |
end | |
end | |
class CityPark < GreenSpace; end | |
class Forest < GreenSpace; end | |
high_park = CityPark.new("High Park", 5000) | |
durham_forest = Forest.new("Durham Forest", 125000) | |
dufferin_park = CityPark.new("Dufferin Park", 2000) | |
high_park.name # => "High Park" | |
high_park.num_trees # => 5000 | |
durham_forest.name # => "Durham Forest" | |
durham_forest.num_trees # => 125000 | |
dufferin_park.num_trees # => 2000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment