module cdplayer; import amplifier; import std.stdio : writeln; import std.conv : to; class CdPlayer { private string description; private int currentTrack; private Amplifier amplifier; private string title; this(string description, Amplifier amplifier) { this.description = description; this.amplifier = amplifier; } void on() { writeln(description ~ " on"); } void off() { writeln(description ~ " off"); } void eject() { title = null; writeln(description ~ " eject"); } void play(string title) { this.title = title; currentTrack = 0; writeln(description ~ " playing \"" ~ title ~ "\""); } void play(int track) { if (title is null) { writeln(description ~ " can't play track " ~ currentTrack.to!string ~ " no cd inserted"); } else { currentTrack = track; writeln(description ~ " playing track " ~ currentTrack.to!string); } } void stop() { currentTrack = 0; writeln(description ~ " stopped"); } void pause() { writeln(description ~ " paused \"" ~ title ~ "\""); } override string toString() const { return description; } }