-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (36 loc) · 938 Bytes
/
main.cpp
File metadata and controls
40 lines (36 loc) · 938 Bytes
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
#include <iostream>
#include "MP3.h"
#include "MP4.h"
#include "Lab.h"
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int player_type;
if (!(std::cin >> player_type)) return 0;
Player* player = nullptr;
Lab lab;
if (player_type == 3) player = new MP3();
else if (player_type == 4) player = new MP4();
else return 0;
int opcode;
while (std::cin >> opcode) {
if (opcode == 0) break;
if (opcode == 1) {
int id; std::cin >> id; player->add_first(id);
} else if (opcode == 2) {
int id; std::cin >> id; player->add_last(id);
} else if (opcode == 3) {
player->play_all();
} else if (opcode == 4) {
int index; std::cin >> index; player->remove_at(index);
} else if (opcode == 5) {
int index; std::cin >> index; player->swap_adjacent(index);
} else if (opcode == 6) {
lab.backup(*player);
} else if (opcode == 7) {
lab.restore(player);
}
}
delete player;
return 0;
}