Question
C++ Employee Class Project #2 For a class I have to take a program I previously created and adapt it to use read and write
C++ Employee Class Project #2
For a class I have to take a program I previously created and adapt it to use read and write functions. I have the prgraom working in its current state but Im a little lost as to where I am supposed to go from here.
Here is my .cpp
http://pastebin.com/5DFDq0ep
Here is my .h
http://pastebin.com/EVR0R7K8
Here are the assignment instructions provided by my instructor
The Employee Class
For this project you need to add the following functions to your Employee class.
- read(ifstream&)
- write(ofstream&)
Note that read is a static member function. It returns an Employee object based on the data it reads from a file. If there is an read error, it throws a std::runtime_error exception with an appropriate message.
The Driver
Your driver will contain a main( ) function that does the following. You may use this description as your pseudo-code:
1. Presents the user with a menu of choices: create a data file, or read data from a file and print checks.
If the user selects the first option, your program should
- Create an ofstream object using a file name obtained from the user. Pass just the file name as the parameter (no path) so that your program assumes the file to be in the same folder as your executable file.
- Create three employee objects as shown:
------Employee joe(37, "Joe Brown", "123 Main St.", "123-6788", 45, 10.00);
------Employee sam(21, "Sam Jones", "45 East State", "661-9000", 30, 12.00);
------Employee mary(15, "Mary Smith", "12 High Street", "401-8900", 40, 15.00);
- Send messages to each of the three Employee objects to write themselves out to the file.
- Print an message that creation of the file is complete.
- Exit.
2. If the user selects the second option, your program should:
- Prompt for the name of the file that you just saved.
- Call Employee::read to read in the objects written in step 1.
- Call the printCheck( ) function for each of the three new objects, just as you did in the previous project.
- Exit.
- Run this option twice. Once with the correct filename, and once with an incorrect one. The second run will test your exception handling. In the error case, throw a std::runtime_error (defined in
Submitting Your Assignment
After you are satisfied that your program works correctly submit it in accordance with course standards. Check to make sure you have included the following:
1. A PDF of your class diagram.
2. The complete source code for your Employee class (employee.h and employee.cpp)
3. The source code for your driver.
4. A screen shot of your execution results.
Users 10002705 Documents\Server Backup 1410Newprojects projecto4projo4Debugprojo4.... le E0 CM This program has two options: Create a data file or 2 Read data from a file and print paychecks. Please enter (1) to create a file or X2> to print checksStep 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