Session 5: Exercise

Exercise 1


Implement a class to store information about a business (Business)

  • The initializer should take in the name & location
  • Ability to get the name & location back out
  • Define a method has_food? that return false

Exercise 2


Implement a subclass to represent a certain type of business: Restaurant

  • Implement has_food? to return true for restaurants.

Exercise 3


Using a mixin or module (HasRatings), add the ability to take in ratings of a business. This includes being able to take in a rating, as well as a method average_rating to return the average rating (be sure to account for the case where there are 0 ratings).