uml diagram
#include <utility>
#include <vector>
class Fireable {
public:
virtual void fire() = 0;
};
class Employee : public Fireable{
Employee() = default;
std::string name;
protected:
explicit Employee(std::string name):name{name}{};
public:
const std::string &getName() const {
return name;
}
double payOwed(){
return 0.0;
}
void fire() override {
std::cout << "You are fired!" << std::endl;
}
};
class Manager : public Employee {
int hoursWorked{0};
double payRate{0.0};
public:
Manager(int hours, double rate,const std::string &name):hoursWorked{hours}, payRate{rate}, Employee(name){
std::cout << "in the employee constructor" << std::endl;
}
double payOwed(){
return hoursWorked * payRate;
}
};
int main() {
Employee *p = new Manager(10,22.5,"john");
std::cout << p->getName() << " is owed " << p->payOwed() << std::endl;
std::vector<Fireable*> firable;
firable.push_back(new Manager(12,25.6,"Bill"));
for(auto f : firable){
f->fire();
}
return 0;
}