GithubHelp home page GithubHelp logo

food_truck_event_2210's Introduction

Food Truck Event

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 - Items & FoodTrucks

Graded Items:

  1. Create an Item with attributes: Item.new
  2. Create a FoodTruck with attributes: FoodTruck.new
  3. Check quantity of an Item on the FoodTruck: FoodTruck #check_stock
  4. Stock an Item on the FoodTruck: FoodTruck #stock

The Event will need to keep track of its FoodTrucks and their Items. Each FoodTruck will be able to report its total inventory, stock items, and return the quantity of items. Any item not in stock should return 0 by default.

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

pry(main)> require './lib/item'
#=> true

pry(main)> require './lib/food_truck'
#=> true

pry(main)> item1 = Item.new({name: 'Peach Pie (Slice)', price: "$3.75"})
#=> #<Item:0x007f9c56740d48...>

pry(main)> item2 = Item.new({name: 'Apple Pie (Slice)', price: '$2.50'})
#=> #<Item:0x007f9c565c0ce8...>

pry(main)> item2.name
#=> "Apple Pie (Slice)"

pry(main)> item2.price
#=> 2.50

pry(main)> food_truck = FoodTruck.new("Rocky Mountain Pies")
#=> #<FoodTruck:0x00007f85683152f0...>

pry(main)> food_truck.name
#=> "Rocky Mountain Pies"

pry(main)> food_truck.inventory
#=> {}

pry(main)> food_truck.check_stock(item1)
#=> 0

pry(main)> food_truck.stock(item1, 30)

pry(main)> food_truck.inventory
#=> {#<Item:0x007f9c56740d48...> => 30}

pry(main)> food_truck.check_stock(item1)
#=> 30

pry(main)> food_truck.stock(item1, 25)

pry(main)> food_truck.check_stock(item1)
#=> 55

pry(main)> food_truck.stock(item2, 12)

pry(main)> food_truck.inventory
#=> {#<Item:0x007f9c56740d48...> => 55, #<Item:0x007f9c565c0ce8...> => 12}

Iteration 2 - Event and FoodTrucks

Graded Items:

  1. Create an Event with attributes: Event.new
  2. Add a FoodTruck to an Event: Event #add_food_truck
  3. Return the list of FoodTruck names for an Event: Event #food_truck_names
  4. Return the list of FoodTrucks that sell a given Item for an Event: Event #food_trucks_that_sell
  5. Return the potential revenue from a FoodTruck: FoodTruck #potential_revenue

A FoodTruck will be able to calculate their potential_revenue - the sum of all their items' price * quantity.

A Event is responsible for keeping track of FoodTrucks. It should have a method called food_truck_names that returns an array of all the FoodTruck's names.

Additionally, the Event should have a method called food_trucks_that_sell that takes an argument of an item represented as a String. It will return a list of FoodTrucks that have that item in stock.

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

pry(main)> require './lib/item'
#=> true

pry(main)> require './lib/food_truck'
#=> true

pry(main)> require './lib/event'
#=> true

pry(main)> event = Event.new("South Pearl Street Farmers Market")    
#=> #<Event:0x00007fe134933e20...>

pry(main)> event.name
#=> "South Pearl Street Farmers Market"

pry(main)> event.food_trucks
#=> []

pry(main)> food_truck1 = FoodTruck.new("Rocky Mountain Pies")
#=> #<FoodTruck:0x00007fe1348a1160...>

pry(main)> item1 = Item.new({name: 'Peach Pie (Slice)', price: "$3.75"})
#=> #<Item:0x007f9c56740d48...>

pry(main)> item2 = Item.new({name: 'Apple Pie (Slice)', price: '$2.50'})
#=> #<Item:0x007f9c565c0ce8...>

pry(main)> item3 = Item.new({name: "Peach-Raspberry Nice Cream", price: "$5.30"})
#=> #<Item:0x007f9c562a5f18...>

pry(main)> item4 = Item.new({name: "Banana Nice Cream", price: "$4.25"})
#=> #<Item:0x007f9c56343038...>

pry(main)> food_truck1.stock(item1, 35)    

pry(main)> food_truck1.stock(item2, 7)    

pry(main)> food_truck2 = FoodTruck.new("Ba-Nom-a-Nom")    
#=> #<FoodTruck:0x00007fe1349bed40...>

pry(main)> food_truck2.stock(item4, 50)    

pry(main)> food_truck2.stock(item3, 25)

pry(main)> food_truck3 = FoodTruck.new("Palisade Peach Shack")    
#=> #<FoodTruck:0x00007fe134910650...>

pry(main)> food_truck3.stock(item1, 65)  

pry(main)> event.add_food_truck(food_truck1)    

pry(main)> event.add_food_truck(food_truck2)    

pry(main)> event.add_food_truck(food_truck3)

pry(main)> event.food_trucks
#=> [#<FoodTruck:0x00007fe1348a1160...>, #<FoodTruck:0x00007fe1349bed40...>, #<FoodTruck:0x00007fe134910650...>]

pry(main)> event.food_truck_names
#=> ["Rocky Mountain Pies", "Ba-Nom-a-Nom", "Palisade Peach Shack"]

pry(main)> event.food_trucks_that_sell(item1)
#=> [#<FoodTruck:0x00007fe1348a1160...>, #<FoodTruck:0x00007fe134910650...>]

pry(main)> event.food_trucks_that_sell(item4)
#=> [#<FoodTruck:0x00007fe1349bed40...>]

pry(main)> food_truck1.potential_revenue
#=> 148.75

pry(main)> food_truck2.potential_revenue
#=> 345.00

pry(main)> food_truck3.potential_revenue
#=> 243.75  

Iteration 3 - Items sold at the Event

Use TDD to update the Event class so that it adds the following functionality:

  1. Return a list of overstocked Items for an Event. An item is overstocked if it is sold by more than 1 food truck AND the total quantity is greater than 50.
  2. An Event can return a list of names of all items the FoodTrucks have in stock, sorted alphabetically. This list should not include any duplicate items.
  3. An Event can return a hash of total inventory that reports the available inventory of all items sold at the event. Specifically, it should include:
    • All items available for sale, and each item should identify the total inventory/quantity for that item, as well as, a list of food_trucks that sell that item.

Iteration 4 - Selling Items

Use TDD to update the Event class so that it adds the following functionality:

  1. An event has a start date that is returned in the format of 'dd/mm/yyyy'. The addition of a date to the event should NOT break any previous tests. Use a stub to test this in with a date that is IN THE PAST.
  2. An event can sell an item of a given quantity. There are two possible outcomes for selling an item:
    • If the Event does not have enough of the item in stock to satisfy the given quantity, this method should return false.
    • If the Event has enough of the item in stock to satisfy the given quantity, this method should return true. Additionally, this method should reduce the stock of the FoodTrucks. It should look through the FoodTrucks in the order they were added and sell the item from the first FoodTruck with that item in stock. If that FoodTruck does not have enough stock to satisfy the given quantity, the FoodTruck's entire stock of that item will be depleted, and the remaining quantity will be sold from the next food_truck with that item in stock. It will follow this pattern until the entire quantity requested has been sold.

food_truck_event_2210's People

Contributors

cemccabe avatar epintozzi 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.