//InventoryItem class file THIS IS THE CLASS FILE CPP FILE //COMING..................................
#ifndef INVENTORY_H
#define INVENTORY_H
#include
using namespace std;
class InventoryItem
{
private:
string description;
string partNo;
int qty;
public:
void setDescription(string desc)
{description = desc;}
void setPartNumber ( string pNo)
{partNo = pNo; }
void setQTY ( int q)
{ qty = q; }
string getDescription() const
{ return description;}
string getPartNumber() const
{ return partNo;}
int getQTY() const
{ return qty; }
};
#endif
2007-12-10
16:51:23
·
4 answers
·
asked by
Shahn
2
in
Education & Reference
➔ Homework Help
//InventoryItem.cpp file
#include "Inventory.h"
#include
#include
#include
using namespace std;
int main()
{nventoryItem itemList[12];
ifstream inFile;
string input, desc, pNum, qty;
int pos, start = 0, q, i=0;
inFile.open("inventory.txt");
if(!inFile)
{cout<<"Error! File not found. \n"; }
else
{cout<<"Inventory list \n";
getline(inFile, input);
while(inFile)
{//find first ','
pos=input.find(',',start);
desc=input.substr(start,pos);
start=pos + 1;
//find second ','
pos=input.find(',',start);
pNum=input.substr(start,pos-start);
start=pos + 1;
//last token
pos=input.length();
qty=input.substr(start,pos-start);
//convert to integer
q=atoi(qty.data());
//populate object
itemList[i].setDescription(desc);
itemList[i].setPartNumber(pNum);
itemList[i].setQTY(q);
//display content
cout<
cout<
cout<
getline(inFile, input);
i++;
start = 0;
}
}
return 0;
}
2007-12-10
17:04:15 ·
update #1
**The previous program has nventoryItem when when it should have InventoryItem**
Anyways when I attempt to compile I get an "undeclared function" first use this function error why?
I NEED TO
DISPLAY ITEMS IN INVENTORY
ADD AN ITEM
UPDATE AN ITEM
DELETE AN ITEM
DISPLAY THE SORTED INVENTORY
LIST BY BY QUANTITY ON HAND
//*****************here is a demo list for inventory.txt**//
Hammer 10 lbs, H10PNDS, 20
Pliers 12 inch, PL12INC, 12
Axes 25 lbs, AX25PNDS, 3
Ratchet 1 cm, RAT1CENT, 1000
Drill 350 watt, D35WATT, 99
Sander 200 watt, S20WATT, 6
Tire 22 inch, TR22INC, 22
Saw 1 foot, SAW1F00T, 3
Wrench Set 14 pc, WSET14PC, 8
Adjustable Wrench 4 pc, AW4PC, 24
Airhose 20 foot, AH20FT, 23
Grinder 2 hp, GRNDR2HP, 71
//**********************demo txtfile LIst**//
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
THANKYOU
TNKS
2007-12-10
17:11:52 ·
update #2
reply to head hunt
I NEED TO
DISPLAY ITEMS IN INVENTORY
ADD AN ITEM
UPDATE AN ITEM
DELETE AN ITEM
DISPLAY THE SORTED INVENTORY
LIST BY BY QUANTITY ON HAND
2007-12-10
18:17:33 ·
update #3
PLEASE IF ANYONE CAN HELP IT WOULD BE GREATLY APPRECIATED I WILL BE AT MY COMP WORKING ON THIS FOR A WHILE
***********************************************
IF YOU NEED MORE INFORMATION PLEASE ASK ME ANYTHING!!!!!!!!
THANKS AGAIN!!!!!!!!!!!!!
2007-12-10
20:02:40 ·
update #4