#include <string>

class Employee {
public:
  Employee(string theName, float thePayRate);

  virtual ~Employee();

  string getName() const;
  float getPayRate() const;

  float pay(float hoursWorked) const;

  void print(float hoursWorked) const {
  cout << "Name: " << name << endl;
  cout << "Pay rate: " << payRate << endl;
  printPay(hoursWorked);
  }

  void printPay(float hoursWorked) const {
  cout << "Pay: " << hoursWorked*payRate << endl;
  }

  

protected:
  string name;
  float payRate;
};

class Manager : public Employee {
public:
  Manager(string theName,
          float thePayRate,
          bool isSalaried);

  bool getSalaried() const;

  float pay(float hoursWorked) const;

protected:
  bool salaried;
};

Employee::Employee(string theName, float thePayRate)
{
  name = theName;
  payRate = thePayRate;
}

Employee::~Employee() {}

string Employee::getName() const
{
  return name;
}

float Employee::getPayRate() const
{
  return payRate;
}

float Employee::pay(float hoursWorked) const
{
  return hoursWorked * payRate;
}

// void Employee::printPay(float hoursWorked) const 
//{
//  cout << "Pay: " << pay(hoursWorked) << endl;
//}

Manager::Manager(string theName,
                 float thePayRate,
                 bool isSalaried)
  : Employee(theName, thePayRate)
{
  salaried = isSalaried;
}

bool Manager::getSalaried() const
{
  return salaried;
}

float Manager::pay(float hoursWorked) const
{
  if (salaried)
    return payRate;
  /* else */
  return Employee::pay(hoursWorked);
}

void PrintPay(const Employee &empl,
              float hoursWorked);

int main() 
{
  Employee *emplP;

  string choice;
  cout << "What kind of employee do you want? " << endl;
  cout << "Please enter Manager or Employee " << endl; 
  cin >> choice;

  if (choice == "Employee" || choice == "employee" ) {
    emplP = new Employee("John Burke", 25.0);
  } else if (choice == "Manager" || choice == "manager" ) {
    emplP = new Manager("Jan Kovacs", 1200.0, true);
  } else {
    cerr << "Unrecognized kind of employee: " << choice << "!" << endl;
    return 1;  // Exit program, returning error code.
  }

  cout << "\nEmployee info..." << endl;
  cout << "Name: " << emplP->getName() << endl;
  cout << "Pay Rate: " << emplP->getPayRate() << endl;

  cout << "\nUsing pay() method..." << endl;
  cout << "Pay: " << emplP->pay(40.0) << endl;

  cout << "\nUsing PrintPay() function..." << endl;
  PrintPay(*emplP, 40.0);

  cout << "\nUsing printPay() method..." << endl;
  emplP->printPay(40.0);

  cout << "\nEmployee info using print() method..." << endl;
  emplP->print(40.0);

  return 0;
}

void PrintPay(const Employee &empl,
              float hoursWorked)
{
  cout << "Pay: " << empl.pay(hoursWorked) << endl;
}

