Coder Social home page Coder Social logo

vending-machine's Introduction

Task

Recreate a vending machine. You will be given a json file of inventory, and "money" to import into your machine.

The user should input two things to get an item:

  1. Code (A01)
  2. Amount of money the user inserts into the machine (0.75)

There should also be two maintenance methods:

  1. Check on inventory of a specific item (by code)
  2. The amount of money currently in the machine

Demonstrate the following rules using a test harness like PyTest, Unittest, etc.

Rules

  1. If the money given to the machine is less than the item cost return: Not enough money!
  2. If the quantity is 0 for an item return: <item name>: Out of Stock!. Where item name is the name of the item selected.
  3. If an item is correctly selected return Vending <item name> with <change> change. Where item name is the name of the item selected and change, if any, 0 otherwise.
  4. If an item is correctly selected and there is no change needed then return: Vending item name. Where item name is the name of the item selected.
  5. If an invalid item is selected return Invalid selection!.
  6. If a selection is successful then the quantity should be updated.
  7. For simplicity, denomitions of bills and coins is not taken into consideration, but the vending machine can run out of 'money', so you must keep track of the amount of money availble to return.
  8. Change is always given to 2 decimal places (e.g. 7.00)

Example

candy_machine = MyVendingMachine(json) # json = {"items": [{"name": "skittles", "code": "A01", "price": 0.60, "quantity": 11}], "money": 12.00}

candy_machine.vend('A01', 0.60)
# "Vending Skittles"
candy_machine.inventory('A01')
# "Skittles Inventory: 10"
candy_machine.money()
# "Change Available: 12.00"

vending-machine's People

Contributors

mqarty avatar

Watchers

 avatar James Cloos avatar  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.