Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Complete the program by:
- * - Prompting the user to enter an album and an undetermined number of songs
- * - Modify the Song class by adding the following properties: track number and writers
- * - Add the following properties to the Album class: release year, artist, label and genre
- * - At the end of the program, all properties of the album should be printed
- */
- #include <iostream>
- #include <vector>
- using namespace std;
- class Song {
- public:
- string title;
- int duration;
- string durationFormatted() {
- int mins = this->duration / 60;
- int sec = this->duration % 60;
- return "" + to_string(mins) + ":" + to_string(sec) + "0";
- }
- };
- class Album {
- public:
- string name;
- vector<Song> songs;
- };
- int main() {
- Song song1;
- Album album1;
- vector<Song> songs;
- song1.title = "Often";
- song1.duration = 242; // in seconds
- // add a song to the songs collection (vector)
- songs.push_back(song1);
- album1.name = "Beauty Behind the Madness";
- album1.songs = songs;
- cout << album1.name << endl;
- for (Song s : album1.songs) {
- cout << s.title << " " << s.durationFormatted() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement