Guest User

Untitled

a guest
Jan 4th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.83 KB | None | 0 0
  1. // Exercise04.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
  2. //
  3.  
  4. #include "stdafx.h"
  5. using namespace std;
  6.  
  7. bool running;
  8. vector<Artist*> _vArtists;
  9. vector<Actor*> _vActors;
  10. vector<AudioTrack*> _vAudioTrack;
  11. vector<VideoTrack*> _vVideoTrack;
  12. vector<Compilations*> _vCompilation;
  13. vector<MediaLibrary*> _vMediaLibrary;
  14.  
  15. int _tmain(int argc, _TCHAR* argv[])
  16. {
  17.     addDefaultPersons();
  18.     running = true;
  19.  
  20.     while(running){
  21.  
  22.         printOptions();
  23.         int in;
  24.         cin >> in;
  25.  
  26.         switch (in){
  27.         case 0:
  28.             running = false;
  29.             return 0;
  30.             break;
  31.         case 1:
  32.             createAudioTrack();
  33.             break;
  34.         case 2:
  35.             createVideoTrack();
  36.             break;
  37.         case 3:
  38.             createCompilation();
  39.             break;
  40.         case 4:
  41.             createMediaLibrary();
  42.             break;
  43.         case 5:
  44.             addTrackToCompilation();
  45.             break;
  46.         case 6:
  47.             addCompilationToMediaLibrary();
  48.             break;
  49.         case 7:
  50.             listCompilations();
  51.             break;
  52.         case 8:
  53.             printDetailsOfCompilation();
  54.             break;
  55.         default:
  56.             running = false;
  57.             return 0;
  58.         }
  59.     }
  60.  
  61.     ::system("pause");
  62.     return 0;
  63. }
  64.  
  65.  
  66. void addTrackToCompilation(){
  67.     int cnumber;
  68.     int tnumber;
  69.  
  70.     cout << "Add Track to compilation" << endl;
  71.     cout << "=====================" << endl;
  72.  
  73.     // Checks for existing compilations
  74.     if(_vCompilation.size() == 0){
  75.         cout << "No compilations found" << endl;
  76.         return;
  77.     }
  78.  
  79.     cout << "Choose a compilation based on the number." << endl;
  80.     listCompilations();
  81.     cin >> cnumber;
  82.  
  83.     if (_vCompilation[cnumber]->getType().compare("Video") == 0){
  84.         cout << "Choose a video track based on the number." << endl;
  85.         for (int i = 0; i < _vVideoTrack.size(); i ++){
  86.             stringstream ss;
  87.             ss << i;
  88.             cout << ss.str() + ": " + _vVideoTrack[i]->toString() << endl;
  89.         }
  90.         cin >> tnumber;
  91.         _vCompilation[cnumber]->addTrack(_vVideoTrack[tnumber]);
  92.     }else {
  93.         cout << "Choose an audio track based on the number." << endl;
  94.         for (int i = 0; i < _vAudioTrack.size(); i ++){
  95.             stringstream ss;
  96.             ss << i;
  97.             cout << ss.str() + ": " + _vAudioTrack[i]->toString() << endl;
  98.         }
  99.         cin >> tnumber;
  100.         _vCompilation[cnumber]->addTrack(_vAudioTrack[tnumber]);
  101.     }
  102.     cout << "Done! You have succesfully added a track to a compilation!" << endl;
  103. }
  104.  
  105. void addCompilationToMediaLibrary(){
  106.     int mlnumber;
  107.     int cnumber;
  108.  
  109.     cout << "Add compilation to media library" << endl;
  110.     cout << "=====================" << endl;
  111.  
  112.         // Checks for existing libraries
  113.     if(_vMediaLibrary.size() == 0){
  114.         cout << "No libraries found" << endl;
  115.         return;
  116.     }
  117.  
  118.     cout << "Choose a library based on the number." << endl;
  119.     for (int i = 0; i < _vMediaLibrary.size(); i ++){
  120.         stringstream ss;
  121.         ss << i;
  122.         cout << ss.str() + ": " + _vMediaLibrary[i]->getName() << endl;
  123.     }
  124.     cin >> mlnumber;
  125.  
  126.     cout << "Choose a compilation based on the number." << endl;
  127.     listCompilations();
  128.     cin >> cnumber;
  129.  
  130.     cout << "Done! You have succesfully added a compilation to a media library!" << endl;
  131.  
  132.     _vMediaLibrary[mlnumber]->addCompilations(_vCompilation[cnumber]);
  133. }
  134.  
  135. void listCompilations(){
  136.     // Checks for existing compilations
  137.     if(_vCompilation.size() == 0){
  138.         cout << "No compilations found" << endl;
  139.         return;
  140.     }
  141.     for (int i = 0; i < _vCompilation.size(); i ++){
  142.         stringstream ss;
  143.         ss << i;
  144.         cout << ss.str() + ": " + _vCompilation[i]->getName() << endl;
  145.     }
  146. }
  147.  
  148. void printDetailsOfCompilation(){
  149.     cout << "Print details of compilation" << endl;
  150.     cout << "=====================" << endl;
  151.     // Checks for existing compilations
  152.     if(_vCompilation.size() == 0){
  153.         cout << "No compilations found" << endl;
  154.         return;
  155.     }
  156.     cout << "Choose a compilation based on the number." << endl;
  157.     listCompilations();
  158.     int cnumber;
  159.     cin >> cnumber;
  160.  
  161.     vector<Track*> vTrack = _vCompilation[cnumber]->getTracks();
  162.  
  163.     // Checks for tracks
  164.     if (vTrack.size() == 0){
  165.         cout << "No tracks found" << endl;
  166.     }
  167.  
  168.     for (int i = 0; i < vTrack.size(); i++){
  169.         stringstream ss;
  170.         ss << i;
  171.         if (_vCompilation[cnumber]->getType().compare("Video") == 0){
  172.             VideoTrack* track = (VideoTrack*) vTrack[i];
  173.             cout << ss.str() + ": " + track->toString() << endl;
  174.         } else {
  175.             AudioTrack* track = (AudioTrack*) vTrack[i];
  176.             cout << ss.str() + ": " + track->toString() << endl;
  177.         }
  178.     }
  179. }
  180.  
  181. void createMediaLibrary(){
  182.     MediaLibrary* m = new MediaLibrary();
  183.  
  184.     cout << "Create a media library" << endl;
  185.     cout << "=====================" << endl;
  186.     cout << "Enter the name of the library: ";
  187.     string s;
  188.     cin >> s;
  189.     m->setName(s);
  190.  
  191.     cout << "Done! You have succesfully created a new media library!" << endl;
  192.  
  193.     _vMediaLibrary.push_back(m);
  194. }
  195.  
  196. void createCompilation(){
  197.     Compilations* c = new Compilations();
  198.  
  199.     cout << "Create a compilation" << endl;
  200.     cout << "=====================" << endl;
  201.     cout << "Enter the name of the compilation: ";
  202.     string s;
  203.     cin >> s;
  204.     c->setName(s);
  205.  
  206.     cout << "Choose the type of the compilation by number: " << endl;
  207.     cout << "0: Video" << endl;
  208.     cout << "1: Audio" << endl;
  209.     int i;
  210.     cin >> i;
  211.     switch (i){
  212.     case 0:
  213.         c->setType("Video");
  214.         break;
  215.     case 1:
  216.         c->setType("Audio");
  217.         break;
  218.     default:
  219.         return;
  220.     }
  221.  
  222.     cout << "Done! You have succesfully created a new compilation!" << endl;
  223.  
  224.     _vCompilation.push_back(c);
  225. }
  226.  
  227. void createVideoTrack(){
  228.     VideoTrack* a = new VideoTrack();
  229.     VideoStream* vs = new VideoStream();
  230.     AudioStream* as = new AudioStream();
  231.     cout << "Create a video track" << endl;
  232.     cout << "=====================" << endl;
  233.     cout << "Choose an actor based on the number." << endl;
  234.     for (int i = 0; i < _vActors.size(); i ++){
  235.         stringstream ss;
  236.         ss << i;
  237.         cout << ss.str() + ": " + _vActors[i]->toString() << endl;
  238.     }
  239.  
  240.     int input;
  241.     cin >> input;
  242.     a->addActor(_vActors[input]);
  243.  
  244.     cout << "Added actor " << input << " to the video track!" << endl;
  245.  
  246.     cout << "Enter the name of the video track: ";
  247.     string s;
  248.     cin >> s;
  249.     a->setTitle(s);
  250.  
  251.     cout << "Enter the year of the video track: ";
  252.     string s1;
  253.     cin >> s1;
  254.     a->setYear(s1);
  255.  
  256.     cout << "Enter the length of the video track in seconds: ";
  257.     int i;
  258.     cin >> i;
  259.     a->setLength(i);
  260.  
  261.     cout << "Enter the filename: ";
  262.     string s2;
  263.     cin >> s2;
  264.     vs->setFileName(s2);
  265.  
  266.     cout << "Enter the bitrate: ";
  267.     float f;
  268.     cin >> f;
  269.     as->setBitRate(f);
  270.  
  271.     a->addAudioStreams(as);
  272.  
  273.     cout << "Done! You have succesfully created a new video track!" << endl;
  274.     cout << a->toString() << endl;
  275.  
  276.     _vVideoTrack.push_back(a);
  277.  
  278. }
  279.  
  280. void createAudioTrack(){
  281.     AudioTrack* a = new AudioTrack();
  282.     AudioStream* as = new AudioStream();
  283.     cout << "Create an audio track" << endl;
  284.     cout << "=====================" << endl;
  285.     cout << "Choose an artist based on the number." << endl;
  286.     for (int i = 0; i < _vArtists.size(); i ++){
  287.         stringstream ss;
  288.         ss << i;
  289.         cout << ss.str() + ": " + _vArtists[i]->toString() << endl;
  290.     }
  291.  
  292.     int input;
  293.     cin >> input;
  294.     a->addArtist(_vArtists[input]);
  295.  
  296.     cout << "Added artist " << input << " to the audio track!" << endl;
  297.  
  298.     cout << "Enter the name of the audio track: ";
  299.     string s;
  300.     cin >> s;
  301.     a->setTitle(s);
  302.  
  303.     cout << "Enter the year of the audio track: ";
  304.     string s1;
  305.     cin >> s1;
  306.     a->setYear(s1);
  307.  
  308.     cout << "Enter the length of the audio track in seconds: ";
  309.     int i;
  310.     cin >> i;
  311.     a->setLength(i);
  312.  
  313.     cout << "Enter the filename: ";
  314.     string s2;
  315.     cin >> s2;
  316.     as->setFileName(s2);
  317.  
  318.     cout << "Enter the bitrate: ";
  319.     float f;
  320.     cin >> f;
  321.     as->setBitRate(f);
  322.  
  323.     a->setAudioStream(*as);
  324.  
  325.     cout << "Done! You have succesfully created a new audio track!" << endl;
  326.     cout << a->toString() << endl;
  327.  
  328.     _vAudioTrack.push_back(a);
  329. }
  330.  
  331. void printOptions(){
  332.     cout << endl;
  333.     cout << "0. EXIT" <<endl;
  334.     cout << "1. Create audio track" <<endl;
  335.     cout << "2. Create video track" <<endl;
  336.     cout << "3. Create compilation" <<endl;
  337.     cout << "4. Create media library" <<endl;
  338.     cout << "5. Add track to compilation" <<endl;
  339.     cout << "6. Add compilation to media library" <<endl;
  340.     cout << "7. List all compilations" <<endl;
  341.     cout << "8. Print details of compilation" <<endl;
  342.     cout << endl;
  343. }
  344.  
  345. void addDefaultPersons(){
  346.  
  347.     Artist* artist1 = new Artist();
  348.     artist1->setBirthday("25.10.1990");
  349.     artist1->setFirstName("Tassilo");
  350.     artist1->setLastName("Posegga");
  351.     artist1->setGenre("Imba");
  352.     artist1->setNationality("AUT");
  353.  
  354.     _vArtists.push_back(artist1);
  355.  
  356.     Artist* artist2 = new Artist();
  357.     artist2->setBirthday("08.08.1975");
  358.     artist2->setFirstName("Gregor");
  359.     artist2->setLastName("Just");
  360.     artist2->setGenre("Rock");
  361.     artist2->setNationality("GB");
  362.  
  363.     _vArtists.push_back(artist2);
  364.  
  365.     Actor* actor1 = new Actor();
  366.     actor1->setBirthday("05.02.1990");
  367.     actor1->setFirstName("Carolin");
  368.     actor1->setLastName("Stuetz");
  369.     actor1->setNumberOfOscars(5);
  370.     actor1->setNationality("GER");
  371.  
  372.     _vActors.push_back(actor1);
  373.  
  374.     Actor* actor2 = new Actor();
  375.     actor2->setBirthday("18.02.1954");
  376.     actor2->setFirstName("John");
  377.     actor2->setLastName("Travolta");
  378.     actor2->setNumberOfOscars(2);
  379.     actor2->setNationality("USA");
  380.  
  381.     _vActors.push_back(actor2);
  382. }
Advertisement
Add Comment
Please, Sign In to add comment