Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Exercise04.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
- //
- #include "stdafx.h"
- using namespace std;
- bool running;
- vector<Artist*> _vArtists;
- vector<Actor*> _vActors;
- vector<AudioTrack*> _vAudioTrack;
- vector<VideoTrack*> _vVideoTrack;
- vector<Compilations*> _vCompilation;
- vector<MediaLibrary*> _vMediaLibrary;
- int _tmain(int argc, _TCHAR* argv[])
- {
- addDefaultPersons();
- running = true;
- while(running){
- printOptions();
- int in;
- cin >> in;
- switch (in){
- case 0:
- running = false;
- return 0;
- break;
- case 1:
- createAudioTrack();
- break;
- case 2:
- createVideoTrack();
- break;
- case 3:
- createCompilation();
- break;
- case 4:
- createMediaLibrary();
- break;
- case 5:
- addTrackToCompilation();
- break;
- case 6:
- addCompilationToMediaLibrary();
- break;
- case 7:
- listCompilations();
- break;
- case 8:
- printDetailsOfCompilation();
- break;
- default:
- running = false;
- return 0;
- }
- }
- ::system("pause");
- return 0;
- }
- void addTrackToCompilation(){
- int cnumber;
- int tnumber;
- cout << "Add Track to compilation" << endl;
- cout << "=====================" << endl;
- // Checks for existing compilations
- if(_vCompilation.size() == 0){
- cout << "No compilations found" << endl;
- return;
- }
- cout << "Choose a compilation based on the number." << endl;
- listCompilations();
- cin >> cnumber;
- if (_vCompilation[cnumber]->getType().compare("Video") == 0){
- cout << "Choose a video track based on the number." << endl;
- for (int i = 0; i < _vVideoTrack.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vVideoTrack[i]->toString() << endl;
- }
- cin >> tnumber;
- _vCompilation[cnumber]->addTrack(_vVideoTrack[tnumber]);
- }else {
- cout << "Choose an audio track based on the number." << endl;
- for (int i = 0; i < _vAudioTrack.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vAudioTrack[i]->toString() << endl;
- }
- cin >> tnumber;
- _vCompilation[cnumber]->addTrack(_vAudioTrack[tnumber]);
- }
- cout << "Done! You have succesfully added a track to a compilation!" << endl;
- }
- void addCompilationToMediaLibrary(){
- int mlnumber;
- int cnumber;
- cout << "Add compilation to media library" << endl;
- cout << "=====================" << endl;
- // Checks for existing libraries
- if(_vMediaLibrary.size() == 0){
- cout << "No libraries found" << endl;
- return;
- }
- cout << "Choose a library based on the number." << endl;
- for (int i = 0; i < _vMediaLibrary.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vMediaLibrary[i]->getName() << endl;
- }
- cin >> mlnumber;
- cout << "Choose a compilation based on the number." << endl;
- listCompilations();
- cin >> cnumber;
- cout << "Done! You have succesfully added a compilation to a media library!" << endl;
- _vMediaLibrary[mlnumber]->addCompilations(_vCompilation[cnumber]);
- }
- void listCompilations(){
- // Checks for existing compilations
- if(_vCompilation.size() == 0){
- cout << "No compilations found" << endl;
- return;
- }
- for (int i = 0; i < _vCompilation.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vCompilation[i]->getName() << endl;
- }
- }
- void printDetailsOfCompilation(){
- cout << "Print details of compilation" << endl;
- cout << "=====================" << endl;
- // Checks for existing compilations
- if(_vCompilation.size() == 0){
- cout << "No compilations found" << endl;
- return;
- }
- cout << "Choose a compilation based on the number." << endl;
- listCompilations();
- int cnumber;
- cin >> cnumber;
- vector<Track*> vTrack = _vCompilation[cnumber]->getTracks();
- // Checks for tracks
- if (vTrack.size() == 0){
- cout << "No tracks found" << endl;
- }
- for (int i = 0; i < vTrack.size(); i++){
- stringstream ss;
- ss << i;
- if (_vCompilation[cnumber]->getType().compare("Video") == 0){
- VideoTrack* track = (VideoTrack*) vTrack[i];
- cout << ss.str() + ": " + track->toString() << endl;
- } else {
- AudioTrack* track = (AudioTrack*) vTrack[i];
- cout << ss.str() + ": " + track->toString() << endl;
- }
- }
- }
- void createMediaLibrary(){
- MediaLibrary* m = new MediaLibrary();
- cout << "Create a media library" << endl;
- cout << "=====================" << endl;
- cout << "Enter the name of the library: ";
- string s;
- cin >> s;
- m->setName(s);
- cout << "Done! You have succesfully created a new media library!" << endl;
- _vMediaLibrary.push_back(m);
- }
- void createCompilation(){
- Compilations* c = new Compilations();
- cout << "Create a compilation" << endl;
- cout << "=====================" << endl;
- cout << "Enter the name of the compilation: ";
- string s;
- cin >> s;
- c->setName(s);
- cout << "Choose the type of the compilation by number: " << endl;
- cout << "0: Video" << endl;
- cout << "1: Audio" << endl;
- int i;
- cin >> i;
- switch (i){
- case 0:
- c->setType("Video");
- break;
- case 1:
- c->setType("Audio");
- break;
- default:
- return;
- }
- cout << "Done! You have succesfully created a new compilation!" << endl;
- _vCompilation.push_back(c);
- }
- void createVideoTrack(){
- VideoTrack* a = new VideoTrack();
- VideoStream* vs = new VideoStream();
- AudioStream* as = new AudioStream();
- cout << "Create a video track" << endl;
- cout << "=====================" << endl;
- cout << "Choose an actor based on the number." << endl;
- for (int i = 0; i < _vActors.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vActors[i]->toString() << endl;
- }
- int input;
- cin >> input;
- a->addActor(_vActors[input]);
- cout << "Added actor " << input << " to the video track!" << endl;
- cout << "Enter the name of the video track: ";
- string s;
- cin >> s;
- a->setTitle(s);
- cout << "Enter the year of the video track: ";
- string s1;
- cin >> s1;
- a->setYear(s1);
- cout << "Enter the length of the video track in seconds: ";
- int i;
- cin >> i;
- a->setLength(i);
- cout << "Enter the filename: ";
- string s2;
- cin >> s2;
- vs->setFileName(s2);
- cout << "Enter the bitrate: ";
- float f;
- cin >> f;
- as->setBitRate(f);
- a->addAudioStreams(as);
- cout << "Done! You have succesfully created a new video track!" << endl;
- cout << a->toString() << endl;
- _vVideoTrack.push_back(a);
- }
- void createAudioTrack(){
- AudioTrack* a = new AudioTrack();
- AudioStream* as = new AudioStream();
- cout << "Create an audio track" << endl;
- cout << "=====================" << endl;
- cout << "Choose an artist based on the number." << endl;
- for (int i = 0; i < _vArtists.size(); i ++){
- stringstream ss;
- ss << i;
- cout << ss.str() + ": " + _vArtists[i]->toString() << endl;
- }
- int input;
- cin >> input;
- a->addArtist(_vArtists[input]);
- cout << "Added artist " << input << " to the audio track!" << endl;
- cout << "Enter the name of the audio track: ";
- string s;
- cin >> s;
- a->setTitle(s);
- cout << "Enter the year of the audio track: ";
- string s1;
- cin >> s1;
- a->setYear(s1);
- cout << "Enter the length of the audio track in seconds: ";
- int i;
- cin >> i;
- a->setLength(i);
- cout << "Enter the filename: ";
- string s2;
- cin >> s2;
- as->setFileName(s2);
- cout << "Enter the bitrate: ";
- float f;
- cin >> f;
- as->setBitRate(f);
- a->setAudioStream(*as);
- cout << "Done! You have succesfully created a new audio track!" << endl;
- cout << a->toString() << endl;
- _vAudioTrack.push_back(a);
- }
- void printOptions(){
- cout << endl;
- cout << "0. EXIT" <<endl;
- cout << "1. Create audio track" <<endl;
- cout << "2. Create video track" <<endl;
- cout << "3. Create compilation" <<endl;
- cout << "4. Create media library" <<endl;
- cout << "5. Add track to compilation" <<endl;
- cout << "6. Add compilation to media library" <<endl;
- cout << "7. List all compilations" <<endl;
- cout << "8. Print details of compilation" <<endl;
- cout << endl;
- }
- void addDefaultPersons(){
- Artist* artist1 = new Artist();
- artist1->setBirthday("25.10.1990");
- artist1->setFirstName("Tassilo");
- artist1->setLastName("Posegga");
- artist1->setGenre("Imba");
- artist1->setNationality("AUT");
- _vArtists.push_back(artist1);
- Artist* artist2 = new Artist();
- artist2->setBirthday("08.08.1975");
- artist2->setFirstName("Gregor");
- artist2->setLastName("Just");
- artist2->setGenre("Rock");
- artist2->setNationality("GB");
- _vArtists.push_back(artist2);
- Actor* actor1 = new Actor();
- actor1->setBirthday("05.02.1990");
- actor1->setFirstName("Carolin");
- actor1->setLastName("Stuetz");
- actor1->setNumberOfOscars(5);
- actor1->setNationality("GER");
- _vActors.push_back(actor1);
- Actor* actor2 = new Actor();
- actor2->setBirthday("18.02.1954");
- actor2->setFirstName("John");
- actor2->setLastName("Travolta");
- actor2->setNumberOfOscars(2);
- actor2->setNationality("USA");
- _vActors.push_back(actor2);
- }
Advertisement
Add Comment
Please, Sign In to add comment