CSS Diner选择器练习网站答案

CSS Diner选择器练习网站答案

CSS Diner网址

答案

01. plate
02. bento 
03. #fancy 
04. plate apple 
05. #fancy pickle 
06. apple.small 
07. orange.small 
08. bento orange.small 
09. plate , bento 
10. * 
11. plate * 
12. plate + apple 
13. bento ~ pickle 
14. plate > apple 
15. plate orange:first-child 
16. plate *:only-child 
17. #fancy *:last-child , plate + pickle 
18. plate:nth-child(3) 
19. bento:nth-last-child(3) 
20. apple:first-of-type 
21. plate:nth-of-type(2n) 
22. plate:nth-of-type(2n+3) 
23. plate apple.small:only-of-type 
24. orange:last-of-type , apple:last-of-type 
25. bento:empty 
26. apple:not(.small) 
27. [for]
28. plate[for]
29. [for="Vitaly"]
30. [for^="Sa"]
31. [for$="ato"]
32. [for*= "obb"]
好的,我们可以使用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), "午餐"); // 另外一餐 // ... } } ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值