1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include "Person_Directory.h"
#include "Student.h"
#include "Person.h"
#include "Salaried_Employee.h"
#include "Hourly_Employee.h"
#include <string>
#include <fstream>
#include <istream>
#include <ostream>
using namespace std;
void Person_Directory::load_data(const string& source_name){
ifstream in(source_name.c_str());
if(in) {
int type;
string name;
string ssn;
int age;
string gender;
double gpa;
string major;
int grad_year;
string job_title;
int hire_year;
double hourly_rate;
int hours_worked;
int annual_salary;
while(getline (in, type)) {
Person* person;
if(type == 1){
getline (in, name);
getline (in, ssn);
getline (in, age);
getline (in, gender);
getline (in, gpa);
getline (in, major);
getline (in, grad_year);
person* = new Student(name, snn, age, gender, gpa, major, grad_year));
}else if(type == 2) {
getline (in, name);
getline (in, ssn);
getline (in, age);
getline (in, gender);
getline (in, job_title);
getline (in, hire_year);
getline (in, hourly_rate);
getline (in, hours_worked);
person* = new Hourly_Employee(name, snn, age, gender, job_title, hire_year, hourly_rate, hours_worked);
}else if( type == 3 ) {
getline (in, name);
getline (in, ssn);
getline (in, age);
getline (in, gender);
getline (in, job_title);
getline (in, hire_year);
getline (in, annual_salary);
person* = new Annual_Employee(name, snn, age, gender, job_title, hire_rear, hourly_rate, hours_worked);
}
directory.pushback(person);
delete person;
}
}
}
|