Giter VIP home page Giter VIP logo

pantry's Introduction

Pantry

Instructions

  • Fork this Repository
  • Clone your forked repo to your computer.
  • Complete the activity below.
  • Push your solution to your forked repo
  • Submit a pull request from your repository to this repository
    • Put your name in your PR!

Iteration 1: Pantry Stocking

Build a simple Pantry-tracking program that can store a list of ingredients and available quantities. Once we have tracked our ingredients and quantities, we'll use the Recipe class we built before to have the pantry prepare a shopping list for us.

Support the following interactions:

pantry = Pantry.new
# => <Pantry...>

# Checking and adding stock
pantry.stock
# => {}

pantry.stock_check("Cheese")
# => 0

pantry.restock("Cheese", 10)
pantry.stock_check("Cheese")
# => 10

pantry.restock("Cheese", 20)
pantry.stock_check("Cheese")
# => 30

Iteration 2: Shopping List

Add a feature to your pantry to generate a shopping list for a collection of recipes.

We'll follow this interaction pattern:

pantry = Pantry.new
# => <Pantry...>

# Building our recipe
r = Recipe.new("Cheese Pizza")
# => <Recipe...>

r.ingredients
# => {}

r.add_ingredient("Cheese", 20)
r.add_ingredient("Flour", 20)

r.ingredients
# => {"Cheese" => 20, "Flour" => 20}

# Adding the recipe to the shopping list
pantry.add_to_shopping_list(r)

# Checking the shopping list
pantry.shopping_list # => {"Cheese" => 20, "Flour" => 20}

# Adding another recipe
r = Recipe.new("Spaghetti")
r.add_ingredient("Spaghetti Noodles", 10)
r.add_ingredient("Marinara Sauce", 10)
r.add_ingredient("Cheese", 5)
pantry.add_to_shopping_list(r)

# Checking the shopping list
pantry.shopping_list # => {"Cheese" => 25, "Flour" => 20, "Spaghetti Noodles" => 10, "Marinara Sauce" => 10}

# Printing the shopping list
pantry.print_shopping_list
# * Cheese: 25
# * Flour: 20
# * Spaghetti Noodles: 10
# * Marinara Sauce: 10
# => "* Cheese: 25\n* Flour: 20\n* Spaghetti Noodles: 10\n* Marinara Sauce: 10"

Iteration 3: What Can I Make?

Add a feature to your pantry that can recommend recipes for us to cook based on what ingredients we currently have in stock.

Support this interaction pattern:

pantry = Pantry.new

# Building our recipe
r1 = Recipe.new("Cheese Pizza")
r1.add_ingredient("Cheese", 20)
r1.add_ingredient("Flour", 20)

r2 = Recipe.new("Pickles")
r2.add_ingredient("Brine", 10)
r2.add_ingredient("Cucumbers", 30)

r3 = Recipe.new("Peanuts")
r3.add_ingredient("Raw nuts", 10)
r3.add_ingredient("Salt", 10)


# Adding the recipe to the cookbook
pantry.add_to_cookbook(r1)
pantry.add_to_cookbook(r2)
pantry.add_to_cookbook(r3)

# Stock some ingredients
pantry.restock("Cheese", 10)
pantry.restock("Flour", 20)
pantry.restock("Brine", 40)
pantry.restock("Cucumbers", 120)
pantry.restock("Raw nuts", 20)
pantry.restock("Salt", 20)

# What can I make?
pantry.what_can_i_make # => ["Pickles", "Peanuts"]

# How many can I make?
pantry.how_many_can_i_make # => {"Pickles" => 4, "Peanuts" => 2}

pantry's People

Contributors

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.