We have four models: Recipe
, Restaurant
, RestuarantOwner
and MenuItem
.
A RestaurantOwner
has many Restaurant
s and a Restaurant
belongs to a RestaurantOwner
. A Restaurant
has many MenuItem
s and a Recipe
has many MenuItem
s. A MenuItem
belongs to a Restaurant
and a Recipe
.
Note: You should draw your domain on paper or on a whiteboard before you start coding. Remember to identify a single source of truth for your data.
Fork this repository and add your instructor as a collaborator.
To get started, run bundle install
while inside of this directory.
Build out all of the methods listed in the deliverables. Commit after each section of deliverables (ie Initializers, Readers, and Writers is one section). If directed to by your lead, please wait for feedback before tackling additional deliverables. You can also do this by choice. In either case, make sure to message your lead when you have deliverables pushed for review.
Write the following methods in the classes in the files provided. Feel free to build out any helper methods if needed.
Deliverables use the notation #
for instance methods, and .
for class methods.
TESTING: As you build ensure you are testing every method by running ruby tools/console.rb
, creating instances, and checking each method one by one!
- For these, the initialize is described as well was what attribute can(not) be changed after initialization. Use those descriptions to determine the appropriate readers and writers.
Recipe#initialize(name, description)
- A recipe should be initialized with a
name
(string) and adescription
(string). - The name cannot be changed after the recipe is initialized.
- The description can be changed after the recipe is initialized.
- Both name and description are readable
- A recipe should be initialized with a
Recipe.all
- Returns an array of all recipe instances that have been created.
Restaurant#initialize(owner, name, star_rating)
- A restaurant should be initialized with a
RestaurantOwner
instance, aname
(string) and astar_rating
(integer). - The name and star_rating can be changed after the restaurant is initialized.
- Both name and star_rating are readable.
- A restaurant should be initialized with a
Restaurant.all
- Returns an array of all restaurant instances that have been created.
RestaurantOwner#initialize(name, age)
- A restaurant_owner should be initialized with a
name
(string) and anage
(integer). - The name and age can be changed after the restaurant_owner is initialized.
- Both name and age are readable.
- A restaurant_owner should be initialized with a
RestaurantOwner.all
- Returns an array of all restaurant_owner instances that have been created.
MenuItem#initialize(restaurant, recipe, price)
- A menu_item should be initialized with a
Restaurant
instance, aRecipe
instance and aprice
(float). - The price can be changed after the menu_item is initialized.
- A menu_item should be initialized with a
MenuItem.all
- Returns an array of all menu_item instances that have been created.
Recipe#menu_items
- returns an array of all the
MenuItem
instances for theRecipe
.
- returns an array of all the
Recipe#restaurants
- returns an array of all the
Restaurant
instances that have theRecipe
on their menu.
- returns an array of all the
Restaurant#menu_items
- returns an array of all the
MenuItem
instances for theRestaurant
.
- returns an array of all the
Restaurant#owner
- returns the
RestaurantOwner
instance associated with theRestaurant
instance
- returns the
Restaurant#recipes
- returns an array of all the
Recipe
instances that are on thisRestaurant
s menu.
- returns an array of all the
RestaurantOwner#restaurants
- returns an array of
Restaurant
instances associated with theRestaurantOwner
instance.
- returns an array of
RestaurantOwner#menu_items
- returns an array of
MenuItem
instances associated with any of theRestaurantOwner
sRestaurant
instances.
- returns an array of
MenuItem#recipe
- returns the
Recipe
instance associated with theMenuItem
instance
- returns the
MenuItem#restaurant
- returns the
Restaurant
instance associated with theMenuItem
instance
- returns the
MenuItem#owner
- returns the
Owner
instance associated with theMenuItem
instance
- returns the
Recipe#average_price
- returns the average price (integer) for all
MenuItem
instances of thisRecipe
instance.
- returns the average price (integer) for all
Recipe#highest_price
- returns the highest price (integer) for all
MenuItem
instances of thisRecipe
instance.
- returns the highest price (integer) for all
Recipe#cheapest_restaurant
- returns the
Restaurant
instance where thisRecipe
instance is the cheapest.
- returns the
Recipe.inactive
- returns an array of
Recipe
instances that are not currently being sold at any restaurants.
- returns an array of
Restaurant#has_dish?(recipe)
- returns
true
if the dish is on the menu at the given restaurant andfalse
if it is not.
- returns
Restaurant.highest_rated
- returns the highest rated
Restaurant
instance.
- returns the highest rated
RestaurantOwner.average_age
- returns the average age of all the
RestaurantOwner
s
- returns the average age of all the
RestaurantOwner#sell_restaurant(restaurant, buyer)
- transfers ownership of a
Restaurant
instance (which must belong to the current user) to thebuyer
which is aRestaurantOwner
instance.
- transfers ownership of a
MenuItem.most_expensive_item
- returns the most expensive
MenuItem
instance
- returns the most expensive