| package com.atguigu.facade; |
| public class DVDPlayer { |
| |
| |
| private static DVDPlayer instance = new DVDPlayer(); |
| |
| public static DVDPlayer getInstanc() { |
| 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 is playing "); |
| } |
| |
| public void pause() { |
| System.out.println(" dvd pause .."); |
| } |
| } |
| |
| package com.atguigu.facade; |
| public class Popcorn { |
| |
| private static Popcorn instance = new Popcorn(); |
| |
| public static Popcorn getInstance() { |
| return instance; |
| } |
| |
| public void on() { |
| System.out.println(" popcorn on "); |
| } |
| |
| public void off() { |
| System.out.println(" popcorn ff "); |
| } |
| |
| public void pop() { |
| System.out.println(" popcorn is poping "); |
| } |
| } |
| |
| package com.atguigu.facade; |
| public class Projector { |
| |
| private static Projector instance = new Projector(); |
| |
| public static Projector getInstance() { |
| return instance; |
| } |
| |
| public void on() { |
| System.out.println(" Projector on "); |
| } |
| |
| public void off() { |
| System.out.println(" Projector ff "); |
| } |
| |
| public void focus() { |
| System.out.println(" Projector is Projector "); |
| } |
| |
| } |
| |
| package com.atguigu.facade; |
| public class Screen { |
| |
| private static Screen instance = new Screen(); |
| |
| public static Screen getInstance() { |
| return instance; |
| } |
| |
| public void up() { |
| System.out.println(" Screen up "); |
| } |
| |
| public void down() { |
| System.out.println(" Screen down "); |
| } |
| |
| } |
| |
| package com.atguigu.facade; |
| public class Stereo { |
| |
| private static Stereo instance = new Stereo(); |
| |
| public static Stereo getInstance() { |
| return instance; |
| } |
| |
| public void on() { |
| System.out.println(" Stereo on "); |
| } |
| |
| public void off() { |
| System.out.println(" Screen off "); |
| } |
| |
| public void up() { |
| System.out.println(" Screen up.. "); |
| } |
| |
| } |
| |
| package com.atguigu.facade; |
| public class TheaterLight { |
| |
| private static TheaterLight instance = new TheaterLight(); |
| |
| public static TheaterLight getInstance() { |
| return instance; |
| } |
| |
| public void on() { |
| System.out.println(" TheaterLight on "); |
| } |
| |
| public void off() { |
| System.out.println(" TheaterLight off "); |
| } |
| |
| public void dim() { |
| System.out.println(" TheaterLight dim.. "); |
| } |
| |
| public void bright() { |
| System.out.println(" TheaterLight bright.. "); |
| } |
| } |
| |
| package com.atguigu.facade; |
| public class HomeTheaterFacade { |
| |
| |
| private TheaterLight theaterLight; |
| private Popcorn popcorn; |
| private Stereo stereo; |
| private Projector projector; |
| private Screen screen; |
| private DVDPlayer dVDPlayer; |
| |
| |
| public HomeTheaterFacade() { |
| super(); |
| this.theaterLight = TheaterLight.getInstance(); |
| this.popcorn = Popcorn.getInstance(); |
| this.stereo = Stereo.getInstance(); |
| this.projector = Projector.getInstance(); |
| this.screen = Screen.getInstance(); |
| this.dVDPlayer = DVDPlayer.getInstanc(); |
| } |
| |
| |
| public void ready() { |
| popcorn.on(); |
| popcorn.pop(); |
| screen.down(); |
| projector.on(); |
| stereo.on(); |
| dVDPlayer.on(); |
| theaterLight.dim(); |
| } |
| |
| public void play() { |
| dVDPlayer.play(); |
| } |
| |
| public void pause() { |
| dVDPlayer.pause(); |
| } |
| |
| public void end() { |
| popcorn.off(); |
| theaterLight.bright(); |
| screen.up(); |
| projector.off(); |
| stereo.off(); |
| dVDPlayer.off(); |
| } |
| |
| } |
| |
| package com.atguigu.facade; |
| public class Client { |
| |
| public static void main(String[] args) { |
| HomeTheaterFacade homeTheaterFacade = new HomeTheaterFacade(); |
| homeTheaterFacade.ready(); |
| homeTheaterFacade.play(); |
| homeTheaterFacade.end(); |
| } |
| |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
2021-08-31 vue开发:前端项目模板