diff --git a/public/api/i/2025/09/18/119exsd-1.webp b/public/api/i/2025/09/18/119exsd-1.webp new file mode 100644 index 0000000..89469ec Binary files /dev/null and b/public/api/i/2025/09/18/119exsd-1.webp differ diff --git a/public/api/i/2025/09/18/8d4y9-1.webp b/public/api/i/2025/09/18/8d4y9-1.webp old mode 100644 new mode 100755 diff --git a/public/api/i/2025/09/18/8or7m-1.webp b/public/api/i/2025/09/18/8or7m-1.webp old mode 100644 new mode 100755 diff --git a/public/api/i/2025/09/20/10gf9ih-1.webp b/public/api/i/2025/09/20/10gf9ih-1.webp new file mode 100644 index 0000000..5e3b0d5 Binary files /dev/null and b/public/api/i/2025/09/20/10gf9ih-1.webp differ diff --git a/public/api/i/2025/09/20/10gsu60-1.webp b/public/api/i/2025/09/20/10gsu60-1.webp new file mode 100644 index 0000000..c705f73 Binary files /dev/null and b/public/api/i/2025/09/20/10gsu60-1.webp differ diff --git a/public/api/i/2025/09/20/10h4100-1.webp b/public/api/i/2025/09/20/10h4100-1.webp new file mode 100644 index 0000000..4e1eae6 Binary files /dev/null and b/public/api/i/2025/09/20/10h4100-1.webp differ diff --git a/public/api/i/2025/09/20/10hjla3-1.webp b/public/api/i/2025/09/20/10hjla3-1.webp new file mode 100644 index 0000000..5ac4cf6 Binary files /dev/null and b/public/api/i/2025/09/20/10hjla3-1.webp differ diff --git a/public/api/i/2025/09/20/10hnekj-1.webp b/public/api/i/2025/09/20/10hnekj-1.webp new file mode 100644 index 0000000..a0532eb Binary files /dev/null and b/public/api/i/2025/09/20/10hnekj-1.webp differ diff --git a/public/api/i/2025/09/20/10i2nlq-1.webp b/public/api/i/2025/09/20/10i2nlq-1.webp new file mode 100644 index 0000000..5e1b051 Binary files /dev/null and b/public/api/i/2025/09/20/10i2nlq-1.webp differ diff --git a/public/api/i/2025/09/20/10i6pio-1.webp b/public/api/i/2025/09/20/10i6pio-1.webp new file mode 100644 index 0000000..2140a17 Binary files /dev/null and b/public/api/i/2025/09/20/10i6pio-1.webp differ diff --git a/src/content/posts/设计模式/常见设计模式.md b/src/content/posts/设计模式/常见设计模式.md new file mode 100644 index 0000000..6b58198 --- /dev/null +++ b/src/content/posts/设计模式/常见设计模式.md @@ -0,0 +1,45 @@ +--- +title: 常见设计模式 +published: 2025-09-18 +description: '' +image: '' +tags: [] +category: '设计模式' +draft: false +lang: '' +--- + + +![](https://blog.meowrain.cn/api/i/2025/09/18/119exsd-1.webp) + + +# 策略模式 +现实生活中我们到商场买东西的时候,卖场往往根据不同的客户制定不同的报价策略,比如针对新客户不打折扣,针对老客户打9折,针对VIP客户打8折... + +现在我们要做一个报价管理的模块,简要点就是要针对不同的客户,提供不同的折扣报价。 +```java +package org.strategy; + +import java.math.BigDecimal; + +public class QuoteManager { + public BigDecimal quote(BigDecimal originalPrice, String customType){ + if ("新客户".equals(customType)) { + System.out.println("抱歉!新客户没有折扣!"); + return originalPrice; + }else if ("老客户".equals(customType)) { + System.out.println("恭喜你!老客户打9折!"); + originalPrice = originalPrice.multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP); + return originalPrice; + }else if("VIP客户".equals(customType)){ + System.out.println("恭喜你!VIP客户打8折!"); + originalPrice = originalPrice.multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP); + return originalPrice; + } + //其他人员都是原价 + return originalPrice; + } + +} + +``` \ No newline at end of file