标签:oid desc pattern esc use layer load play lang
//DVDPlayer.java
public class DVDPlayer {
private static DVDPlayer instance = new DVDPlayer();
public static DVDPlayer getInstance(){
return instance;
}
public void on(){
System.out.println("DVD ON");
}
public void off(){
System.out.println("DVD OFF");
}
public void play(){
System.out.println("DVD PLAY");
}
public void pause(){
System.out.println("DVD PAUSE");
}
}
//Poncorn.java
public class Poncorn {
private static Poncorn instance = new Poncorn();
public static Poncorn getInstance(){
return instance;
}
public void on(){
System.out.println("Popcorn ON");
}
public void off(){
System.out.println("Popcorn OFF");
}
public void pop(){
System.out.println("Popcorn POP");
}
}
// Projection.java
public class Projection {
private static Projection instance = new Projection();
public static Projection getInstance(){
return instance;
}
public void on(){
System.out.println("Projection ON");
}
public void off(){
System.out.println("Projection OFF");
}
public void projection(){
System.out.println("Projection project");
}
}
//Facade.java
public class Facede {
private DVDPlayer dvdPlayer;
private Poncorn poncorn;
private Projection projection;
public Facede(){
this.dvdPlayer = DVDPlayer.getInstance();
this.poncorn = Poncorn.getInstance();
this.projection = Projection.getInstance();
}
public void on(){
dvdPlayer.on();
poncorn.on();
projection.on();
}
public void off(){
dvdPlayer.off();
poncorn.off();
projection.off();
}
public void play(){
dvdPlayer.play();
}
public void pause(){
dvdPlayer.pause();
}
public void pop(){
poncorn.pop();
}
public void projection(){
projection.projection();
}
}
//Client.java
public class Client {
public static void main(String[] args) {
Facede facede = new Facede();
facede.on();
facede.play();
facede.pop();
facede.projection();
facede.off();
}
}
标签:oid desc pattern esc use layer load play lang
原文地址:https://www.cnblogs.com/nedrain/p/13199308.html