From 3fcf9f8b81e98865571848bf3174c5ca65bbfae7 Mon Sep 17 00:00:00 2001 From: chenjianqiang Date: Thu, 25 Nov 2021 13:57:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E5=90=88=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 ++++ .../CompositePattern/examples/README.md | 0 .../materials/CompositeMain.class | Bin 0 -> 1527 bytes .../CompositePattern/materials/README.md | 1 + .../materials/po/ClassRoom$Student.class | Bin 0 -> 1035 bytes .../materials/po/ClassRoom.class | Bin 0 -> 2524 bytes .../com/pattern/PatternApplication.class | Bin 421 -> 421 bytes .../CompositePattern/examples/README.md | 0 .../materials/CompositeMain.java | 21 ++++ .../CompositePattern/materials/README.md | 1 + .../materials/po/ClassRoom.java | 92 ++++++++++++++++++ .../pattern/FilterPattern/examples/README.md | 0 .../FilterPattern/materials/FilterMain.java | 13 +++ .../pattern/FilterPattern/materials/README.md | 0 src/com/pattern/PatternApplication.java | 8 +- .../materials/PrototypeMain.java | 2 +- 16 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 out/production/patterns/com/pattern/CompositePattern/examples/README.md create mode 100644 out/production/patterns/com/pattern/CompositePattern/materials/CompositeMain.class create mode 100644 out/production/patterns/com/pattern/CompositePattern/materials/README.md create mode 100644 out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom$Student.class create mode 100644 out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom.class create mode 100644 src/com/pattern/CompositePattern/examples/README.md create mode 100644 src/com/pattern/CompositePattern/materials/CompositeMain.java create mode 100644 src/com/pattern/CompositePattern/materials/README.md create mode 100644 src/com/pattern/CompositePattern/materials/po/ClassRoom.java create mode 100644 src/com/pattern/FilterPattern/examples/README.md create mode 100644 src/com/pattern/FilterPattern/materials/FilterMain.java create mode 100644 src/com/pattern/FilterPattern/materials/README.md diff --git a/README.md b/README.md index 2b3a716..4a5c90e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,27 @@ ----FactoryPattern 工厂模式 ----InterpreterPattern 解释器模式 ----StrategyPattern 策略模式 +----AdapterPattern 适配器模式 +----BridgePattern 桥接模式 +----BuilderPattern 构建者模式 +----PrototypePattern 原型模式 +----ProxyPattern 代理模式 +----SingletonPattern 单例模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 +----Pattern 模式 ``` ``` -----examples 贡献用户的真实业务代码案例 diff --git a/out/production/patterns/com/pattern/CompositePattern/examples/README.md b/out/production/patterns/com/pattern/CompositePattern/examples/README.md new file mode 100644 index 0000000..e69de29 diff --git a/out/production/patterns/com/pattern/CompositePattern/materials/CompositeMain.class b/out/production/patterns/com/pattern/CompositePattern/materials/CompositeMain.class new file mode 100644 index 0000000000000000000000000000000000000000..e44aebb7c93bc09911550942e7d6fb9e5969aebc GIT binary patch literal 1527 zcmbtUOHUI~6#g!+X~&UALGUdoN)cg@hp)jGAc~fU)TqSOrM=*o=}gm3Np$7XN1_X3 zq6rHZB<_s5Cz~5nkUtv6Vrpi=V5N(sWbH97$obP<+-1F_n@>c+TxTT^D6jw6&YI}a#Cq0Yr0~x z2&6dSCbzPB+R=wBp3P1ZbkmG*@k%$ZhFWK^`FJcN$lWn5c$DzQ!tUC^mdcsecYBtz#GwFqWX;?=9-New;d zCAtYGC&_q1$IVBAh(?2-{;H#l+b`pu`Xij*v?aooh6~{gY4Ck{S-Lo83ZQ<5m4h!E|U-=rk7#~y)LOegEng0BI8XLK~$7t&!7cE zG|=R)3`~wRdS0QOPAj9e^7sS7%$Xqb*P`rF-k?78D32P!>-0CFgRd`8O(+NPJ#9yy-JiH_j#Fn`uz?pccc3K%m}Z+~~7H3}a+hjk_4f1aU6IB<;&^6H~OR Lgf!5AiX;3JUUjDe literal 0 HcmV?d00001 diff --git a/out/production/patterns/com/pattern/CompositePattern/materials/README.md b/out/production/patterns/com/pattern/CompositePattern/materials/README.md new file mode 100644 index 0000000..e3a6f15 --- /dev/null +++ b/out/production/patterns/com/pattern/CompositePattern/materials/README.md @@ -0,0 +1 @@ +组合模式 diff --git a/out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom$Student.class b/out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom$Student.class new file mode 100644 index 0000000000000000000000000000000000000000..2882ca72b0d5143a28b730bc30ca3543031d1ffd GIT binary patch literal 1035 zcmbu8&u-H|5XQfCQkw)5m$V80q0l0w0pSDO0=+~6RYWbqRZ5SWbd|b_?Z|czj|CDH z5(gfDheCY2b&4tF0om>S77DKyREx{!He%N@KsD zM6)CdbM>ZhM3VkcPBVX&`2DHOvbRYRZ3OxJP{p}GHI|VQXbz6$d+ASQJn@4(4dY2q zr@7>!hPpr{Qy&CYN4WOhf#YRnAw^DqwcEsAtDhXT$- z%v*hkHSpg#o#}>&?8m0 zplWsggwotLxdYvW)^FI0J}`h1CZJtbSnO+wPI;rKx0I|LS`U(WI#w@3U3lZ{-k#|8 z3b@;GtWx7unS*tKr~gnst1g}a?(?o)zAlR&AC;N$;yErs;3}H5D_r>;h4ywoLwq!0 ztF*RpzCw$0_cQ=)T;odMI&RSF!&^q4(cMQU5TEF=pikF10X-^YvCSGT3F-t=q?G)A7BHupY*!Tl>h($ literal 0 HcmV?d00001 diff --git a/out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom.class b/out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom.class new file mode 100644 index 0000000000000000000000000000000000000000..0af088303fe8970fb7d929d0e3de94bcd2bad761 GIT binary patch literal 2524 zcmbtWTW=dh6#mAJy@|bc8z(WPP)HyJ+ezw{5>jvyNKFF)H%a3XXt+-7#oc1>TD$8= z;Ro=qHyJLH8+?VFTJ2PkIeCIotIpaV7z4tqS z7g3HNfS`gt6(NKfj^E&0JX_^PCA+eDLn}E9;aT0#oq2{}D!o2{ehesxsE9&kIA1br z**bR|%`&oivsO24-O*O1pvFnA^QxV#o7sGo+xD7i)))p#V!q648bhMcwpes5-KgY* zjktUNRi5qFFfw3EFT$8jfDgE?5@dF6g!s!61SHYeYp7 zk1_O1ESuc)fLsM}HW$U?IH}+X6;I+6L%fYAwi)_tmjH!eDT1dls$fjTGkBI^u+3jm zVoX;w9E2(uf0vr^rQ3y)Bu<3+FPa`QQcls^fQoi8mi>ACbeRY~3~6Nh63-O!dBwN1^s$~UVdNfgWy zudZ{t4YZcRKIghlwK)AK42f5?qETkt+d(LaluUTLrWvmMPk8ijL~Xy>AsL*uRS}0| zr@Pzrrps&H$B)WKSW_twZg=rI%5c+Zw~NVy(JA8XI~8w7&+9EC9cs<2(j_UG4RHm0 zZ7ALjfv21Fmq=4pP>awtmZ}Wo{84JL*M+8AWP8jQ=8lBU5Gy*o^x0)zm*p8LnhmR@ zE$X6xy>-4=utLvl@r14~CA1pJm2PHGPhgjwSgV**kw1?qeT-`;}l*TX>sBVKqxDu@}nxis4%{2|ySKyTTJL zpz0lvfSxl2l3m8K1X-m~xEvO=U7A4`MZC?R2PuS8E>hAv)uI-b0a~F`o)sa<6Sik% zm1bA4M&E9#N;lQf9#k2Mn3Kx$eu_#vk{-ozqImit6h+QNjIQFH9zIRwgfy89E7~aKul0kP;mtK{NUSXxnJFR^ zyN&S{uN@4E`NUm3A0Uzww{~$h@zQNv*u}gc?BzH?MJWD=4Plx}e}-QF3qI3Rtz1vx eeSAPBKXf(O7+L*@rU876PiTzL7N?t2!oYv students; + private String className; + private Integer studentSize; + + public ClassRoom(String className, Integer studentSize) { + this.className = className; + this.studentSize = studentSize; + this.students = new ArrayList<>(); + } + + public List getStudents() { + return students; + } + + public void setStudents(List students) { + this.students = students; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Integer getStudentSize() { + return studentSize; + } + + public Integer countStudentSize() { + return students.size(); + } + + public void setStudentSize(Integer studentSize) { + this.studentSize = studentSize; + } + + public Boolean addStudent(Student student) { + if (studentSize >= students.size()) { + return students.add(student); + } else { + System.err.println("教室已经满员,塞不进去了"); + return Boolean.FALSE; + } + } + + /** + * 学生 + */ + public static class Student { + private String name; + /** + * 1 男 2女 + */ + private Integer sex; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public Student(String name, Integer sex) { + this.name = name; + this.sex = sex; + } + } + +} diff --git a/src/com/pattern/FilterPattern/examples/README.md b/src/com/pattern/FilterPattern/examples/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/com/pattern/FilterPattern/materials/FilterMain.java b/src/com/pattern/FilterPattern/materials/FilterMain.java new file mode 100644 index 0000000..5161371 --- /dev/null +++ b/src/com/pattern/FilterPattern/materials/FilterMain.java @@ -0,0 +1,13 @@ +package com.pattern.FilterPattern.materials; + +/** + * 过滤器模式 + * + * @author lx + * @date 2021/11/25 13:56 + **/ +public class FilterMain { + public static void main(String[] args) { + + } +} diff --git a/src/com/pattern/FilterPattern/materials/README.md b/src/com/pattern/FilterPattern/materials/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/com/pattern/PatternApplication.java b/src/com/pattern/PatternApplication.java index bf5d121..a8accd3 100644 --- a/src/com/pattern/PatternApplication.java +++ b/src/com/pattern/PatternApplication.java @@ -100,10 +100,16 @@ public class PatternApplication { /* 11.过滤模式 - new BuilderMain().main(); + new FilterMain().main(); 2021-11-24:实现同一个抽象类为不同的方法,使用不同的实例处理相同的数据出来不同的结果 */ + + /* + 12.组合模式 + new CompositeMain().main(); + 2021-11-25:一个实体包含了小规模业务 + */ } } diff --git a/src/com/pattern/PrototypePattern/materials/PrototypeMain.java b/src/com/pattern/PrototypePattern/materials/PrototypeMain.java index f916b5d..52c4bb1 100644 --- a/src/com/pattern/PrototypePattern/materials/PrototypeMain.java +++ b/src/com/pattern/PrototypePattern/materials/PrototypeMain.java @@ -4,7 +4,7 @@ import com.pattern.PrototypePattern.materials.po.Shape; import com.pattern.PrototypePattern.materials.po.ShapeCache; /** - * 主进程 + * 原型模式 * @author lx * @date 2021/11/24 14:54 **/ -- GitLab