Store Program

Write your question here.
Hi everyone,
I have to write a store program for my assignment. I did most of it but now I need to add these things in and I have no idea how to.
1. Display inventory
this should display all the items in the store
2. Add a product
This should let you add an item to the store
3. Display inventory
When you do a display, it should print out all the items including the item just added
4. Delete a product
Deleting an item from the store
5. Display Inventory
Displaying items again.
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
// 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 Store::addProduct (Product &p)
{
	products.push_back (p);
}
void Store::deleteProduct (int id)
{
	products.erase(products.begin() + id);
}
int _tmain(int argc, _TCHAR* argv[])
{
	Product chips (1, "chips", .99 , 1.99, 50);
	Product pepsi (2, "pepsi", 1.99 , 2.99, 50);
	Product oranges (3, "oranges", 5.00, 10.00, 50);
	Product chocolate (4, "chocolate", 0.50, 0.99, 50);
	Product gum (5, "gum", 0.10 , 0.99 , 50);
	Product bread (6, "bread", 1.99 , 2.50, 50);
	Product icecream (7, "ice cream" , 1.00 , 3.00, 50);
	Product apples (8, "apples" , 2.00 , 4.00, 50);
	Product peanutbutter(9, "peanut butter", 1.00 , 3.00 , 50);
	Product eggs (10, "eggs", 2.00 , 5.00 , 50);
	while (true)
	{
	int choice;
	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. Exit" <<endl;
	cout<< "(Enter A Number That Corresponds With Choice)" <<endl;
	cin>> choice;
	if (choice == 1)
	{
		int choice2;
		cout<< "What Would You Like To Buy"<<endl;
		cout<< "1. Chips"<<endl;
		cout<< "2. Pepsi" <<endl;
		cout<< "3. Oranges" <<endl;
		cout<< "4. Chocolate" <<endl;
		cout<< "5. Bubble Gum" <<endl;
		cout<< "6. Bread" <<endl;
		cout<< "7. Ice Cream" <<endl;
		cout<< "8. Apples" <<endl;
		cout<< "9. Peanut Butter" <<endl;
		cout<< "10.Eggs" <<endl;
		cin>> choice2;
		
	}
	return 0;
	}

  
  
You already have these done OP, you just have to call the right member functions based on the user input. What's the problem exactly?

FWIW: I would place Lines 102 - 116 inside of your store class. But that's personal preference I guess.
My teacher wants me to not do everything in the main and to put it in my store class can you help me with that?
Plz can anyone help?
i would recommend putting all the classes into a header file to make it more organized, also your classes are already not in the main source code.

Last edited on
That really doesn't help me any other tips on how to add these things in?
Topic archived. No new replies allowed.