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
|
int main () {
string wn;
printSignature();
vector<WineryName*> winName;
int street_number, zip_code;
string street, city, state, country;
bool more = true;
// loop to initilize winerys
while (more)
{
cout << "Please enter the winery's name: (no to quit)";
cin >> wn;
if (wn == "no")
{
more = false;
}
else
{
cout << "Please enter the street number: ";
cin >> street_number;
cout << "Please enter the street : ";
cin.ignore();
getline(cin,street);
cout << "Please enter the city : ";
getline(cin,city);
cout << "Please enter the state : ";
getline(cin, state);
cout << "Please enter the zip code : ";
cin >> zip_code;
cout << "Please enter the country : ";
cin.ignore();
getline(cin, country);
winName.push_back(new WineryName(wn, street_number, street, city, state, zip_code,country));
}
}
cout << endl;
// loop to initilize winerys ends
// loop to initilize wines starts
vector<Wine*> wines;
string n, wt;
int sc, vin;
double p;
bool more1 = true;
while (more1) {
cin.ignore();
cout << "Enter wine name " ;
getline (cin, n);
if ( n == "no") more1 = false;
else
{
cout << "Enter the wine type: ";
getline (cin, wt);
cout << "Enter the wine vintage: ";
cin >> vin;
cout << "Enter the wine score: ";
cin >> sc;
cout << "Enter the wine price: ";
cin >> p;
Wine* wine = new Wine(n);
cout << "enter the winerys name:";
string wineryname;
cin.ignore();
getline (cin, wineryname);
wine->setWineryName(find(winName, wineryname));
wine->setWineInfo(n, p, sc);
wine->setWineVintage(vin);
wine->setWineType(wt);
wines.push_back(wine);
}
}
cout << "These are the wines sorted by vintage: " << endl;
sort(wines.begin(), wines.end(), sort_price);
int j = 0;
while (j <= wines.size())
{
j++;
wines[j]->print();
}
return 0;
}
|