generated from Coding-Cuddles/bootstrap-cpp-kata
-
Notifications
You must be signed in to change notification settings - Fork 1
/
media_player.h
60 lines (52 loc) · 1.37 KB
/
media_player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <stdexcept>
#include <string>
#include <vector>
class MediaFile {
public:
std::string format;
std::string filename;
};
class IMediaPlayer {
public:
virtual void play_audio() = 0;
virtual void display_video() = 0;
virtual void view_image() = 0;
};
class AudioPlayer : public IMediaPlayer {
public:
void play_audio() final
{
// Implementation...
}
void display_video() final { throw std::logic_error("Not implemented"); }
void view_image() final { throw std::logic_error("Not implemented"); }
};
class VideoPlayer : public IMediaPlayer {
public:
void play_audio() final { throw std::logic_error("Not implemented"); }
void display_video() final
{
// Implementation...
}
void view_image() final { throw std::logic_error("Not implemented"); }
};
class ImagePlayer : public IMediaPlayer {
public:
void play_audio() final { throw std::logic_error("Not implemented"); }
void display_video() final { throw std::logic_error("Not implemented"); }
void view_image() final
{
// Implementation...
}
};
using Players = std::vector<std::shared_ptr<IMediaPlayer>>;
class MediaListPlayer {
public:
void play_list(const std::vector<MediaFile>& media_list, const Players& players)
{
for (auto& media : media_list) {
// Implementation...
}
}
};