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
|
#include "InventoryClass.h"
#include "InventoryCostClass.h"
#include<iostream>
#include<fstream>
using namespace std;
const int SIZE = 6;
int menu();
void displayInv(InventoryCost[]);
void createFile(fstream&, string);
int main() {
InventoryCost itemInv[SIZE] =
{ InventoryCost(209875, "Global - Designed Wrench : catalog 145HN - 89", 1056,
14.67, 23.99, 10, 13, 2014),
InventoryCost(176524, "Steeheel Chainsaw - 120 H - P: catalog 133NM - 65", 2654,
234.67, 299.99, 10, 13, 2014),
InventoryCost(340965, "Plurers Pliers with Sure - Grip: catalog 764TW - 12", 1043,
11.45, 19.98, 10, 13, 2014),
InventoryCost(453285, "Rapid Recoil Hand Tape Measure : catalog 127UY - 32", 3316,
8.56, 15.99, 10, 13, 2014),
InventoryCost(893167, "Steady Built Steel Saw Horses : catalog 564HG - 34", 764,
45.54, 79.99, 10, 13, 2014),
InventoryCost(597895, "Big Boy Bib Overalls - L - XL - XXL: catalog 278LG - 45", 5032,
19.76, 39.99, 10, 13, 2014) };
int ch = 0;
fstream file;
string filename;
do {
ch = menu();
if (ch != 6) {
switch (ch)
{
case 1:
displayInv(itemInv);
break;
case 2:
{ cout << "Choose a name for the file: ";
cin >> filename;
createFile(file, filename);
};
break;
}
}
} while (ch != 6);
file.close();
system("pause");
return 0;
}
int menu() {
int choice;
cout << "**********************************\n"
<< "*________MENOCU TOOL SHOP________*\n"
<< "**********************************\n"
<< "* 1. Display Inventory *\n"
<< "* 2. Create a Transaction File *\n"
<< "* 3. Update Inventory *\n"
<< "* 4. Display Updated Inventory *\n"
<< "* 5. Compute Profit Projection *\n"
<< "* 6. EXIT *\n"
<< "**********************************\n"
<< " Menu Choice: ";
cin >> choice;
return choice;
}
void displayInv(InventoryCost itemInv[SIZE]) {
for (int i = 0; i < SIZE; i++) {
cout << "Item #" << i+1 << ": " << endl;
itemInv[i].print();
}
}
void createFile(fstream &file, string filename) {
char code[3], edit[75];
int iId;
cout << "Transaction Codes: \n"
<< "\tAI: Add to Inventory\n"
<< "\tRI: Reduce from Inventory\n"
<< "\tCW: Change Wholesale Cost\n"
<< "\tCR: Change Retail Price\n"
<< "\tCD: Change Description\n\n"
<< "Enter the ItemID #: ";
cin >> iId;
if (iId < 99999) {
cout << "ItemID must be 6 digits; Enter the ItemID #: ";
cin >> iId;
}
cout << "Enter the Transaction Code: ";
cin >> code;
cout << "Enter the Updated Information: ";
cin >> edit;
file.open((filename+".dat").c_str(), ios::out | ios::binary);
file.write(reinterpret_cast<char *>(&iId), sizeof(iId));
file.write(code, sizeof(code));
file.write(edit, sizeof(edit));
file.close();
}
|