Write a program that uses the class productType defined in Exercises 8 and 10 of this chapter.

Write a program that uses the class productType defined in Exercises 8 and 10 of this chapter.

September 3, 2023
3 Views
0
0

Write a program that uses the class productType defined in Exercises 8 and 10 of this chapter.

Answer and ExplanationSolution by a verified expert

Explanation
#######################################
main.cpp
#######################################
#include "productType.h"

int main() {
productType p("Cerelac", "XYYY-2333", "Nestle", 1002, 23.2, 1.4);
p.print();

p.setQuantitiesInStock(10);
p.print();

p.setDiscount(12);
p.print();

}

#######################################
productType.h
#######################################
#include
#include

using namespace std;

class productType
{

public:

productType();

productType(int, double, double);

productType(string, int, double, double);

productType(string, string, string,

int, double, double);

void set(string, string, string, int,

double, double);

void print() const;

void setQuantitiesInStock(int x);

void updateQuantitiesInStock(int x);

int getQuantitiesInStock() const;

void setPrice(double x);

double getPrice() const;

void setDiscount(double d);

double getDiscount() const;

private:

string productName;

string id;

string manufacturer;

int quantitiesInStock;

double price;

double discount;

};

#######################################
productTypeImp.cpp
#######################################
#include "productType.h"

productType::productType() {
productName = "";
id = "";
manufacturer = "";
quantitiesInStock= 0;
price = 0;
discount = 0;
}

productType::productType(int q, double p, double d) {
productName = "";
id = "";
manufacturer = "";
quantitiesInStock= q;
price = p;
discount = d;
}

productType::productType(string m, int q, double p, double d) {
productName = "";
id = "";
manufacturer = m;
quantitiesInStock= q;
price = p;
discount = d;
}

productType::productType(string pn, string i, string m, int q, double p, double d) {
productName = pn;
id = i;
manufacturer = m;
quantitiesInStock= q;
price = p;
discount = d;
}

void productType::set(string pn, string i, string m, int q, double p, double d) {
productName = pn;
id = i;
manufacturer = m;
quantitiesInStock= q;
price = p;
discount = d;
}

void productType::print() const {
cout << "Produce Name: " << productName << endl;
cout << "Produce Id: " << id << endl;
cout << "Produce Manufacturer: " << manufacturer << endl;
cout << "Quantity in stock: " << quantitiesInStock << endl;
cout << "Price: " << price << endl;
cout << "Discount: " << discount << endl << endl;
}

void productType::setQuantitiesInStock(int x) {
quantitiesInStock = x;
}

void productType::updateQuantitiesInStock(int x) {
quantitiesInStock += x;
}

int productType::getQuantitiesInStock() const {
return quantitiesInStock;
}

void productType::setPrice(double x) {
price = x;
}

double productType::getPrice() const {
return price;
}

void productType::setDiscount(double d) {
discount = d;
}

double productType::getDiscount() const {
return discount;
}

Purchase this answer to view it.
Click the button to login/signup and buy full solution at 2 USD only.

The Best Research Paper Writing Service

Would you want to pay someone to write your paper professionally from scratch? 100% Original and 0% AI Content!.

🎓 Write my Essay
📚 Write my Persuasive Essay
📋 Humanize AI Content for Turnitin
💻 Write my Reflective Essay
📑 Write my Research Paper
📜 Write my Thesis Paper
📘 Write my Dissertation
📋 Write my Case Study
📝 Write my Online Exam
✒️ Write my Term Paper
Write my Paper