Question: Upload source code for both the dayType class and your test class (all .h and .cpp files). 1. Design and implement a class dayType that

Upload source code for both the dayType class and your test class (all .h and .cpp files).

1. Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type dayType:

Set the day.

Print the day.

Return the day.

Return the next day.

Return the previous day.

Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.

Add the appropriate constructors.

2. Also, write a program to test various operations on this class .

//////////////////////////////////////////////////////////////////////////////////////////////////

C++

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!