cdplayer.java
来自「深入浅出设计模式」· Java 代码 · 共 56 行
JAVA
56 行
package headfirst.facade.hometheater;public class CdPlayer { String description; int currentTrack; Amplifier amplifier; String title; public CdPlayer(String description, Amplifier amplifier) { this.description = description; this.amplifier = amplifier; } public void on() { System.out.println(description + " on"); } public void off() { System.out.println(description + " off"); } public void eject() { title = null; System.out.println(description + " eject"); } public void play(String title) { this.title = title; currentTrack = 0; System.out.println(description + " playing \"" + title + "\""); } public void play(int track) { if (title == null) { System.out.println(description + " can't play track " + currentTrack + ", no cd inserted"); } else { currentTrack = track; System.out.println(description + " playing track " + currentTrack); } } public void stop() { currentTrack = 0; System.out.println(description + " stopped"); } public void pause() { System.out.println(description + " paused \"" + title + "\""); } public String toString() { return description; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?