类全部变成咖啡杯

问题描述

新版IDEA中,module模块无法被识别,类全部变成咖啡杯无法被识

解决方案:

java的Directory文件没有被设置为根目录,解决方法如下:

在这里插入图片描述

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Python实现咖啡机的示例代码: ```python class CoffeeMachine: def __init__(self, water, milk, coffee_beans, cups, money): self.water = water self.milk = milk self.coffee_beans = coffee_beans self.cups = cups self.money = money def make_coffee(self, water_needed, milk_needed, beans_needed, cost): if self.water < water_needed: print("Sorry, not enough water!") elif self.milk < milk_needed: print("Sorry, not enough milk!") elif self.coffee_beans < beans_needed: print("Sorry, not enough coffee beans!") elif self.cups < 1: print("Sorry, not enough cups!") else: print("I have enough resources, making you a coffee!") self.water -= water_needed self.milk -= milk_needed self.coffee_beans -= beans_needed self.cups -= 1 self.money += cost def buy(self): choice = input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino: ") if choice == "1": self.make_coffee(250, 0, 16, 4) elif choice == "2": self.make_coffee(350, 75, 20, 7) elif choice == "3": self.make_coffee(200, 100, 12, 6) else: print("Invalid choice!") def fill(self): self.water += int(input("How many ml of water do you want to add? ")) self.milk += int(input("How many ml of milk do you want to add? ")) self.coffee_beans += int(input("How many grams of coffee beans do you want to add? ")) self.cups += int(input("How many disposable cups do you want to add? ")) def take(self): print("I gave you $", self.money) self.money = 0 def remaining(self): print("The coffee machine has:") print(self.water, "of water") print(self.milk, "of milk") print(self.coffee_beans, "of coffee beans") print(self.cups, "of disposable cups") print("$", self.money, "of money") # 创建一个咖啡机对象 my_machine = CoffeeMachine(400, 540, 120, 9, 550) # 与用户交互 while True: action = input("What would you like to do? (buy, fill, take, remaining, exit): ") if action == "buy": my_machine.buy() elif action == "fill": my_machine.fill() elif action == "take": my_machine.take() elif action == "remaining": my_machine.remaining() elif action == "exit": break else: print("Invalid action!") ``` 该代码创建了一个名为`CoffeeMachine`的,该具有制作咖啡、购买咖啡、填充咖啡机、取走咖啡机中的钱和显示咖啡机状态等方法。在的构造函数中,我们初始化了咖啡机的水、牛奶、咖啡豆、杯子和钱的数量。然后,我们使用一个无限循环与用户交互,直到用户选择退出。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值