1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
viktelen [127]
4 years ago
8

Consider the definition of the following class: (1, 2, 3, 5, 7) class productType //Line 1 { //Line 2 public: //Line 3 productTy

pe(); //Line 4 productType(int, double, double); //Line 5 productType(string, int, double, double); //Line 6 productType(string, string, string, int, double, double); //Line 7 void set(string, string, string, int, double, double); //Line 8 void print() const; //Line 9 void setQuantitiesInStock(int x); //Line 10 void updateQuantitiesInStock(int x); //Line 11 int getQuantitiesInStock() const; //Line 12 void setPrice(double x); //Line 13 double getPrice() const; //Line 14 void setDiscount(double d); //Line 15 double getDiscount() const; //Line 16 private: //Line 17 string productName; //Line 18 string id; //Line 19 string manufacturer; //Line 20 int quantitiesInStock; //Line 21 double price; //Line 22 double discount; //Line 23 }; //Line 24 a. Give the line number containing the constructor that is executed in each of the following declarations. i. productType product1; ii. productType product2("Microwave", "M3562", "GeneralPool", 35, 175.00, 0.1); iii. productType product3("D1290", 25, 375.00, 0.05); iv. productType product4(10, 8.50, 0.2);
Computers and Technology
1 answer:
Shkiper50 [21]4 years ago
6 0

Answer:

The C++ codes are given below with appropriate comments

Explanation:

// productType.h

#ifndef PRODUCTTYPE_H

#define PRODUCTTYPE_H

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

int getQuantitiesInStock() const;

void updateQuantitiesInStock(int x);

 

void setPrice(double x);

double getPrice() const;

void setDiscount(double d);

double getDiscount() const;

 

 

 

private:

// Declaring variables

string productName;

string id;

string manufacturer;

int quantitiesInStock;

double price;

double discount;

};

#endif

=============================

// productType.cpp

#include <iostream>

using namespace std;

#include "productType.h"

productType::productType()

{

this->productName="";

this->id="";

this->manufacturer="";

this->quantitiesInStock=0;

this->price=0.0;

this->discount=0.0;

}

productType::productType(int quantitiesInStock, double price,double discount)

{

this->productName="";

this->id="";

this->manufacturer="";

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

productType::productType(string productName,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id="";

this->manufacturer="";

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

productType::productType(string productName,string id,string manufacturer,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id=id;

this->manufacturer=manufacturer;

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

void productType::set(string productName,string id,string manufacturer,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id=id;

this->manufacturer=manufacturer;

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

void productType::print() const

{

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

cout<<"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)

{

this->quantitiesInStock=x;

}

int productType::getQuantitiesInStock() const

{

return quantitiesInStock;

}

 

void productType::setPrice(double x)

{

this->price=x;

}

double productType::getPrice() const

{

return price;

}

void productType::setDiscount(double d)

{

this->discount=d;

}

double productType::getDiscount() const

{

return discount;

}

void productType::updateQuantitiesInStock(int x)

{

this->quantitiesInStock=x;

}

=============================

// main.cpp

#include <iostream>

using namespace std;

#include "productType.h"

int main()

{

productType pt("Mobile","1234","Lenovo",34,1500,10);

pt.print();

 

pt.updateQuantitiesInStock(50);

cout<<"\nAfter Modifying the quantity ::"<<endl;

pt.print();

 

return 0;

}

You might be interested in
If an occupation is projected to grow by 13% over the next 10 years, how would you rate the job outlook?
Elena L [17]

Answer:

Steady

Explanation:

Its not an insane growth rate but it would more then likely be Steady.

6 0
3 years ago
Read 2 more answers
If you were to design a range of athletic shoes for various sports activities, what key factors would you consider during the de
mylen [45]
With this you just have to think about what do different shoes do and why? For example, track shoes need to be extremely light to make it so the runners don't need to move excess weight to accelerate faster whereas basketball shoes can be heavier because they need high ankle coverage for more ankle support during moves like the crossover. Then the key factors that I would do personally are: difficulty to produce, benefit to athlete, cost to athlete, weight, and support. My advice would be to systematically go through a bunch of sports and talk about each of their shoes...
4 0
3 years ago
Why we need to interpret the drawing and plans
scoray [572]

Technical drawing is essential for communicating ideas in industry and engineering.

5 0
3 years ago
Explain why the computer is powerful working tool???​
notsponge [240]

Answer:

here ya go

Explanation:

A computer is a powerful tool because it is able to perform the information processing cycle operations (input, process, output, and storage) with amazing speed, reliability, and accuracy; store huge amounts of data and information; and communicate with other computers.

8 0
3 years ago
The five types of personal computers are: desktops, laptops, tablets, smartphones, and
shepuryov [24]

Answer:

microcomputers

Explanation:

8 0
3 years ago
Other questions:
  • To display the control panel window, first right-click ____ and then click control panel.
    5·1 answer
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • On most computers, the default font size in Word is ____. 8 11 14 16
    6·1 answer
  • The standing toe touch is most likely to result in
    15·1 answer
  • If you want to present slides to fellow students or coworkers which productivity software should you use to create them A. Word
    14·2 answers
  • When adding cells you must use a "+" symbol, you cannot use a ":" symbol.<br><br> ☐ True<br> ☐ False
    13·1 answer
  • In addition to paying $100 per month for health insurance, sam is responsible for paying her first $500 of medical bills every y
    10·1 answer
  • Systems Software, Inc., is introducing a new piece of sophisticated graphics software. A recently hired writer has been assigned
    8·1 answer
  • I NEED HELP ASAP
    8·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!