001package headfirst.facade.hometheater; 002 003public class HomeTheaterFacade { 004 Amplifier amp; 005 Tuner tuner; 006 DvdPlayer dvd; 007 CdPlayer cd; 008 Projector projector; 009 TheaterLights lights; 010 Screen screen; 011 PopcornPopper popper; 012 013 public HomeTheaterFacade(Amplifier amp, 014 Tuner tuner, 015 DvdPlayer dvd, 016 CdPlayer cd, 017 Projector projector, 018 Screen screen, 019 TheaterLights lights, 020 PopcornPopper popper) { 021 022 this.amp = amp; 023 this.tuner = tuner; 024 this.dvd = dvd; 025 this.cd = cd; 026 this.projector = projector; 027 this.screen = screen; 028 this.lights = lights; 029 this.popper = popper; 030 } 031 032 public void watchMovie(String movie) { 033 System.out.println("Get ready to watch a movie..."); 034 popper.on(); 035 popper.pop(); 036 lights.dim(10); 037 screen.down(); 038 projector.on(); 039 projector.wideScreenMode(); 040 amp.on(); 041 amp.setDvd(dvd); 042 amp.setSurroundSound(); 043 amp.setVolume(5); 044 dvd.on(); 045 dvd.play(movie); 046 } 047 048 049 public void endMovie() { 050 System.out.println("Shutting movie theater down..."); 051 popper.off(); 052 lights.on(); 053 screen.up(); 054 projector.off(); 055 amp.off(); 056 dvd.stop(); 057 dvd.eject(); 058 dvd.off(); 059 } 060 061 public void listenToCd(String cdTitle) { 062 System.out.println("Get ready for an audiopile experence..."); 063 lights.on(); 064 amp.on(); 065 amp.setVolume(5); 066 amp.setCd(cd); 067 amp.setStereoSound(); 068 cd.on(); 069 cd.play(cdTitle); 070 } 071 072 public void endCd() { 073 System.out.println("Shutting down CD..."); 074 amp.off(); 075 amp.setCd(cd); 076 cd.eject(); 077 cd.off(); 078 } 079 080 public void listenToRadio(double frequency) { 081 System.out.println("Tuning in the airwaves..."); 082 tuner.on(); 083 tuner.setFrequency(frequency); 084 amp.on(); 085 amp.setVolume(5); 086 amp.setTuner(tuner); 087 } 088 089 public void endRadio() { 090 System.out.println("Shutting down the tuner..."); 091 tuner.off(); 092 amp.off(); 093 } 094}