Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For my first question, a few days ago, you all gave me the below answer, however the professor says that I was given maybe somewhat

For my first question, a few days ago, you all gave me the below answer, however the professor says that I was given maybe somewhat different instructions it seems, that are shown in "red ink". Can you all find the solution to this?

#include #include #include "productType.h"

using namespace std;

//Default Constructor productType::productType() { productType::productName = "---"; productType::id = "---"; productType::manufacturer = "---"; productType::quantitiesInStock = 0; productType::price=0.0; productType::discount=0.0; }

//3 - argument Constructor productType::productType(int qty, double price, double disc) { productType::productName = "---"; productType::id = "---"; productType::manufacturer = "---"; productType::quantitiesInStock = qty; productType::price=price; productType::discount=disc; }

//4 - argument Constructor productType::productType(string manufacturer, int qty, double price, double disc) { productType::productName = "---"; productType::id = "---"; productType::manufacturer = manufacturer; productType::quantitiesInStock = qty; productType::price=price; productType::discount=disc; }

//6 - argument Constructor productType::productType(string prodName, string tid, string manufacturer, int qty, double price, double disc) { productType::productName = prodName; productType::id = tid; productType::manufacturer = manufacturer; productType::quantitiesInStock = qty; productType::price=price; productType::discount=disc; }

//Set Method void productType::set(string prodName, string tid, string manufacturer, int qty, double price, double disc) { productType::productName = prodName; productType::id = tid; productType::manufacturer = manufacturer; productType::quantitiesInStock = qty; productType::price=price; productType::discount=disc; }

//Printing values void productType::print() const { cout << " Product Information: "; cout << " Name: " << productType::productName; cout << " Id: " << productType::id; cout << " Manufacturer: " << productType::manufacturer; cout << " Quantity in Stock: " << productType::quantitiesInStock; cout << " Price: " << productType::price; cout << " Discount: " << productType::discount << " "; }

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

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

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

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

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

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

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

File: main.cpp

#include #include #include "productType.h"

using namespace std;

int main() { //Declaring an object productType pt("Pencil", "P001", "Apsara", 30, 5.2, 0.8);

//Printing product info pt.print();

//Updating quantity pt.updateQuantitiesInStock(8);

//Printing product info pt.print();

return 0; }

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

The professor has said this today.

The following should go in the main program (This is what I gave in the example).

#//Main program

#include

#include

#include "productType.h"

using namespace std;

int main()

{

productType product1;

productType product2("Microwave", "M3562", "GeneralPool",

35, 175.00, 0.1);

productType product3("D1290", 25, 375.00, 0.05);

productType product4(10, 8.50, 0.2);

product1.print();

cout << "***************" << endl << endl;

product2.print();

cout << "***************" << endl << endl;

return 0;

}

The following should go into productType.h (This is what I gave in the example)

#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;

};

I would revise what you have below for productTypeimp.cpp as I show below. I would compare what you have below with what is in red below.

#include

#include

#include

#include "productType.h"

using namespace std;

productType::productType()

{

productName = "";

id = "";

manufacturer = "";

quantitiesInStock = 0;

price = 0.0;

discount = 0.0;

}

productType::productType(int x, double y, double z)

{

productName = "";

id = "";

manufacturer = "";

if (x >= 0)

quantitiesInStock = x;

else

quantitiesInStock = 0;

if (y >= 0.0)

price = y;

else

price = 0.0;

if (z >= 0.0)

discount = z;

else

discount = 0.0;

}

productType::productType(string s, int x, double y, double z)

{

productName = "";

id = s;

manufacturer = "";

if (x >= 0)

quantitiesInStock = x;

else

quantitiesInStock = 0;

if (y >= 0.0)

price = y;

else

price = 0.0;

if (z >= 0.0)

discount = z;

else

discount = 0.0;

}

productType::productType(string n, string pID, string m,

int x, double y, double z)

{

productName = n;

id = pID;

manufacturer = m;

if (x >= 0)

quantitiesInStock = x;

else

quantitiesInStock = 0;

if (y >= 0.0)

price = y;

else

price = 0.0;

if (z >= 0.0)

discount = z;

else

discount = 0.0;

}

void productType::set(string n, string pID, string m,

int x, double y, double z)

{

productName = n;

id = pID;

manufacturer = m;

if (x >= 0)

quantitiesInStock = x;

else

quantitiesInStock = 0;

if (y >= 0.0)

price = y;

else

price = 0.0;

if (z >= 0.0)

discount = z;

else

discount = 0.0;

}

void productType::print() const

{

cout << "Product Name: " << productName << endl;

cout << "Product ID: " << id << endl;

cout << "Manufacturer: " << manufacturer << endl;

cout << "Quantities In Stock: " << quantitiesInStock

<< endl;

cout << "Price: " << price << endl;

cout << "Discount: " << discount << endl;

}

void productType::setQuantitiesInStock(int x)

{

if (x >= 0)

quantitiesInStock = x;

else

quantitiesInStock = 0;

}

void productType::updateQuantitiesInStock(int x)

{

quantitiesInStock = quantitiesInStock + x;

if (quantitiesInStock < 0)

quantitiesInStock = 0;

}

int productType::getQuantitiesInStock() const

{

return quantitiesInStock;

}

void productType::setPrice(double x)

{

if (x >= 0.0)

price = x;

else

price = 0;

}

double productType::getPrice() const

{

return price;

}

void productType::setDiscount(double d)

{

if (d >= 0.0)

discount = d;

else

discount = 0;

}

double productType::getDiscount() const

{

return discount;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What do you need to know about motivation to solve these problems?

Answered: 1 week ago

Question

Does it have at least one-inch margins?

Answered: 1 week ago

Question

Does it highlight your accomplishments rather than your duties?

Answered: 1 week ago