当前位置: 编程技术>移动开发
本页文章导读:
▪Facade-门脸模式 Facade--门面模式
interface LetterProcess {
public void writeContext(String context);
public void fillEnvelope(String address);
public void letterIntoEnvelope();
public void sendLetter();
}
class PersonWriteLetter implements LetterProcess {.........
▪ Strategy - 计策模式 Strategy -- 策略模式
public interface Strategy {
public void operation();
}
/**
* 三条妙计
*/
class BackDoor implements Strategy {
@Override
public void operation() {
System.out.println("找乔国老帮忙");
}
}
class GivenGreenL.........
▪ 圆形菜单成效 圆形菜单效果
需要android3.0
......
[1]Facade-门脸模式
来源: 互联网 发布时间: 2014-02-18
Facade--门面模式
interface LetterProcess { public void writeContext(String context); public void fillEnvelope(String address); public void letterIntoEnvelope(); public void sendLetter(); } class PersonWriteLetter implements LetterProcess { @Override public void writeContext(String context) { // TODO Auto-generated method stub System.out.println("write the context:" + context); } @Override public void fillEnvelope(String address) { // TODO Auto-generated method stub System.out.println("fill Envelope with address:" + address); } @Override public void letterIntoEnvelope() { // TODO Auto-generated method stub System.out.println("put letter into Envelope"); } @Override public void sendLetter() { // TODO Auto-generated method stub System.out.println("send letter"); } } public class Facade { LetterProcess letterProcess = new PersonWriteLetter(); Police police = new Police(); public void sendLetter(String context, String address) { letterProcess.writeContext(context); letterProcess.fillEnvelope(address); letterProcess.letterIntoEnvelope(); //任何对LetterPress操作的过程可以放在门面中。如,警察检查信件 police.checkLetter(letterProcess); letterProcess.sendLetter(); }; } class Police{ void checkLetter(LetterProcess letterProcess){ } }
/** * 4.门面模式Facade */ System.out.println("***********4.门面模式***********"); Facade facade = new Facade(); facade.sendLetter("I Love u", "No.5 Street");
[2] Strategy - 计策模式
来源: 互联网 发布时间: 2014-02-18
Strategy -- 策略模式
public interface Strategy { public void operation(); } /** * 三条妙计 */ class BackDoor implements Strategy { @Override public void operation() { System.out.println("找乔国老帮忙"); } } class GivenGreenLight implements Strategy { @Override public void operation() { System.out.println("求吴国太开个绿灯"); } } class BlockEnemy implements Strategy { @Override public void operation() { System.out.println("孙夫人断后"); } } /** * 锦囊盛放妙计 */ class Context implements Strategy{ private Strategy mStrategy; public Context(Strategy s){ mStrategy = s; } @Override public void operation() { mStrategy.operation(); } }
/** * 1.策略模式 */ System.out.println("***********1.策略模式***********"); //生成第一个锦囊 Context context = new Context(new BackDoor()); System.out.println("使用第 1 条妙计:"); context.operation(); //生成第二个锦囊 context = new Context(new GivenGreenLight()); System.out.println("使用第 2 条妙计:"); context.operation(); //生成第三个锦囊 context = new Context(new BlockEnemy()); System.out.println("使用第 3 条妙计:"); context.operation(); System.out.println("");
[3] 圆形菜单成效
来源: 互联网 发布时间: 2014-02-18
圆形菜单效果
需要android3.0
需要android3.0
最新技术文章: