Skip to content

david-alvs/hs-coffee-machine-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

☕ Virtual Coffee Machine

A sophisticated command-line interface (CLI) application that simulates the operations of a coffee machine. This project was developed as part of the JavaScript Backend Developer track on Hyperskill (JetBrains Academy).

👤 Developer: David Alves
🎓 Hyperskill Profile: View my learning progress

📖 About

This project simulates a fully functional coffee machine. It manages internal resources (water, milk, coffee beans, disposable cups, and cash) and processes user requests through a loop-based menu. The core logic is built using Object-Oriented Programming (OOP) principles, ensuring modularity, scalability, and clean state management.

✨ Features

  • Resource Management: Real-time tracking of water, milk, beans, cups, and money.
  • Smart Validation: The machine checks if there are enough resources before attempting to make a coffee.
  • Interactive Menu:
    • buy: Choose from Espresso, Latte, or Cappuccino.
    • fill: Restock the machine supplies.
    • take: Withdraw the accumulated cash from the machine.
    • remaining: Display the current status of supplies and cash.
    • exit: Gracefully terminate the program.
  • Robust Input Handling: Handles case-insensitive commands and validates numeric inputs.

🛠️ Tech Stack

  • Language: JavaScript (Node.js)
  • Paradigm: Object-Oriented Programming (OOP)
  • External Libraries: sync-input (for synchronous user input handling)

🚀 Getting Started

Follow these steps to run the project locally on your machine.

Prerequisites

  • Node.js installed on your system.

Installation

  1. Clone the repository:

    git clone [https://github.com/david-alvs/hs-coffee-machine-js.git](https://github.com/david-alvs/hs-coffee-machine-js.git)
  2. Navigate to the project directory:

    cd hs-coffee-machine-js
  3. Install the dependencies:

    npm install

Usage

Run the application using Node.js:

node index.js

🧠 What I Learned

During the development of this project, I focused on:

  • Separation of Concerns: Splitting the logic between resource verification (checkForResources) and the execution of the order (makeCoffee).
  • Data Structures: Using Arrays of Objects to store coffee recipes, making the code scalable for new beverage types.
  • Input Validation: Implementing defensive programming to handle invalid user inputs preventing runtime errors.
  • State Management: Maintaining the machine's state throughout the application lifecycle.

🔗 Acknowledgements


Made with ☕ and code by David Alves.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors