MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / PackedGroceries

Class PackedGroceries

Lab_21/e-commerce.cpp:67–122  ·  view source on GitHub ↗

class for Packed Products

Source from the content-addressed store, hash-verified

65
66// class for Packed Products
67class PackedGroceries : public Item {
68
69private:
70 double price;
71 int quantity;
72 int quantity_purchased;
73public:
74
75 PackedGroceries() {
76 price = 0.0;
77 quantity = 0;
78 quantity_purchased = 0;
79 }
80
81 PackedGroceries(string name, string UIC, double price, int quantity, int quantity_purchased) : Item(name, UIC) {
82 this->price = price;
83 this->quantity = quantity;
84 this->quantity_purchased = quantity_purchased;
85 }
86
87 void display() {
88 Item::display();
89 cout << left << setw(20) << price << setw(15) << quantity << endl;
90 }
91
92 void input() {
93 Item::input();
94 cout << "Enter the price of a new product: ";
95 cin >> price;
96 cout << "Enter the quantity of a new product: ";
97 cin >> quantity;
98 }
99
100 void set_quantity(int quantity) {
101 this->quantity = quantity;
102 }
103
104 int get_quantity() {
105 return quantity;
106 }
107
108 double get_price() {
109 return price;
110 }
111
112 void set_quantity_p(int quantity_purchased) {
113 this->quantity_purchased = quantity_purchased;
114 }
115
116 int get_quantity_p() {
117 quantity_purchased++;
118 quantity--;
119 return quantity_purchased;
120 }
121
122};
123
124// classfor Fresh Products

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected