CSS Diner 选择器练习

地址:http://flukeout.github.io/

答案:

plate
bento 
#fancy 
plate apple 
#fancy pickle 
apple.small 
orange.small 
bento orange.small 
plate , bento 
* 
plate * 
plate + apple 
bento ~ pickle 
plate > apple 
plate orange:first-child 
plate *:only-child 
#fancy *:last-child , plate + pickle 
plate:nth-child(3) 
bento:nth-last-child(3) 
apple:first-of-type 
plate:nth-of-type(2n) 
plate:nth-of-type(2n+3) 
plate apple.small:only-of-type 
orange:last-of-type , apple:last-of-type 
bento:empty 
apple:not(.small) 
[for]
plate[for]
[for="Vitaly"]
[for^="Sam"] , [for^="Sarah"]  或者  [for^="Sa"]  或者  [for^="S"]
[for$="Hayato"],[for$="Minato"]  或者  [for$="to"]  或者  [for$="o"]
[for*="Robbie"],[for*="Bobby"]  或者  [for*="obb"]  或者  [for*="bb"]  或者  [for*="ob"]  或者  [for*="o"]  或者  [for*="b"]
好的,我们可以使用Java设计一个简单的命令模式或者策略模式来实现这个食堂点餐程序。这里我将提供一个基础的伪代码示例: ```java // 餐品接口 interface Food { double getPrice(); } // 具体餐品类,实现Food接口 class Rice implements Food { private double price; public Rice(double price) { this.price = price; } @Override public double getPrice() { return price; } } class Noodle implements Food { // 类似于Rice,定义其他菜品的价格 // ... } class Dumpling implements Food { // ... } // 时间策略类,包含折扣规则 class DiscountStrategy { double breakfastDiscount = 0.9; public double applyDiscount(Food food, String mealTime) { if ("早餐".equals(mealTime)) { return food.getPrice() * breakfastDiscount; } else { return food.getPrice(); } } } // 点餐类 class Diner { int maxOrderCount = 5; DiscountStrategy strategy = new DiscountStrategy(); void order(Food food, String mealTime) { double discountedPrice = strategy.applyDiscount(food, mealTime); if (getTotalOrders() >= maxOrderCount) { System.out.println("您已经达到了最大购买数量,请减少一些餐品。"); } else { System.out.printf("您选择了%T, 折扣后的价格为%.2f元。\n", food, discountedPrice); // 添加到购物车或处理订单逻辑 } } private int getTotalOrders() { // 计算已点餐品的数量 // ... } } public class Main { public static void main(String[] args) { Diner diner = new Diner(); diner.order(new Rice(10), "早餐"); // 示例点餐 diner.order(new Noodle(15), "午餐"); // 另外一餐 // ... } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值