classfor Fresh Products
| 123 | |
| 124 | // classfor Fresh Products |
| 125 | class FreshGroceries : public Item { |
| 126 | private: |
| 127 | double price; |
| 128 | int quantity; |
| 129 | int quantity_purchased; |
| 130 | |
| 131 | public: |
| 132 | |
| 133 | FreshGroceries() { |
| 134 | price = 0.0; |
| 135 | quantity = 0; |
| 136 | quantity_purchased = 0; |
| 137 | } |
| 138 | |
| 139 | FreshGroceries(string name, string UIC, double price, int quantity, int quantity_purchased) : Item(name, UIC) { |
| 140 | this->price = price; |
| 141 | this->quantity = quantity; |
| 142 | this->quantity_purchased = quantity_purchased; |
| 143 | } |
| 144 | |
| 145 | void display() { |
| 146 | Item::display(); |
| 147 | cout << left << setw(20) << price << setw(15) << quantity << endl; |
| 148 | |
| 149 | } |
| 150 | |
| 151 | int get_quantity() { |
| 152 | return quantity; |
| 153 | } |
| 154 | |
| 155 | double get_price() { |
| 156 | return price; |
| 157 | } |
| 158 | |
| 159 | int get_quantity_p() { |
| 160 | quantity--; |
| 161 | quantity_purchased++; |
| 162 | return quantity_purchased; |
| 163 | } |
| 164 | |
| 165 | void input() { |
| 166 | Item::input(); |
| 167 | cout << "Enter the price of a new product: "; |
| 168 | cin >> price; |
| 169 | cout << "Enter the quantity of a new product: "; |
| 170 | cin >> quantity; |
| 171 | } |
| 172 | |
| 173 | }; |
| 174 | |
| 175 | void Purchase(){ |
| 176 | PackedGroceries p; // declaration of object PackedGroceries |
nothing calls this directly
no outgoing calls
no test coverage detected