#ifndef PRODUCT_CLASS #define PRODUCT_CLASS #include "tstring.h" #include "textlib.h" const int MARGIN = 100; // gross margin in percent class Product{ private: String serNumber; //the product identifying number String prodName; // product name double sellingPrice; double costPrice; String purpose; void setSellingPrice(double costPrice); public: // constructor Product(String newSerNumber, double costPrice); //access function prototypes String getSerNumber(); String getProdName(); double getSellingPrice(); void writeProdInfo(); // set function prototypes void setProdName(String newProdName); void setCostPrice(double newPrice); void setPurpose(String newPurpose); }; // *********************************************************** // Product class implementation // *********************************************************** // implementation of the Product constructor Product::Product(String newSerNumber, double costPrice) { sellingPrice = ( 1.0 + MARGIN/100.0 )*costPrice; } // implements access functions String Product::getProdName() { return prodName; } double Product::getSellingPrice() { return sellingPrice; } void Product::writeProdInfo() { cout << endl; cout << "The product named " << prodName << " has serial number " << serNumber << endl; cout << "The selling price is $" << setreal(4,2) << sellingPrice << endl; } // implements set functions void Product::setCostPrice(double newPrice) { costPrice = newPrice; } void Product::setProdName(String newProdName) { prodName = newProdName; } #endif