Given main, define the Product class that will manage product inventory. Product class has three private member fields: a product

Given main, define the Product class that will manage product inventory. Product class has three private member fields: a product code (String), the product’s price (double), and the number count of product in inventory (int). Implement the following Constructor and member methods as listed below: public Product(String code, double price, int count) – set the member fields using the three parameters public void setCode(String code) – set the product code (i.e. SKU234) to parameter code public String getCode – return the product code public void setPrice(double p) – set the price to parameter p public double getPrice – return the price public void setCount(int num) – set the number of items in inventory to parameter num public int getCount – return the count public void addInventory(int amt) – increase inventory by parameter amt public void sellInventory(int amt) – decrease inventory by parameter amt
Output each floating point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision (2): once before all other cout statements Current file: main.cpp File is marked as read only 1 tinclude 2 #include 3 #include 5 #include "Product.h" 6 using namespace std; 7 8 int main 9 10 string name "Apple"; 11 double price - 0.40; 12 int num= 3; 14 15 16 17 18 19 20 23 Product p - Product (name, price, num); cout << fixed << setprecision(2); // Test 1 - Are instance variables set/returned properly? cout << "Name: " << p.GetCode << endl; // should be Apple cout << "Price: "< 5 using namespace std; 6 7 class Product 8 9 public: 10 Product(string, double, int); 11 void setcode(string); 12 string GetCode: void SetPrice(double); 14 double GetPrice; 15 void Setcount(int): 16 int GetCount; 17 void Addinventory(int); 18 void sellinventory(int); 19 20 bivate: Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Be input values in the first box, then click Runnmaram Current file: Product.h File is marked as read only 7 class Product 9 public: 10 Product(string, double, int); 11 void setcode(string), 12 string GetCode; 13 void SetPrice(double); 14 double GetPrice; 15 void Setcount(int); 16 int GetCount; void Add Inventory(int); void sell Inventory (int); 19 20 private: 21 string code: 22 double price; 22 int count: 25 26 Wondit/" PRODUCTIE Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, input values in the first box, then click Run program and observe the program's second box Current file: Product.cpp 1 include 2 #include 3 winclude "Product.h" 4 5 using namespace std; 6 7 double inventoryValue; 8); 9 10 InventoryItem: InventoryItem { product - **; inventory - ; 13 price - 0.8; 12 15 17 16 InventoryItem: InventoryItem(string prod, int in double p) product - prod; 18 inventory - in; 19 price-P 20) Develop mode Submit mode Run your program as often as yowd like, before submitting for grading input values in the first box, then click Run program and observe the p Current file: Product.cpp LOE 26 29 33 25 void Inventoryitem::set Inventory(int in) inventory - in; 27 ) 28 vold InventoryItent: setPrice(double ) { price - P: 11 12 string InventoryttemgetProduct return product; 34) 35 int Inventory Item::getInventory return inventory: 37) 38 double Inventorytent getPrice return prices 40) 42 double Inventorytent inventoryvalue) return Inventory price: M 16 39 41 Develop mode Submit mode Run your program as often as you'd like before submitting for grading, Below input values in the first box, then click Run program and observe the program second box


CategoriesUncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *