Apr 3, 2013 at 5:12am
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
|
void orderItem( Inventory *& inven , OrderList *& order , int &index ){
displayItem(inven,index);
string status = "";
string name = "";
string item = "";
double price = 0.00;
int quan = 0;
int orderIndex = 0;
char choice = 'a';
ifstream inFile;
//readOrder( order ,inFile , orderIndex );
do{
cout << "Do you want add an order [y / n] : ";
cin >> choice;
switch( choice ){
case 'y':
case 'Y':
cin.ignore();
cout << "Enter company name : ";
getline( cin , name );
order[orderIndex].setCompanyName( name );
cout << "Enter item name : ";
getline( cin , item );
order[orderIndex].setItemName( item );
cout << "Enter quantity : ";
cin >> quan;
order[orderIndex].setQuantity( quan );
for( int i = 0 ; i < index ; i++ ){
if( item == inven[i].getItemName() ){
price = quan * inven[i].getPrice();
}
}
cout << "Total Price : RM" << price << endl;
order[orderIndex].setPrice(price);
status = "pending";
order[orderIndex].setOrderStatus(status);
break;
case 'N':
case'n':
cout << "You cancel order item" << endl;
break;
default:
cout << "Invalid input ! Please re-enter" << endl;
break;
}
}while( choice != 'Y' && choice != 'y' && choice != 'N' && choice !='n');
}
|
main.cpp
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
|
/*
* File: main.cpp
* Author: Lim
*
* Created on April 2, 2013, 12:48 PM
*/
#include <cstdlib>
#include "Inventory.h"
#include "OrderList.h"
int main(int argc, char** argv) {
ifstream inFile;
Inventory *inven;
OrderList *order;
int index = 0;
readInven(inven,inFile,index);
inven = new Inventory[index];
recordStore(inven,index);
orderItem(inven,order,index);
return 0;
}
|
why i cannot set the order status.
if i set it my program will pop out an error.
if i comment it out my program able to run . why ?
and at line 25
i able to run it in netbean
but why i cannot run in visual studio?
will pop out an error message. can any expert help pls..
Last edited on Apr 3, 2013 at 6:09am