Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lsh
patterns
提交
3fcf9f8b
P
patterns
项目概览
lsh
/
patterns
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
patterns
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3fcf9f8b
编写于
11月 25, 2021
作者:
C
chenjianqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加组合模式
上级
5c0b331c
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
157 addition
and
2 deletion
+157
-2
README.md
README.md
+21
-0
out/production/patterns/com/pattern/CompositePattern/examples/README.md
.../patterns/com/pattern/CompositePattern/examples/README.md
+0
-0
out/production/patterns/com/pattern/CompositePattern/materials/CompositeMain.class
...om/pattern/CompositePattern/materials/CompositeMain.class
+0
-0
out/production/patterns/com/pattern/CompositePattern/materials/README.md
...patterns/com/pattern/CompositePattern/materials/README.md
+1
-0
out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom$Student.class
...ern/CompositePattern/materials/po/ClassRoom$Student.class
+0
-0
out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom.class
...com/pattern/CompositePattern/materials/po/ClassRoom.class
+0
-0
out/production/patterns/com/pattern/PatternApplication.class
out/production/patterns/com/pattern/PatternApplication.class
+0
-0
src/com/pattern/CompositePattern/examples/README.md
src/com/pattern/CompositePattern/examples/README.md
+0
-0
src/com/pattern/CompositePattern/materials/CompositeMain.java
...com/pattern/CompositePattern/materials/CompositeMain.java
+21
-0
src/com/pattern/CompositePattern/materials/README.md
src/com/pattern/CompositePattern/materials/README.md
+1
-0
src/com/pattern/CompositePattern/materials/po/ClassRoom.java
src/com/pattern/CompositePattern/materials/po/ClassRoom.java
+92
-0
src/com/pattern/FilterPattern/examples/README.md
src/com/pattern/FilterPattern/examples/README.md
+0
-0
src/com/pattern/FilterPattern/materials/FilterMain.java
src/com/pattern/FilterPattern/materials/FilterMain.java
+13
-0
src/com/pattern/FilterPattern/materials/README.md
src/com/pattern/FilterPattern/materials/README.md
+0
-0
src/com/pattern/PatternApplication.java
src/com/pattern/PatternApplication.java
+7
-1
src/com/pattern/PrototypePattern/materials/PrototypeMain.java
...com/pattern/PrototypePattern/materials/PrototypeMain.java
+1
-1
未找到文件。
README.md
浏览文件 @
3fcf9f8b
...
@@ -8,6 +8,27 @@
...
@@ -8,6 +8,27 @@
----FactoryPattern 工厂模式
----FactoryPattern 工厂模式
----InterpreterPattern 解释器模式
----InterpreterPattern 解释器模式
----StrategyPattern 策略模式
----StrategyPattern 策略模式
----AdapterPattern 适配器模式
----BridgePattern 桥接模式
----BuilderPattern 构建者模式
----PrototypePattern 原型模式
----ProxyPattern 代理模式
----SingletonPattern 单例模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
----Pattern 模式
```
```
```
```
-----examples 贡献用户的真实业务代码案例
-----examples 贡献用户的真实业务代码案例
...
...
out/production/patterns/com/pattern/CompositePattern/examples/README.md
0 → 100644
浏览文件 @
3fcf9f8b
out/production/patterns/com/pattern/CompositePattern/materials/CompositeMain.class
0 → 100644
浏览文件 @
3fcf9f8b
文件已添加
out/production/patterns/com/pattern/CompositePattern/materials/README.md
0 → 100644
浏览文件 @
3fcf9f8b
组合模式
out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom$Student.class
0 → 100644
浏览文件 @
3fcf9f8b
文件已添加
out/production/patterns/com/pattern/CompositePattern/materials/po/ClassRoom.class
0 → 100644
浏览文件 @
3fcf9f8b
文件已添加
out/production/patterns/com/pattern/PatternApplication.class
浏览文件 @
3fcf9f8b
无法预览此类型文件
src/com/pattern/CompositePattern/examples/README.md
0 → 100644
浏览文件 @
3fcf9f8b
src/com/pattern/CompositePattern/materials/CompositeMain.java
0 → 100644
浏览文件 @
3fcf9f8b
package
com.pattern.CompositePattern.materials
;
import
com.pattern.CompositePattern.materials.po.ClassRoom
;
/**
* 组合模式
* @author lx
* @date 2021/11/25 13:44
**/
public
class
CompositeMain
{
public
void
main
()
{
ClassRoom
classRoom
=
new
ClassRoom
(
"教室001"
,
1
);
classRoom
.
addStudent
(
new
ClassRoom
.
Student
(
"张开花"
,
1
));
classRoom
.
addStudent
(
new
ClassRoom
.
Student
(
"王大瓜"
,
2
));
classRoom
.
addStudent
(
new
ClassRoom
.
Student
(
"刘小艺"
,
2
));
System
.
out
.
println
(
"教室有"
+
classRoom
.
countStudentSize
()
+
"人"
);
}
}
src/com/pattern/CompositePattern/materials/README.md
0 → 100644
浏览文件 @
3fcf9f8b
组合模式
src/com/pattern/CompositePattern/materials/po/ClassRoom.java
0 → 100644
浏览文件 @
3fcf9f8b
package
com.pattern.CompositePattern.materials.po
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 教室
*
* @author lx
* @date 2021/11/25 13:41
**/
public
class
ClassRoom
{
private
List
<
Student
>
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
<
Student
>
getStudents
()
{
return
students
;
}
public
void
setStudents
(
List
<
Student
>
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
;
}
}
}
src/com/pattern/FilterPattern/examples/README.md
0 → 100644
浏览文件 @
3fcf9f8b
src/com/pattern/FilterPattern/materials/FilterMain.java
0 → 100644
浏览文件 @
3fcf9f8b
package
com.pattern.FilterPattern.materials
;
/**
* 过滤器模式
*
* @author lx
* @date 2021/11/25 13:56
**/
public
class
FilterMain
{
public
static
void
main
(
String
[]
args
)
{
}
}
src/com/pattern/FilterPattern/materials/README.md
0 → 100644
浏览文件 @
3fcf9f8b
src/com/pattern/PatternApplication.java
浏览文件 @
3fcf9f8b
...
@@ -100,10 +100,16 @@ public class PatternApplication {
...
@@ -100,10 +100,16 @@ public class PatternApplication {
/*
/*
11.过滤模式
11.过滤模式
new
Build
erMain().main();
new
Filt
erMain().main();
2021-11-24:实现同一个抽象类为不同的方法,使用不同的实例处理相同的数据出来不同的结果
2021-11-24:实现同一个抽象类为不同的方法,使用不同的实例处理相同的数据出来不同的结果
*/
*/
/*
12.组合模式
new CompositeMain().main();
2021-11-25:一个实体包含了小规模业务
*/
}
}
}
}
src/com/pattern/PrototypePattern/materials/PrototypeMain.java
浏览文件 @
3fcf9f8b
...
@@ -4,7 +4,7 @@ import com.pattern.PrototypePattern.materials.po.Shape;
...
@@ -4,7 +4,7 @@ import com.pattern.PrototypePattern.materials.po.Shape;
import
com.pattern.PrototypePattern.materials.po.ShapeCache
;
import
com.pattern.PrototypePattern.materials.po.ShapeCache
;
/**
/**
*
主进程
*
原型模式
* @author lx
* @author lx
* @date 2021/11/24 14:54
* @date 2021/11/24 14:54
**/
**/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录