subject

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

{ //Line 2

public: //Line 3

productType(); //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);

b. Write the definition of the constructor in Line 4 so that the instance variables are initialized to "", "", "", 0, 0.0, and 0.0, respectively.
c. Write the definition of the constructor in Line 5 so that the string instance variables are initialized to "", and the other instance variables are initialized according to the parameters. Instance variables quantitiesInStock, price, and discount must be nonnegative.
d. Write the definition of the constructor in Line 6 so that the instance variables productName and manufacturer are initialized to the empty string, instance variable id is initialized according to the first parameter, and the remaining instance variables are initialized according to the last three parameters. Instance variables quantitiesInStock, price, and discount must be nonnegative.
e. Write the definition of the constructor in Line 7 so that the instance variables are initialized according to the parameters. Instance variables quantitiesInStock, price, and discount must be nonnegative.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Facial expressions and gestures are examples of messages.
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
3. when you right-click a linked spreadsheet object, what commands do you choose to activate the excel features? a. linked worksheet object > edit b. edit data > edit data c. linked spreadsheet > edit d. object > edit data
Answers: 2
question
Computers and Technology, 23.06.2019 12:40
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
You know the right answer?
Consider the definition of the following class: (1, 2, 3, 5, 7) class productType //Line 1
Questions
question
English, 27.01.2021 17:40
question
English, 27.01.2021 17:40
question
Mathematics, 27.01.2021 17:40
question
Mathematics, 27.01.2021 17:40
question
Mathematics, 27.01.2021 17:50
question
Mathematics, 27.01.2021 17:50
Questions on the website: 13722363