Code Monkey home page Code Monkey logo

potluck's Introduction

Potluck

Instructions

  1. Fork this Repository
  2. Clone your forked repo to your computer.
  3. Complete the activity below.
  4. Push your solution to your forked repo
  5. Submit a pull request from your repository to the turingschool-examples repository

Iteration 1

Use TDD to create a Dish class that responds to the following interaction pattern:

pry(main)> require './lib/dish'
#=> true
pry(main)> dish = Dish.new("Couscous Salad", :appetizer)
#=> #<Dish:0x00007f93fe9aa698...>
pry(main)> dish.name
#=> "Couscous Salad"
pry(main)> dish.category
#=> :appetizer

Iteration 2

Use TDD to create a Potluck class that responds to the following interaction pattern:

pry(main)> require './lib/dish'
#=> true
pry(main)> require './lib/potluck'
#=> true
pry(main)> potluck = Potluck.new("7-13-18")
#=> #<Potluck:0x00007fccc4abe940...>
pry(main)> potluck.date
#=> "7-13-18"
pry(main)> potluck.dishes
#=> []
pry(main)> couscous_salad = Dish.new("Couscous Salad", :appetizer)
#=> #<Dish:0x00007fccc4249940...>
pry(main)> cocktail_meatballs = Dish.new("Cocktail Meatballs", :entre)
#=> #<Dish:0x00007fccc499ceb8...>
pry(main)> potluck.add_dish(couscous_salad)
#=> [#<Dish:0x00007fccc4249940...>]
pry(main)> potluck.add_dish(cocktail_meatballs)
#=> [#<Dish:0x00007fccc4249940...>, #<Dish:0x00007fccc499ceb8...>]
pry(main)> potluck.dishes
#=> [#<Dish:0x00007fccc4249940...>, #<Dish:0x00007fccc499ceb8...>]
pry(main)> potluck.dishes.length
#=> 2

Iteration 3

Use TDD to update your Potluck class so that it responds to the following interaction pattern:

pry(main)> require './lib/dish'
#=> true
pry(main)> require './lib/potluck'
#=> true
pry(main)> potluck = Potluck.new("7-13-18")
#=> #<Potluck:0x00007f9422838908...>
pry(main)> couscous_salad = Dish.new("Couscous Salad", :appetizer)
#=> #<Dish:0x00007f942191e9b8...
pry(main)> summer_pizza = Dish.new("Summer Pizza", :appetizer)
#=> #<Dish:0x00007f9421d26880...>
pry(main)> roast_pork = Dish.new("Roast Pork", :entre)
#=> #<Dish:0x00007f9421d04870...>
pry(main)> cocktail_meatballs = Dish.new("Cocktail Meatballs", :entre)
#=> #<Dish:0x00007f9421ce6e88...>
pry(main)> candy_salad = Dish.new("Candy Salad", :dessert)
#=> #<Dish:0x00007f9421cb60f8...>
pry(main)> potluck.add_dish(couscous_salad)
#=> [#<Dish:0x00007f942191e9b8...]
pry(main)> potluck.add_dish(summer_pizza)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>]
pry(main)> potluck.add_dish(roast_pork)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>]
pry(main)> potluck.add_dish(cocktail_meatballs)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>, #<Dish:0x00007f9421dAA770...>]
pry(main)> potluck.add_dish(candy_salad)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>, #<Dish:0x00007f9421dAA770...>, #<Dish:0x00007f9421dAA610...>]
pry(main)> potluck.get_all_from_category(:appetizer)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>
pry(main)> potluck.get_all_from_category(:appetizer).first
#=> #<Dish:0x00007f942191e9b8...>
pry(main)> potluck.get_all_from_category(:appetizer).first.name
=> "Couscous Salad"

Iteration 4

Use TDD to update your Potluck class so that it responds to the following interaction pattern:

Note for the the menu method, dishes are sorted alphabetically.

pry(main)> require './lib/dish'
#=> true
pry(main)> require './lib/potluck'
#=> true
pry(main)> potluck = Potluck.new("7-13-18")
#=> #<Potluck:0x00007f9422838908...>
pry(main)> couscous_salad = Dish.new("Couscous Salad", :appetizer)
#=> #<Dish:0x00007f942191e9b8...
pry(main)> summer_pizza = Dish.new("Summer Pizza", :appetizer)
#=> #<Dish:0x00007f9421d26880...>
pry(main)> roast_pork = Dish.new("Roast Pork", :entre)
#=> #<Dish:0x00007f9421d04870...>
pry(main)> cocktail_meatballs = Dish.new("Cocktail Meatballs", :entre)
#=> #<Dish:0x00007f9421ce6e88...>
pry(main)> candy_salad = Dish.new("Candy Salad", :dessert)
#=> #<Dish:0x00007f9421cb60f8...>
pry(main)> bean_dip = Dish.new("Bean Dip", :appetizer)
#=> #<Dish:0x00007fa115885500...>
pry(main)> potluck.add_dish(couscous_salad)
#=> [#<Dish:0x00007f942191e9b8...]
pry(main)> potluck.add_dish(summer_pizza)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>]
pry(main)> potluck.add_dish(roast_pork)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>]
pry(main)> potluck.add_dish(cocktail_meatballs)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>, #<Dish:0x00007f9421dAA770...>]
pry(main)> potluck.add_dish(candy_salad)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>, #<Dish:0x00007f9421dAA770...>, #<Dish:0x00007f9421dAA610...>]
pry(main)> potluck.add_dish(bean_dip)
#=> [#<Dish:0x00007f942191e9b8...>, #<Dish:0x00007f9421d26880...>, #<Dish:0x00007f9421e26800...>, #<Dish:0x00007f9421dAA770...>, #<Dish:0x00007f9421dAA610...>, #<Dish:0x00007f9421dAA680...>]
pry(main)> potluck.menu
# => {:appetizers=>["Bean Dip", "Couscous Salad", "Summer Pizza"],:entres=>["Cocktail Meatballs", "Roast Pork"],:desserts=>["Candy Salad"]}
pry(main)> potluck.ratio(:appetizer)
#=> 50.0

potluck's People

Contributors

tcraig7 avatar brianzanti avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.