001package headfirst.facade.hometheater;
002
003public class DvdPlayer {
004        String description;
005        int currentTrack;
006        Amplifier amplifier;
007        String movie;
008
009        public DvdPlayer(String description, Amplifier amplifier) {
010                this.description = description;
011                this.amplifier = amplifier;
012        }
013
014        public void on() {
015                System.out.println(description + " on");
016        }
017
018        public void off() {
019                System.out.println(description + " off");
020        }
021
022        public void eject() {
023                movie = null;
024                System.out.println(description + " eject");
025        }
026
027        public void play(String movie) {
028                this.movie = movie;
029                currentTrack = 0;
030                System.out.println(description + " playing \"" + movie + "\"");
031        }
032
033        public void play(int track) {
034                if (movie == null) {
035                        System.out.println(description + " can't play track " + track + " no dvd inserted");
036                } else {
037                        currentTrack = track;
038                        System.out.println(description + " playing track " + currentTrack + " of \"" + movie + "\"");
039                }
040        }
041
042        public void stop() {
043                currentTrack = 0;
044                System.out.println(description + " stopped \"" + movie + "\"");
045        }
046
047        public void pause() {
048                System.out.println(description + " paused \"" + movie + "\"");
049        }
050
051        public void setTwoChannelAudio() {
052                System.out.println(description + " set two channel audio");
053        }
054
055        public void setSurroundAudio() {
056                System.out.println(description + " set surround audio");
057        }
058
059        public String toString() {
060                return description;
061        }
062}