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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct song{
string title;
string artist;
double length;
};
vector<song>list;
char input(char choice, char &done, song &title, song &newSong, song &artist, song &length){
do{
cout<<"(1) Add a song""\n"<<endl;
cout<<"(2) Sort by title"<<endl;
cout<<"(3) Sort by artist"<<endl;
cout<<"(4) Sort by length"<<endl;
cout<<"(5) Print your playlist"<<endl;
cout<<"(6) Exit""\n"<<endl;
cout<<"Enter your option: ";
cin>>choice; cout<<"\n";
cout<<"\n";
cout<<"\n";
do{
if(choice=='1'){
cout<<"Title: ";
cin.ignore();
getline(cin, newSong.title);
list.push_back(title);
cout<<"Artist: ";
getline(cin, newSong.artist);
list.push_back(artist);
cout<<"Length: ";
cin>>newSong.length;
list.push_back(length);
cout<<"\n";
cout<<"\n";
cout<<"Done adding?";
cin>>done; cout<<"\n";
}
}while (done=='n');
if(choice=='2'){
}
else if(choice=='3'){
}
else if(choice=='4'){
}
else if(choice=='5'){
cout<<"-----Current Playlist----- "; cout<<"\n";
cout<<"Title: "<<newSong.title; cout<<"\n";
cout<<"Arist: "<<newSong.artist; cout<<"\n";
cout<<"Length: "<<newSong.length; cout<<"\n";
cout<<"\n";
cout<<"Other options""\n";
cout<<"\n";
}
else if(choice=='6'){
return 0;
}
}
while(done=='y');
}
int main(){
vector<song>list;
song title;
song artist;
song length;
song newSong;
list.push_back(artist);
list.push_back(length);
char choice;
char done;
choice = input(choice, done, title, newSong, artist, length);
}
|