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
|
#include <iostream>
#include <string>
using namespace std;
class inventory
{
public:
inventory();
inventory(string);
inventory(string, int, double);
inventory(string, int, double, int);
void printInventory() const;
private:
string name;
int itemNum;
double price;
int unitsInStock;
};
inventory::inventory() //default constructor
{
name = "";
itemNum = -1;
price = 0.0;
unitsInStock = 0;
}
inventory::inventory (string n)
{
name = n;
itemNum = -1;
price = 0.0;
unitsInStock = 0;
}
inventory::inventory (string n, int iNum, double cost)
{
name = n;
itemNum = iNum;
price = cost;
unitsInStock = 0;
}
inventory::inventory (string n, int iNum, double cost, int inStock)
{
name = n;
itemNum = iNum;
price = cost;
unitsInStock = inStock;
}
void printInventory (string n, int iNum, double cost, int inStock)
{
cout << "Item name is : " << n;
cout << "Item number is : " << iNum;
cout << "Item price is : " << cost;
cout << "Items in stock : " << inStock;
}
int main()
{
inventory item1();
inventory item2("Dryer");
inventory item3("Washer", 2345, 278.95);
inventory item4("Toaster", 8231, 34.49, 200);
printInventory (item1);
printInventory (item2);
printInventory (item3);
printInventory (item4);
system("PAUSE");
return EXIT_SUCCESS;
}
|