In the retailitem.cpp I need to beable to increment x,y and z. So that is displays the next item. Heres what the code should output
Descriptio Units On Hand Unit Price ($)
Item #1 Jacket 12 59.95
Item #2 Jeans 40 34.95
Item #3 Shirt 20 24.95
Heres the code I have...
main.cpp
#include <cstdlib>
#include <iostream>
#include "RetailItem.h"
#include <iomanip>
using namespace std;
const unsigned W = 20;
int main(int argc, char *argv[])
{
RetailItem r;
cout<<setw(W)<<"Description"<<setw(W)<<"Units on Hand"<<setw(W)<<"Price ($)"<<endl;
cout<<endl;
cout<<"Item #1";
cout<<setw(10)<<r.getDescription();
cout<<setw(15)<<r.getUnitsOnHand();
cout<<setw(25)<<r.getPrice()<<endl;
cout<<"Item #2";
cout<<setw(10)<<r.getDescription();
cout<<setw(15)<<r.getUnitsOnHand();
cout<<setw(25)<<r.getPrice()<<endl;
cout<<"Item #3";
cout<<setw(10)<<r.getDescription();
cout<<setw(15)<<r.getUnitsOnHand();
cout<<setw(25)<<r.getPrice()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
retailitem.h
#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <stdlib.h>
using namespace std;
class RetailItem
{
public:
static const unsigned SIZE = 100;
static const unsigned SIZE1 = 100;
static const unsigned SIZE2 = 100;
RetailItem();
void setDescription();
void setUnitsOnHand();
void setPrice();
string getDescription();
double getUnitsOnHand();
double getPrice();
private:
string description;
unsigned unitsOnHand;
double price;
double x,y,z;
double p[SIZE];
string d[SIZE1];
double oh[SIZE2];
};
retailitem.cpp
#include <cstdlib>
#include <iostream>
#include <string>
#include "RetailItem.h"
using namespace std;
RetailItem::RetailItem()
{
}
double RetailItem::getPrice()
{
x = 0;
p[1] = 59.95;
p[2] = 34.95;
p[3] = 24.95;
x++;
return p[x];
}
string RetailItem::getDescription()
{
y=0;
d[1] = "Jacket";
d[2] = "Jeans";
d[3] = "Shirt";
y++;
return d[y];
}
double RetailItem::getUnitsOnHand()
{
z=0;
oh[1] = 12;
oh[2] = 40;
oh[3] = 20;
z++;
return oh[z];
}