📅  最后修改于: 2023-12-03 15:23:00.622000             🧑  作者: Mango
咖啡,一种由咖啡豆制成的饮料,常见于世界各地。
咖啡豆是咖啡的原材料,通常由咖啡果中取出,经过去皮、去果肉、发酵、清洗、烘焙等工序制成。
public class CoffeeBean {
private String name; // 咖啡豆名称
private String origin; // 原产地
private String variety;// 品种
public CoffeeBean(String name, String origin, String variety) {
this.name = name;
this.origin = origin;
this.variety = variety;
}
// getters and setters
}
咖啡因是咖啡中的一种生物碱,具有兴奋作用,也是咖啡的主要成分之一。
def getCaffeineAmount(amount, unit='oz'):
if unit.lower() == 'ml':
amount = amount * 0.0338
if amount <= 0:
return 'Error: Invalid amount'
caffeine = amount * 95 # 一般一杯8oz的咖啡含有95mg咖啡因
return '{} mg caffeine'.format(caffeine)
咖啡有很多种类,常见的包括:
class Coffee {
constructor(type, milkType, size) {
this.type = type;
this.milkType = milkType;
this.size = size;
}
getDescription() {
return `${this.size} ${this.type} with ${this.milkType} milk`;
}
}
let order = new Coffee('Espresso', 'Whole', 'Large');
console.log(order.getDescription()); // Large Espresso with Whole milk
咖啡不仅仅是一种饮料,更是一种文化。咖啡文化的代表有:
class CoffeeShop
def initialize(name, city)
@name = name
@city = city
@menu = {}
end
def addMenuItem(itemName, price)
@menu[itemName] = price
end
def printMenu
puts "#{@name} Menu:"
@menu.each do |item, price|
puts "#{item}: $#{price}"
end
end
end
coffeeShop = CoffeeShop.new('The Coffee Shop', 'New York')
coffeeShop.addMenuItem('Espresso', 2.50)
coffeeShop.addMenuItem('Cappuccino', 3.50)
coffeeShop.printMenu
# The Coffee Shop Menu:
# Espresso: $2.5
# Cappuccino: $3.5