Advertisement
steamengines

song class

May 5th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. // Christian Ballard
  2. // COSC 1336 - 001
  3. // March 25th 2015
  4. // PA13 - Song Class
  5.  
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <string>
  9. // Include your generic files for readInt function
  10. #include "song.h"
  11. #include "genericCDB.h"
  12. using namespace std;
  13.  
  14.  
  15. int main()
  16. {
  17.     const int NUMB_SONGS = 3;
  18.  
  19.     Song songList[NUMB_SCORES] = {
  20.         Song("Hand In My Pocket", "Jagged Little Pill", "Alanis Morissette",
  21.             Song::ROCK, 3, 47),
  22.         Song("The Last Time", "Red", "Taylor Swift"),       // Partially initialized Song
  23.     }; // Note that the third song is uninitialized.
  24.  
  25.     cout << "\nSONG CLASS PROGRAM TEST CLIENT:\n";
  26.  
  27.     // Display content of songList array
  28.     for (int i = 0; i < NUMB_SONGS; i++)
  29.     {
  30.         cout << "\nSong #" << i + 1 << ": " << songList[i].getSong() << endl;
  31.     }
  32.  
  33.     int tempInt;    // Variables used to store information for a new song object.
  34.     string tempString;
  35.     Song newSong;
  36.  
  37.     // Test set member functions
  38.     cout << "\n\nEnter the title of a 4th new song: ";
  39.     getline(cin, tempString);
  40.     newSong.setTitle(tempString);
  41.  
  42.     cout << "\nWhat album is it on? ";
  43.     getline(cin, tempString);
  44.     newSong.setAlbum(tempString);
  45.  
  46.     cout << "\nWho is the artist? ";
  47.     getline(cin, tempString);
  48.     newSong.setArtist(tempString);
  49.  
  50.     cout << "\nWhat music genre is it?\n";
  51.     cout << "\t1. Rock" << endl;
  52.     cout << "\t2. Jazz" << endl;
  53.     cout << "\t2. Classical" << endl;
  54.     cout << "\t2. Blues" << endl;
  55.     cout << "\t2. Techno" << endl;
  56.     tempInt = readInt("Pick a genre:", 1, 5);
  57.     newSong.setGenre(static_cast<song::MusicGenre>(tempInt));
  58.  
  59.     cout << "\nHow long is this song? " << endl;
  60.     cout << "\nMinutes: ";
  61.     int min = readInt("\tMinutes:", 0, 59);
  62.     cout << "\tSeconds: ";
  63.     int sec = readInt("\tSeconds:", 0, 59);
  64.     newSong.setPlayingTime(min, sec);
  65.  
  66.     cout << endl << endl;
  67.  
  68.     // Test get member functions.
  69.     cout << "The new 4th song information:\n";
  70.     cout << "Song Title: " << newSong.getTitle() << endl;
  71.     cout << "Album Name: " << newSong.getTitle() << endl;
  72.     cout << "Artist Name: " << newSong.getTitle() << endl;
  73.     cout << "Genre: " << newSong.getTitle() << endl;
  74.     cout << "Time: " << newSong.getTitle() << endl;
  75.  
  76.     // Test isEqual member function
  77.     cout << "\nChecking to see if class objects are equivalent.\n\n"
  78.         << "Does the first song == the new song?   "
  79.         << boolalpha << songList[0].isEqual(newSong) << "\n";
  80.  
  81.     cout << "\nAssign the first Song to the new Song"
  82.         << " and then check quivalency.\n\n";
  83.     newSong = songList[0];
  84.     cout << "Does the first song == the new song?   " << songList[0].isEqual(newSong) << "\n";
  85.  
  86.     cout << "\nProgram Ended.\n";
  87.     system("pause");
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement