Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
QZero_0
java-design-patterns
提交
84d14edc
J
java-design-patterns
项目概览
QZero_0
/
java-design-patterns
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
java-design-patterns
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
84d14edc
编写于
8月 13, 2015
作者:
I
Ilkka Seppala
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#84 Added view layer
上级
2a46b691
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
10 deletion
+28
-10
layers/src/main/java/com/iluwatar/layers/App.java
layers/src/main/java/com/iluwatar/layers/App.java
+14
-10
layers/src/main/java/com/iluwatar/layers/CakeView.java
layers/src/main/java/com/iluwatar/layers/CakeView.java
+14
-0
未找到文件。
layers/src/main/java/com/iluwatar/layers/App.java
浏览文件 @
84d14edc
...
...
@@ -5,24 +5,28 @@ import java.util.Arrays;
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
CakeBakingService
service
=
new
CakeBakingServiceImpl
();
service
.
saveNewLayer
(
new
CakeLayerInfo
(
"chocolate"
,
1200
));
service
.
saveNewLayer
(
new
CakeLayerInfo
(
"banana"
,
900
));
service
.
saveNewLayer
(
new
CakeLayerInfo
(
"strawberry"
,
950
));
service
.
getAllLayers
().
stream
().
forEach
((
layer
)
->
System
.
out
.
println
(
layer
));
CakeBakingService
cakeBakingService
=
new
CakeBakingServiceImpl
();
initializeData
(
cakeBakingService
);
CakeView
cakeView
=
new
CakeView
(
cakeBakingService
);
cakeView
.
render
();
}
private
static
void
initializeData
(
CakeBakingService
cakeBakingService
)
{
cakeBakingService
.
saveNewLayer
(
new
CakeLayerInfo
(
"chocolate"
,
1200
));
cakeBakingService
.
saveNewLayer
(
new
CakeLayerInfo
(
"banana"
,
900
));
cakeBakingService
.
saveNewLayer
(
new
CakeLayerInfo
(
"strawberry"
,
950
));
cakeBakingService
.
getAllLayers
().
stream
().
forEach
((
layer
)
->
System
.
out
.
println
(
layer
));
s
ervice
.
saveNewTopping
(
new
CakeToppingInfo
(
"candies"
,
350
));
s
ervice
.
getAllToppings
().
stream
().
forEach
((
topping
)
->
System
.
out
.
println
(
topping
));
cakeBakingS
ervice
.
saveNewTopping
(
new
CakeToppingInfo
(
"candies"
,
350
));
cakeBakingS
ervice
.
getAllToppings
().
stream
().
forEach
((
topping
)
->
System
.
out
.
println
(
topping
));
CakeInfo
cakeInfo
=
new
CakeInfo
(
new
CakeToppingInfo
(
"candies"
,
0
),
Arrays
.
asList
(
new
CakeLayerInfo
(
"chocolate"
,
0
),
new
CakeLayerInfo
(
"banana"
,
0
),
new
CakeLayerInfo
(
"strawberry"
,
0
)));
try
{
s
ervice
.
bakeNewCake
(
cakeInfo
);
cakeBakingS
ervice
.
bakeNewCake
(
cakeInfo
);
}
catch
(
CakeBakingException
e
)
{
e
.
printStackTrace
();
}
service
.
getAllCakes
().
stream
().
forEach
((
cake
)
->
System
.
out
.
println
(
cake
));
}
}
layers/src/main/java/com/iluwatar/layers/CakeView.java
0 → 100644
浏览文件 @
84d14edc
package
com.iluwatar.layers
;
public
class
CakeView
{
private
CakeBakingService
cakeBakingService
;
public
CakeView
(
CakeBakingService
cakeBakingService
)
{
this
.
cakeBakingService
=
cakeBakingService
;
}
public
void
render
()
{
cakeBakingService
.
getAllCakes
().
stream
().
forEach
((
cake
)
->
System
.
out
.
println
(
cake
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录