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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
// Store.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
class Product
{
public:
int productId;
string productName;
double buyPrice;
double sellPrice;
int qty;
int soldQty;
public:
Product(int id, string name, double bprice, double sprice, int q);
int getProductId() const;
string getProductName() const;
double getBuyPrice() const;
double getSellPrice() const;
int getSoldQty() const;
};
Product::Product(int id, string name, double bprice, double sprice, int q)
{
productId = id;
productName = name;
buyPrice = bprice;
sellPrice = sprice;
qty = q;
soldQty = 0;
}
int Product::getProductId() const {
return productId;
}
string Product::getProductName() const {
return productName;
}
double Product::getBuyPrice() const
{
return buyPrice;
}
double Product:: getSellPrice() const
{
return sellPrice;
}
int Product::getSoldQty() const
{
return soldQty ;
}
class Store
{
private:
int calcprofits;
vector <Product> products;
public:
void addProduct (Product &p);
void deleteProduct (int id);
void displayMenu ();
void displayInv ();
};
void Store::addProduct (Product &p)
{
products.push_back (p);
}
void Store::deleteProduct (int id)
{
products.erase(products.begin() + id);
}
void Store ::displayMenu ()
{
cout<< "What Would You Like To Do" <<endl;
cout<< "1. Sell" << endl;
cout<< "2. Restock" <<endl;
cout<< "3. CalcProfits" <<endl;
cout<< "4. CalcSales" <<endl;
cout<< "5. Add Product" <<endl;
cout<< "6. Delete Product" <<endl;
cout<< "7 Print Inventory" <<endl;
cout<< "8. Exit" <<endl;
cout<< "(Enter A Number That Corresponds With Choice)" <<endl;
}
void Store ::displayInv ()
{
for(int x = 0; x < products.size() ; x++)
{
Product p = products[x];
cout<< p.getProductId();
cout<< p.getProductName ();
cout<< p.getBuyPrice ();
cout<< p.getSellPrice ();
cout<< p.getSoldQty ();
}
}
int _tmain(int argc, _TCHAR* argv[])
{
Store ucStore;
cout<< "Welcome to The Union City Store";
while(true)
{
ucStore.displayMenu();
int choice;
cin>> choice;
int id;
string name;
double bprice;
double sellprice;
int qty;
int product;
switch (choice)
{
case 7:
ucStore.displayInv();
break;
case 5:
cout<< "Enter product id";
cin>> id;
cout<< "Enter product name";
cin>> name;
cout<< "Enter buy price";
cin>> bprice;
cout<< "Enter sell price";
cin>> sellprice;
cout<< "Enter Quantity";
cin>> qty;
Product p (id,name,bprice,sellprice,qty);
ucStore.addProduct(p);
break;
case 1:
ucStore.displayInv();
cout<< "What would you like to buy";
cin>> product;
}
}
return 0;
}
}
|