装饰设计模式
来源:互联网 发布:下载了软件打不开 编辑:程序博客网 时间:2024/05/29 07:38
package cn.mdln.demo;
/**
* 装饰设计模式(组合)
* @author Administrator
*
*/
public class Demo8 {
public static void main(String[] args) {
Voice voice=new Voice(10);
voice.say();
EnlargeVoice en=new EnlargeVoice(10,voice);
en.say();
}
}
class Voice
{
private int voice;
public Voice(int voice) {
super();
this.voice = voice;
}
public int getVoice() {
return voice;
}
public void setVoice(int voice) {
this.voice = voice;
}
public void say()
{
System.out.println("原音量:"+getVoice());
}
}
class EnlargeVoice
{
private int enlargevoice;
private Voice voice;
public EnlargeVoice(int enlargevoice,Voice voice) {
this.enlargevoice=enlargevoice;
this.voice = voice;
}
public int getVoice() {
return enlargevoice;
}
public void setVoice(int enlargevoice) {
this. enlargevoice= enlargevoice;
}
public void say()
{
System.out.println("扩音器的音量:"+voice.getVoice()*100);
}
}
/**
* 装饰设计模式(组合)
* @author Administrator
*
*/
public class Demo8 {
public static void main(String[] args) {
Voice voice=new Voice(10);
voice.say();
EnlargeVoice en=new EnlargeVoice(10,voice);
en.say();
}
}
class Voice
{
private int voice;
public Voice(int voice) {
super();
this.voice = voice;
}
public int getVoice() {
return voice;
}
public void setVoice(int voice) {
this.voice = voice;
}
public void say()
{
System.out.println("原音量:"+getVoice());
}
}
class EnlargeVoice
{
private int enlargevoice;
private Voice voice;
public EnlargeVoice(int enlargevoice,Voice voice) {
this.enlargevoice=enlargevoice;
this.voice = voice;
}
public int getVoice() {
return enlargevoice;
}
public void setVoice(int enlargevoice) {
this. enlargevoice= enlargevoice;
}
public void say()
{
System.out.println("扩音器的音量:"+voice.getVoice()*100);
}
}
0 0
- 设计模式---装饰模式
- 设计模式:装饰模式
- 设计模式------装饰模式
- 设计模式--装饰模式
- 设计模式--装饰模式
- 设计模式--装饰模式
- 设计模式 装饰模式
- 设计模式----装饰模式
- 设计模式-【装饰模式】
- 设计模式--装饰模式
- 设计模式装饰模式
- 设计模式 - 装饰模式
- 设计模式-----装饰模式.
- 设计模式-----装饰模式.
- [ 设计模式 ] 装饰模式!
- 设计模式:装饰模式
- 设计模式 - 装饰模式
- 设计模式 - 装饰模式
- android 填充 singlechoiceitems 对话框使用 arraylist 值
- Java数据类型
- Android 教程连接
- 如果要实现--画中画,图片合并,OSD,跨平台等,那么,SDL是个很好的选择!
- 快排的优化(简直神乎其神了!!!)
- 装饰设计模式
- AS中如何使用GsonFormat插件
- 随手记-数据库太大篇
- Unity3D C#代码注释规范及文档生成
- 顺序表合并
- C语言++i和i++
- 显示一个打开过的页面
- Java 学习(一)基本操作
- 淘淘商城---8.6