Starting from:

$30

Lab #3 SOlution




Employee




For this lab, you will de ne the three classes Name, Address and Employee.




Your group will have to rewrite the given method so that they perform their descriptions correctly.




The header le \Name.h" contains the class Name, which consists of



Private string eld named rstName. Private string eld named lastName.




Public default constructor that assigns the empty string to both rstName and lastName.




Public overloaded constructor that takes two strings as parameters named rstName and lastName respectively. If the parameters are valid names (they consist of only letters), they should be assigned to their respective elds (match the names); however, if any parameter is invalid, assign its respective eld the empty string.




Public copy constructor that performs a shallow copy.




Public overloaded assignment operator that performs a shallow copy. Public get method for rstName.




Public get method for lastName.




Public set method for rstName that assigns the parameter to rstName only if it is a valid name. Public set method for lastName that assigns the parameter to lastName only if it is a valid name.




Public string constant method named ToString() that takes no parameters. It returns a string with the format rstName followed by lastName with a space between them.




Public overloaded ostream operator that the displays a Name object in the same format as ToString().




The header le \Address.h" contains the class Address, which consists of



Private string eld named street. Private string eld named city. Private string eld named state. Private string eld named zipcode.




Public default constructor that assigns the empty string to both street and city,\NY" to state and \11111" to zipcode.




Public overloaded constructor that takes four strings as parameters named street, city, state and zipcode respec-tively. It assigns street to the street eld. It assigns city to the city eld only if city is a valid name (consists of only letters); otherwise, it assigns the empty string to the city eld. It assigns state to the state eld only if state is a valid initial (consists of only two letters); otherwise, it assigns \NY" to the state eld. And it assigns zipcode to the zipcode eld only if zipcode is a valid zipcode (consists of exactly ve digits); otherwise, it assigns \11111" to the zipcode eld.




Public copy constructor that performs a shallow copy.




Public overloaded assignment operator that performs a shallow copy. Public get method for street.




Public get method for city. Public get method for state. Public get method for zipcode. Public set method for street.

Public set method for city that assigns the parameter to city only if it is a valid name.




Public set method for state that assigns the parameter to state only if it is a valid initial.




Public set method for zipcode that assigns the parameter to zipcode only if it is a valid zipcode.




Public string constant method named ToString() that takes no parameters. It returns a string with the format street on its own line, followed by city comma state space zipcode.




Public overloaded ostream operator that the displays a Name object in the same format as ToString().




The header le \Employee.h" contains the class Employee, which consists of



Private Name eld named name.




Private Address eld named address. Private int eld named employeeId.




Private double eld named salary.




Private int static eld named nextId which is initialized to 1.




Public default constructor that assigns the default Name object to name, default Address object to address, nextId to employeeId and 5000 to salary. It also increments nextId by 1.




Public overloaded constructor that takes a Name, Address and a double as parameters named name, address and salary respectively. It assigns name to the name eld. It assigns address to the address eld. It assigns salary to the salary eld only if salary is at least 5000; otherwise, it assigns 5000 to the salary eld. And it assigns nextId to employeeId. It also increments nextId by 1.




Public copy constructor that performs a shallow copy.




Public overloaded assignment operator that performs a shallow copy. Public get method for name.




Public get method for address.




Public get method for employeeId. Public get method for salary.




Public static get method for nextId. Public set method for name.




Public set method for address.




Public set method for salary that assigns the parameter to salary only if it is at least 5000.




Public string constant method named ToString() that takes no parameters. It returns a string with the format name space employeeId on their own line, followed by address on its own line, followed salary.




Public overloaded ostream operator that the displays a Name object in the same format as ToString().

More products