Question
Question 1 Using modular programing concepts (creating header file and .cpp file for a class) do the following implementation in sdds as namespace. a.Design a
Question 1
Using modular programing concepts (creating header file and .cpp file for a class) do the following implementation in sdds as namespace.
a.Design a class named Employee.Employee class has the following attributes
name: This is a char pointer that is used to store the name of the Employee
int empNo : a integer number of 6 digits.
Hourly Rate: a double value, negative value is not acceptable
Hours Per Week: an integer value between 20 and 35
b. Make a member function called set, that [3 Marks]
accepts one integer and sets the "Hours Per Week" member data.
If the value received Is not between 20 and 35 then it will set the "Hours Per Week" to zero.
c. Make another (overloaded) member function called set.
The set function gets four arguments and sets all the member data. However, they do need to be validated beforehand. If any of the parameters are invalid, instead of setting the Employee with the values, it set the Employee to a safe empty state.
A constant char pointer for the Employee's name
A integer value for the employee number 0 A double value for the hourly rate A integer value for the hours per week Make sure that your implementation does not make memory leaks.
The Employee's name can't be null or an empty string
Employee number and hourly rate can not be negative number. If the hours per week is not between 20 and 35 (inclusive) then it will set the "Hours Per Week" to zero.
d. Make a "No argument" (default) constructor that sets the class to a safe empty state.
This constructor sets the name to nulltr, and the Employee Number, Hourly Rate and Hours Per Week to zero.
e. Make a constructor that receives 4 arguments and works exactly like the set function with four arguments.
f. Make a destructor
g.Make a member function called print() that prints the Employee information exactly as follows with the same format:
name width as 40
Employee number as 6 digits
2 digits after decimal point for Hourly Rate
If name is an empty string, then the function outputs the following message
Unset Employee Record
If name is not empty but "Hours Per Week" is zero then the function outputs the following message
Fullname 123456 17.23 Invalid work hours
A sample output
class definition in a header file and the function definitions in an implementation file. Both files should be written in a form that compiles and executes successfully under a standard C++ compiler. Make sure that your implementation does not make memory leaks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started