Giter Club home page Giter Club logo

vending-machine's Introduction

Build a Ruby CLI for a Vending Machine

Contents of the vending machine lives in tiny_vending_machine.json.

Running the program should present a prompt.

Hello, please enter a command:
(c)ontents - Prints the contents of the vending machine.
(i)nsert money - Takes in coins and prints total money inserted.
(v)alid coin values - Prints the valid coins inputs:  Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter.
(p)urchase - Displays a prompt to enter the slot they'd like to purchase.

Insert Money

> i

Please insert your money > 13

Not a valid coin.

Please insert your money > 25

Total inserted: 25

> i

Please insert your money > 25

Total inserted: 50

Purchase

> p

Please enter the slot of the item you'd like to vend > g7

Not a valid slot...

> p
Please enter the slot of the item you'd like to vend > b1
Sorry. There are no items remaining.

> p
Please enter the slot of the item you'd like to vend > a1
Insufficient funds. Please (i)nsert more money.

> i
Please insert your money > 25,25,25,25
Total inserted: 100

> p
Please enter the slot of the item you'd like to vend > a1

Vending...

Enjoy your Snickers!

Extensions

  • Rewrite the JSON file each time something vends successfully
  • Provide change
    • Create a preference for returning larger coins first
    • Change should only be in the supported coin types
  • Vending machine admin:
    • Reset the contents
    • Make sure each slot is not over filled

vending-machine's People

Contributors

jmejia avatar rajaaboulassouak 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.