Objective: Build a Python program that simulates the operation of a coffee machine simulation. This project will help you understand the basics of Python programming and how to use PyCharm for development.
Requirements:
- User Interaction:
- The program should start by asking the user, “What would you like? (espresso/latte/cappuccino):”
- It should repeatedly prompt the user until they choose to turn off the coffee machine.
- Turn Off the Machine:
- Users and maintainers can turn off the coffee machine by entering “off” as a command.
- Report:
- Users can request a report that displays the current resource levels of the coffee machine. For example:makefileCopy code
Water: 100ml Milk: 50ml Coffee: 76g Money: $2.5
- Users can request a report that displays the current resource levels of the coffee machine. For example:makefileCopy code
- Resource Availability:
- The program should check if there are enough resources (water, milk, coffee) to make the selected drink.
- If resources are insufficient, the program should print an appropriate message (e.g., “Sorry, not enough water”).
- Processing Coins:
- When the user selects a drink, the program should prompt them to insert coins.
- The program should accept quarters ($0.25), dimes ($0.10), nickels ($0.05), and pennies ($0.01).
- Calculate the total monetary value of the coins inserted.
- Transaction Handling:
- Check if the user has inserted enough money to purchase the selected drink.
- If they have, calculate the change if needed, add the money to the machine, and make the drink.
- If they haven’t inserted enough money, refund the money and display an appropriate message.
- Making Coffee:
- If the transaction is successful and resources are available, make the selected drink by deducting the required resources.
- Display a message like “Here is your latte. Enjoy!” if the user ordered a latte, for example.
Development Environment:
- Use PyCharm as your Integrated Development Environment (IDE) for this project.
- Create a new Python project in PyCharm.
- Create a Python script file within your project to write your coffee machine program.
- Use Git for version control if you’re familiar with it. If not, this project can be a great opportunity to learn Git and manage your code with version control.
Challenges:
- As a challenge, you can add more drink options and customize their ingredients and costs.
- Implement a mechanism to handle and give change back to the user.
- Add a feature to track the money earned by the coffee machine over multiple transactions.
- Create an interactive and user-friendly interface for the coffee machine program (advanced).
Testing:
- Test your coffee machine program with various scenarios to ensure it works correctly.
- Debug and fix any issues that arise during testing.
2 Responses