Good stuff getting to this challenge! Here are my notes on your code:
-
It looks like you have methods on your specific tree classes that are similar. For example,
OrangeTree.has_oranges?
andPearTree.has_pears?
. This is a code smell. You could DRY out your code by putting ahas_fruit?
method on theFruitTree
class. This way, every child class ofFruitTree
will have ahas_fruit?
method. Tada! Can you find any other ways to DRY out your code? Hint: look for similarly-worded methods that appear in all of your tree classes. -
Each of your tree classes has a few lines of code in its age! method that needs to be rethought. Here are those lines, from the
AppleTree
class:if age > 3 && age < 17 new_number = rand(10..