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
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.
- 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.
- Language: JavaScript (Node.js)
- Paradigm: Object-Oriented Programming (OOP)
- External Libraries:
sync-input(for synchronous user input handling)
Follow these steps to run the project locally on your machine.
- Node.js installed on your system.
-
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)
-
Navigate to the project directory:
cd hs-coffee-machine-js -
Install the dependencies:
npm install
Run the application using Node.js:
node index.jsDuring 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.
- Project provided by Hyperskill / JetBrains Academy.
Made with ☕ and code by David Alves.