コード例 #1
0
int main()
{
	SalaryEmployee salEmp;
	HourlyEmployee hourEmp;
	CommisionEmployee comEmp;

	cout << "The number of employees are " << numberOfEmployees << endl;

	cout << salEmp.empName << ", please enter your Salary : ";
	salEmp.setSalary();

	cout << hourEmp.empName << ", please enter your Hourly Rate : ";
	hourEmp.setHourlyRate();
	cout << hourEmp.empName << ", please enter your Hours worked : ";
	hourEmp.setHoursWorked();

	cout << comEmp.empName << ", please enter your Base Salary : ";
	comEmp.setBaseSalary();
	cout << comEmp.empName << ", please enter your Rate : ";
	comEmp.setRate();
	cout << comEmp.empName << ", please enter your Revenue : ";
	comEmp.setRevenue();

	float total;
	total = salEmp.salary() + hourEmp.salary() + comEmp.salary();
	cout << endl << "The total Salary is : R" << total << endl;




}
コード例 #2
0
int main()
{
	float totalWage = 0;

	SalaryEmployee *Praneel = new SalaryEmployee("Praneel", 202515355);
	cout << "Number of employees: " << Employee::numberOfEmployees << endl;

	HourlyEmployee *Riana = new HourlyEmployee("Riana", 203515655);
	cout << "Number of employees: " << Employee::numberOfEmployees << endl;

	CommissionEmployee *Salesh = new CommissionEmployee("Salesh", 200666666);
	cout << "Number of employees: " << Employee::numberOfEmployees << endl;

	//Set the wages
	Praneel->setSalary(18000.500);
	
	Riana->setHourlyRate(800.500);
	Riana->setHoursWorked(80);

	Salesh->setBaseSalary(8000);
	Salesh->setRate(0.85);
	Salesh->setRevenue(30000);

	cout << Praneel->name() << "'s salary is : " << Praneel->salary() << endl;
	cout << Riana->name() << "'s salary is : " << Riana->salary() << endl;
	cout << Salesh->name() << "'s salary is : " << Salesh->salary() << endl;
	
	//Creating pointer array of the abstract base class

	Employee *emp[3];

	emp[0] = Praneel;   //Since we used pointer no need to use & sign
	emp[1] = Riana;
	emp[2] = Salesh;

	//Calculating total wage
	for (int i = 0; i < 3; i++)
	{
		totalWage = totalWage + emp[i]->salary();
	}

	cout << "Total wages are : " << totalWage << endl;

	//Firing employees
	for (int i = 0; i < 3; i++)
	{
		cout << "Firing " << emp[i]->name() << endl;
		delete emp[i];
		cout << "Number of employees: " << Employee::numberOfEmployees << endl;
	}

	//When adding to a static var using constructor don't update the base constructor static var
	//When decrementing static var using destructor you can still update both base and sub destructors

	system("PAUSE");
	return 0;
}
コード例 #3
0
int main()
{
	/*
	HourlyEmployee bob("Bob", 40, 100);
	bob.setHours((float)60);

	setName("ewq");

	Employee alice("Alice");
	alice.setName("Wonderland");
	alice.setName("Dr.", "Alice");

	cout << alice.getName() << endl;

	cout << "Inherited display()" << endl;
	alice.display();
	bob.display("Bob's Info:");
	bob.display();

	Employee e[] = {bob, alice};

	double total = 0.0;
	for (int i = 0; i < 2; i++)
	{
		total += e[i].getPaycheck();
	}

	cout << "Total: " << endl;
	cout << total << endl;
*/
	HourlyEmployee* he = new HourlyEmployee("Alice", 12.23, 34.45);
	FulltimeEmployee* fe = new FulltimeEmployee("Bob", 123321);
	he->display();
	fe->display();

	Employee* e = he;
	e->display();

	Employee* es[] = { he, fe };
	es[0]->display();
	es[1]->display();

	getchar();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: jannunzi/CS1500Summer2-2015
int main(int argc, const char * argv[]) {
    FullTimeEmployee* f1 = new FullTimeEmployee();
    f1->yearlySalary = 100000;
    f1->type = FULL;

    HourlyEmployee* h1 = new HourlyEmployee();
    h1->hours = 40;
    h1->rate = 70;
    h1->type = HOURLY;

    cout << f1->getWeeklyPay() << endl;
    cout << h1->getWeeklyPay() << endl;

    Employee* employees[] = {f1, h1};
    for(int i=0; i<2; i++)
    {
        Employee* e = employees[i];
        cout << e->getWeeklyPay() << endl;
        HourlyEmployee* h;
        FullTimeEmployee* f;
        switch (e->type) {
        case HOURLY:
            h = (HourlyEmployee*)e;
            cout << h->getWeeklyPay() << endl;
            break;
        case FULL:
            f = (FullTimeEmployee*)e;
            cout << f->getWeeklyPay() << endl;
            break;
        }
    }


    for(int i=0; i<2; i++)
    {
        Employee* e = employees[i];
        cout << e->getWeeklyPay() << endl;
    }
}
コード例 #5
0
ファイル: 15-07.cpp プロジェクト: Zezyn/CPlusPlus
int main( )
{
    HourlyEmployee joe;
    joe.set_name("Mighty Joe");
    joe.set_ssn("123-45-6789"); 
    joe.set_rate(20.50);
    joe.set_hours(40);
    cout << "Check for " << joe.get_name( )
         << " for " << joe.get_hours( ) << " hours.\n";
    joe.print_check( );
    cout << endl;

    SalariedEmployee boss("Mr. Big Shot", "987-65-4321", 10500.50);
    cout << "Check for " << boss.get_name( ) << endl;
    boss.print_check( ); 

    return 0;
}
コード例 #6
0
int main()
{
  Employee x;
  Employee y("John", "351951015");
  cout << y.getName() << " " << y.getSsn() << endl;

  HourlyEmployee Joe("Mighty Joe", "123-45-6789", 20.50, 40);
  Joe.printCheck(); 

  HourlyEmployee Mike;
  Mike.setName("Mighty Mike");
  Mike.setSsn("123-45-6789");
  Mike.setWageRate(20.50);
  Mike.setHour(40);
  Mike.printCheck();


  TitledEmployee Noor;
  Noor.setTitle("Dr.");
  Noor.setName("Nurur Rahman");
  Noor.setSsn("123-45-6789");
  Noor.printEmployeeData();
  
  TitledEmployee NR("Nurur Rahman", "123-45-6789", 325000, "Dr.");

  
  Administrator Nurur;
  Nurur.setName("Nurur Rahman");   //Inherited from Employee
  Nurur.setSsn("123-45-6789");     //Inherited from Employee
  Nurur.setSalary(5000);           //Inherited from SalariedEmployee
  Nurur.setTitle("Director");
  Nurur.setResponsibility("Computing");
  Nurur.setSupervisor("Robert Brandenburger");
  Nurur.printEmployeeData();
  Nurur.printCheck();
  

  return 0;
}
コード例 #7
0
int main()
{
  HourlyEmployee Joe("Mighty Joe", "123-45-6789", 20.50, 40);
  Joe.printCheck(); 


  HourlyEmployee Mike;
  Mike.setName("Mighty Mike");
  Mike.setSsn("123-45-6789");
  Mike.setWageRate(20.50);
  Mike.setHour(40);
  Mike.printCheck();


  SalariedEmployee Noor;
  Noor.setName("Nurur Rahman");
  Noor.setSsn("123-45-6789");
  Noor.setSalary(325000.00);
  Noor.printCheck();

  return 0;
}