Hi every1!
Thats my code that used to work before I've added some attributes to my items.
void manager::EditStockItem()
{
ListStock();
{
string z;
bool found;
cout<< endl<<"<===================================================>"<<endl<<endl;
cout << "Enter ID of the Stock Item you want to edit" << endl<<endl;
cin>>z;
found = false;
vector <Item*>::iterator iter = theStock.begin();
for(iter = theStock.begin();iter != theStock.end();++iter)
{
if (z == ((*iter)->getStockID()))
{
found = true;
break;
}
}
if(found)
{
system("cls");
char choice;
bool valid = false;
for(;;)
{
system("cls");
do
{
cout << " Edit details of "<<z<<endl;
cout << " 1. To edit ID\n";
cout << " 2. To edit Title\n";
cout << " 3. To edit Publisher\n";
cout << " 4. To edit Price\n";
cout << " 5. To Cancel\n";
cin >> choice;
if(choice == '5')
{
ShowAdminMenu();
}
else if(choice < '1' || choice > '4')
{
cout << "\nNot a valid char!\n\n";
char aChar;
cout << endl << "Enter any character to continue .. " << endl;
cin >> aChar;
system("cls");
}
else
{
valid = true;
}
}
while(!valid);
cout << "\n";
switch(choice)
{
char aChar;
case '1':
{
cout << "Enter new ID" << endl;
string newStockID;
cin.sync();
getline(cin,newStockID);
(*iter)->setStockID(newStockID);
ListStock();
}
cout << endl << "Enter any character to continue .. " << endl;
cin >> aChar;
break;
case '2':
{
cout << "Enter new Title: " << endl;
string newTitle;
cin.sync();
getline(cin,newTitle);
(*iter)-> setTitle(newTitle);
ListStock();
}
cout << endl << "Enter any character to continue .. " << endl;
cin >> aChar;
break;
case '3':
{
cout << "Enter new Publisher: " << endl;
string newPublisher;
cin.sync();
getline(cin,newPublisher);
(*iter)-> setPublisher(newPublisher);
ListStock();
}
cout << endl << "Enter any character to continue .. " << endl;
cin >> aChar;
break;
case '4':
{
cout << "Enter new Price" << endl;
string newPrice;
cin.sync();
getline(cin,newPrice);
(*iter)->setPrice(newPrice);
ListStock();
}
cout << endl << "Enter any character to continue .. " << endl;
cin >> aChar;
break;
}
cout << "\n";
}
}
else
{
cout << "Not found" << endl;
}
}
}
Heres the Stock vector
void manager::BuildStockVector()
{
theStock.push_back(new Book("SBK010","978-0-307-47427-8","A Tale of Two Cities","Penguin Classics","General","345","12"));
theStock.push_back(new Book("SBK020","325-0-412-45527-4","The Da Vinci Code","Random House","General","237","14.25"));
theStock.push_back(new Book("SBK011","978-0-307-47427-3","Copy of the book 'A Tale of Two Cities'","Penguin Classics","General","340","12"));
theStock.push_back(new Journal("SJN010","0811-8203","Desire Journal","8","01.04.2012","History","Chronicle Books","144","10.75"));
theStock.push_back(new Video("SVD010","The Squid and the Whale","Drama","1:45:22","AVI","Keep Case","Sony Pictures Home Entertainment","20"));
theStock.push_back(new Video("SVD020","High Fidelity","Dogstar Films","Comedy","1:37:44","DVD","Keep Case","17.50"));
theStock.push_back(new MusicCD("SCD010","Chris Rea","The Best Of Chris Rea","0:45:22","Tyvek Sleeve","CD","16","East/West Records","6.50"));
theStock.push_back(new MusicCD("SCD020","Smokie","The Best Of Smokie","0:48:12","Paper Sleeve","CD-R","17","Paradiso","4.75"));
theStock.push_back(new Journal("SJN010","0811-8204","Copy of 'Desire Journal'","8","01.04.2012","History","Chronicle Books","144","10.75"));
theStock.push_back(new Book("SBK021","325-0-412-45527-2","Copy of the book 'The Da Vinci Code'","Random House","General","235","14.25"));
theStock.push_back(new Journal("SJN020","0577-2173","CSC Journal","3","01.08.2011","IT","CSC Journals","87","4.25"));
theStock.push_back(new Journal("SJN021","0577-2175","Copy of the 'CSC Journal'","3","01.08.2011","IT","CSC Journals","87","4.25"));
}