Exemplo n.º 1
0
bool Employee::makes_more_than(Employee emp) {

  /* notify users of what is being compared */
  cout << "Is input Employee's salary of " << emp.get_salary() 
       << " less than current Employee's salary of " << salary << endl;
  
  /* compare the two salaries of the Employee objects */
  if( emp.get_salary() < salary ) {
    return true;
  } /* end if */
  else {
    return false;
  } /* end else */
}
Exemplo n.º 2
0
int main()
{  
   cout << "Please enter the data file name: ";
   string filename;
   cin >> filename;
   fstream fs;
   fs.open(filename.c_str());
   fs.seekg(0, ios::end); // Go to end of file
   int nrecord = fs.tellg() / RECORD_SIZE;

   cout << "Please enter the record to update: (0 - "
      << nrecord - 1 << ") ";
   int pos;
   cin >> pos;

   const double SALARY_CHANGE = 5.0;

   Employee e;
   fs.seekg(pos * RECORD_SIZE, ios::beg);
   read_employee(e, fs);
   raise_salary(e, SALARY_CHANGE);
   cout << "New salary: " << e.get_salary();
   fs.seekp(pos * RECORD_SIZE, ios::beg);
   write_employee(e, fs);

   fs.close();
   return 0;
}
Exemplo n.º 3
0
/**
   Writes an employee record to a stream.
   @param e the employee record to write
   @param out the stream to write to
*/
void write_employee(Employee e, ostream& out)
{  
   out << e.get_name()
      << setw(10 + (30 - e.get_name().length()))
      << fixed << setprecision(2)
      << e.get_salary();
}
Exemplo n.º 4
0
/**
   Constructs a department with a given name and receptionist.
   @param n the department name
   @param e the receptionist
*/
Department::Department(string n, Employee e)
{
   name = n;
   receptionist = new Employee(e.get_name(), e.get_salary());
   
   cout << "Constructor: ";
   print();
}
Exemplo n.º 5
0
/**
   Prints a description of this department.
*/
void Department::print() const
{
   cout << "Name: " << name << "\n"
        << "Receptionist: ";
   if (receptionist == NULL)
      cout << "None";
   else
      cout << receptionist->get_name() << " "
           << receptionist->get_salary();
   cout << "\nSecretary: ";
   if (secretary == NULL)
      cout << "None";
   else if (secretary == receptionist)
      cout << "Same";
   else 
      cout << secretary->get_name() << " "
           << secretary->get_salary();      
   cout << "\n";
}
Exemplo n.º 6
0
/** 
   Raises an employee salary.
   @param e employee receiving raise
   @param percent the percentage of the raise
*/
void raise_salary(Employee& e, double percent)
{  
   double new_salary = e.get_salary() * (1 + percent / 100);
   e.set_salary(new_salary);
}
Exemplo n.º 7
0
/**
   Raises an employee salary. 
   @param e employee receiving raise
   @param by the percentage of the raise
*/
void raise_salary(Employee& e, double by)
{  
   double new_salary = e.get_salary() * (1 + by / 100);
   e.set_salary(new_salary);
}