Класс CdPlayer - Nero-ro/Facade GitHub Wiki
- amplifer
- on()
- off()
- eject()
- pause()
- play()
- play()
- stop()
- toString()
#ifndef CDPLAYER_H
#define CDPLAYER_H
#include
#include
#include "amplifier.h"
using namespace std;
class CdPlayer
{
private:
QString description; int currentTrack; Amplifier *amplifier; QString title;
public:
CdPlayer(QString description, Amplifier *amplifier); void on(); void off(); void eject(); void play(QString title); void play(int track); void stop(); void pause(); QString toString();
};
#endif // CDPLAYER_H
#include "cdplayer.h"
CdPlayer::CdPlayer(QString description, Amplifier *amplifier)
{ this->description = description; this->amplifier = amplifier; }
void CdPlayer::on() {
cout << description.toStdString() << " on" << endl;
}
void CdPlayer::off() {
cout << description.toStdString() << " off" << endl;
}
void CdPlayer::eject() {
title = nullptr; cout << description.toStdString() << " eject" << endl;
}
void CdPlayer::play(QString title) {
this->title = title; currentTrack = 0; cout << description.toStdString() << " playing \"" << title.toStdString() << "\"" << endl;
}
void CdPlayer::play(int track) {
if (title == nullptr) { cout << description.toStdString() << "can't play track " << currentTrack << ", no cd inserted" << endl; } else { currentTrack = track; cout << description.toStdString() << " playing track " << currentTrack << endl; }
}
void CdPlayer::stop() {
currentTrack = 0; cout << description.toStdString() << " stopped" << endl;
}
void CdPlayer::pause() {
cout << description.toStdString() << " paused \"" << title.toStdString() << "\"" << endl;
}
QString CdPlayer::toString() {
return description;
}