-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3.cpp
More file actions
58 lines (45 loc) · 1.07 KB
/
Copy pathtask3.cpp
File metadata and controls
58 lines (45 loc) · 1.07 KB
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
#include <iostream>
using namespace std;
class Product {
private:
double price;
int stock;
public:
string productName;
string category;
Product(string name, string cat, double p, int s) {
productName = name;
category = cat;
price = p;
stock = s;
}
void setPrice(double p) {
if (p >= 0)
price = p;
}
double getPrice() {
return price;
}
void setStock(int s) {
if (s >= 0)
stock = s;
}
int getStock() {
return stock;
}
void displaySummary() {
cout << "Product Name: " << productName << endl;
cout << "Category: " << category << endl;
cout << "Price: ₹" << price << endl;
cout << "Stock: " << stock << " units" << endl;
}
};
int main() {
Product p1("Laptop", "Electronics", 55000.0, 20);
p1.displaySummary();
p1.setPrice(53000.0);
p1.setStock(18);
cout << "\nAfter Update:\n";
p1.displaySummary();
return 0;
}