Esempio n. 1
0
int main()
{
	//prints my info
	cout<<"Assignment 5A: EmployeeDriver.cpp" <<endl;
	cout<<"Ashkon Honardoost"<<endl;
	cout<<"Comsc 200"<<endl;
	cout<<"Editor:Sublime Text"<<endl;
	cout<<"Compiler: G++"<<endl;
	
	//creates employe object with birthdate and name
	Date birth(12,11,1994);
	Date hire(10, 25, 2012);
	Employee a("Ashkon","Honardoost",birth,hire);

	//test the obecjt
	cout << "Testing the print Function. It should printout the info of the canidate and his hire date"<<endl;
	a.print();
	cout << endl<<endl;
	{
	//copying the employee object
	const Employee copy = a;

	cout<<"Testing the copy of object A that was just printed. Results should be the same"<<endl;
	copy.print();
	cout << endl;
	}
}
Esempio n. 2
0
void virtualViaRef(const Employee &baseClassRef)
{
	baseClassRef.print();
	cout << endl;
	SHOW(baseClassRef.earnings());
	cout << "\n" << endl;
}
int main()
{

	DatasimDate myBirthday(29, 8, 1952);
	string myName ("Daniel J. Duffy");
	Person dd(myName, myBirthday);
	dd.print();

	DatasimDate bBirthday(06, 8, 1994);
	string bName ("Brendan Duffy");
	Person bd(bName, bBirthday);
	bd.print();
	
	Employee dde (myName, myBirthday, string("Cuchulainn Chief"), 0.01, 65);
	dde.print();

	cout << "Working with pointers I\n"; // Non-polymorphic function
	Person* p = &dde;
	p -> print();

	cout << "Working with pointers II\n"; // Polymorphic function
	p -> DeepPrint();

	return 0;
}
Esempio n. 4
0
int main()
{
	Date birth(7,1,1990,1);
	Date hire (10,1,2016,2);

	Employee swe ("Desouky","Abdelqawy",birth,hire);
	swe.print();

}
Esempio n. 5
0
int main(){
	Employee A;
	Employee B("wang");
	Employee C(B);
	A.print(cout);
	B.print(cout);
	C.print(cout);
	return 0;
}
Esempio n. 6
0
void Company::printWorkers() const
{
	int i;
	for ( i = 0; i < numPeople; i++)
	{
		Employee e = (*workers[i]);
		e.print();
	}
}
Esempio n. 7
0
int main(int argc, char const *argv[]) {

    int age(32);
    std::string name = "Zooce";
    PersonalInfo info = { age, name };
    Employee* newEmployee = new Employee(123, info, EmployeeType::HOURLY);
    newEmployee->print();
    delete newEmployee;

    return 0;
}
Esempio n. 8
0
int main()
{
    Date birth(11,23,1995);
    Date hire(02, 21, 2015);
    Employee a("Sohaib","Syed",birth,hire);

    //test the obecjt
    cout << "Testing the print Function. It should printout the info of the canidate and his hire date"<<endl;
    a.print();
    cout << endl <<endl;
    {
        //copying the employee object
        const Employee copy = a;

        cout<<"Testing the copy of object A that was just printed. Results should be the same"<<endl;
        copy.print();
        cout << endl;
    }

}
Esempio n. 9
0
// call Employee virtual function print and earnings off a
// base-class reference using dynamic binding
void virtualViaReference(const Employee& baseClassRef) {
    baseClassRef.print();
    std::cout << "\nearned $" << baseClassRef.earnings() << "\n\n";
}
Esempio n. 10
0
// Make virtual function calls off a base-class reference
// using dynamic binding.
void virtualViaReference( const Employee &baseClassRef )
{
   baseClassRef.print();
   cout << " earned $" << baseClassRef.earnings();
}
Esempio n. 11
0
void virtualViaReference( const Employee &baseClassRef )
{
    baseClassRef.print();
    cout << "\nretribuzione $" << baseClassRef.earnings() << "\n\n";
} 
Esempio n. 12
0
// call Employee virtual functions print and earnings off a 
// base-class reference using dynamic binding
void virtualViaReference( const Employee &baseClassRef )
{
   baseClassRef.print();
   cout << "\nearned $" << baseClassRef.earnings() << "\n\n";
} // end function virtualViaReference
Esempio n. 13
0
int main()
{  
  /* Lab #6 demonstrations and tests */
  cout << "Demonstrations from Lab 6:" << endl;
  Employee harry("Hacker, Harry", 55000.00);

  double new_salary = harry.get_salary() + 3000;
  harry.set_salary(new_salary);

  cout << "Name: " << harry.get_name() << "\n";
  cout << "Salary: " << harry.get_salary() << "\n";

  harry.print();

  Employee nate("Nate", 2500);
  Employee nick("Nick", 4500);
  nate.print();
  nick.print();

  Employee* james;
  james = new Employee("James", 230505);
  Employee* william;
  william = new Employee("William", 45000);
  james->print();
  william->print();


  /* Employee class & Supervisor subclass demonstration, for part 1 */
  cout << "\nPart 1 Demonstrations:" << endl;

  // Employee object in Employee variable
  cout << "\nEmployee object in an Employee variable:" << endl;
  Employee rachael("Rachael", 40000);
  rachael.print(); // print the Employee object

  // Pointer to Employee object in Employee* variable
  cout << "\nPointer to an Employee object in an Employee* variable:" << endl;
  Employee* bethany = new Employee("Bethany", 60000);
  bethany->print(); // print the Employee object pointed to

  // Supervisor object in Supervisor variable
  cout << "\nSupervisor object in a Supervisor variable:" << endl;
  Supervisor bill("Bill", 85000, "Publishing", 25);
  bill.print_super(); // print the Supervisor object

  // Pointer to Supervisor object in Supervisor* variable
  cout << "\nPointer to a Supervisor object in a Supervisor* variable:" << endl;
  Supervisor* adam = new Supervisor("Adam", 72500, "Testing", 15);
  adam->print_super(); // print the Supervisor object pointed to

  
  /* HighLevelSupervisor/Supervisor/Employee demonstrations, for part 2 */
  cout << "\nPart 2 Demonstrations:" << endl;

  // more Employee & Supervisor examples
  cout << "\nTwo more employees, in Employee and Employee* variables:" << endl;
  Employee roger("Roger", 2500);
  roger.print();
  Employee* leon = new Employee("Leon", 6000);
  leon->print();

  cout << "\nTwo more supervisors, in Supervisor and Supervisor* variables:" << endl;
  Supervisor johnny("Johnny", 7205, "FX", 40);
  johnny.print_super();
  Supervisor* richard = new Supervisor("Richard", 8400, "Ads", 11);
  richard->print_super();

  // HighLevelSupervisor object in HighLevelSupervisor variable
  cout << "\nHighLevelSupervisor object in HighLevelSupervisor var:" << endl;
  HighLevelSupervisor phynn("Phynn", 150000, "Production", 8);
  phynn.print_hlsuper(); // print the HighLevelSupervisor object

  // Pointer to HighLevelSupervisor object in HighLevelSupervisor* variable
  cout << "\nPointer to HighLevelSupervisor obj. in HighLevelSupervisor* var:" << endl;
  HighLevelSupervisor* antonia = new HighLevelSupervisor("Antonia", 25000, "Singer", 0);
  antonia->print_hlsuper();


  /* Virtual & dynamic binding demonstations, for part 3 */
  cout << "\nPart 3 Demonstrations:" << endl;

  /* HighLevelSupervisor object whose pointer is in an Employee* variable */
  Employee* tania = new HighLevelSupervisor("Tania", 24500, "Vocals", 10);
  cout << "\nHighLevelSupervisor object whose pointer in an Employee* variable:";
  cout << "\nOutput of print():" << endl; 
  tania->print(); // call to normal print method for Employee class
  cout << "Output of printv():" << endl;
  tania->printv(); // call to virtual print method

  /* Supervisor object whose pointer is in an Employee* variable */
  Employee* sam = new Supervisor("Sam", 1000, "Film", 18);
  cout << "\nSupervisor object whose pointer in an Employee* variable:";
  cout << "\nOutput of print():" << endl;
  sam->print(); // call to normal print method for Employee class
  cout << "Output of printv():" << endl;
  sam->printv(); // call to virtual print method

  /* HighLevelSupervisor object whose pointer is in a Supervisor* variable */
  Supervisor* blake = new HighLevelSupervisor("Blake", 50400, "Dev", 30);
  cout << "\nHighLevelSupervisor object whose pointer in an Supervisor* variable:";
  cout << "\nOutput of print_super():" << endl; 
  blake->print_super(); // call to normal print method for Supervisor class
  cout << "Output of printv():" << endl;
  blake->printv(); // call to virtual print method

  
  /* makes_more_than functions demonstrations, for part 4 */
  cout << "\nPart 4 Demonstrations:" << endl;
  
  cout << "\nReturn value of 1 indicates True, and 0 indicates False:" << endl;
  /* demonstrate makes_more_than for Employee objects */
  Employee miranda("Miranda", 25000); // Employee object
  Employee audrey("Audrey", 40000); // Employee object

  cout << audrey.makes_more_than(miranda) << endl; // compare two Employee objects
  cout << miranda.makes_more_than(audrey) << endl; // compare oppositely

  Employee* gabe = new Employee("Gade", 5000); // pointer to an Employee object
  Employee* brian = new Employee("Brian", 4999); // pointer to another Employee object

  cout << gabe->makes_more_than(brian) << endl; // compare function on the pointers to objects
  cout << brian->makes_more_than(miranda) << endl; // compare with object and pointer to object
  cout << audrey.makes_more_than(gabe) << endl; // compare with object and pointer to object

  Supervisor* jake = new Supervisor("Jake", 1000, "Contracting", 10);
  HighLevelSupervisor* maddy = new HighLevelSupervisor("Maddy", 7000, "Audio", 5);
  
  cout << jake->makes_more_than(maddy) << endl; // supervisor & highlevelsupervisor comparison
  cout << maddy->makes_more_than(brian) << endl; // another combination
  cout << jake->makes_more_than(audrey) << endl; // yet another combination
  

  return 0; /* successful termination */
} /* end function main */
Esempio n. 14
0
int main()
{
	Student tempStudent;
	Employee tempEmployee;
	ifstream fin;
	fin.open("persons");
	char tempChar;
	char* tempWord = new char[50];
	int tempInt = -1;
	int* tempArrInt = new int[10];
	double tempDbl = -1.0;
	for(int i = 0; i < 13; i++)
	{
		fin >> tempChar;
		switch (tempChar)
		{
			case 's':
				fin.get();
				fin.getline(tempWord, 51, ':');
				tempStudent.setFirstName(tempWord);
				fin.getline(tempWord, 51, ':');
				tempStudent.setLastName(tempWord);
				fin >> tempInt;
				tempStudent.setAge(tempInt);
				fin.get();
				for(int j = 0; j < 9; j++)
				{
					fin >> tempChar;
					tempArrInt[j] = tempChar - '0';
				}
				tempStudent.setSSN(tempArrInt);
				fin.get();
				for(int j = 0; j < 10; j++)
				{
					fin >> tempChar;
					tempArrInt[j] = tempChar - '0';
				}
				tempStudent.setNsheNumber(tempArrInt);
				fin.get();
				fin.get(tempWord, 51, ':');
				tempStudent.setMajor(tempWord);
				fin.get();
				fin >> tempDbl;
				tempStudent.setGpa(tempDbl);
				tempStudent.print();
				break;
			case 'e':
				fin.get();
				fin.getline(tempWord, 51, ':');
				tempEmployee.setFirstName(tempWord);
				fin.getline(tempWord, 51, ':');
				tempEmployee.setLastName(tempWord);
				fin >> tempInt;
				tempEmployee.setAge(tempInt);
				fin.get();
				for(int j = 0; j < 9; j++)
				{
					fin >> tempChar;
					tempArrInt[j] = tempChar - '0';
				}
				tempEmployee.setSSN(tempArrInt);
				fin.get();
				for(int j = 0; j < 5; j++)
				{
					fin >> tempChar;
					tempArrInt[j] = tempChar - '0';
				}
				tempEmployee.setEmployeeNumber(tempArrInt);
				fin.get();
				fin.get(tempWord, 51, ':');
				tempEmployee.setTitle(tempWord);
				fin.get();
				fin >> tempInt;
				tempEmployee.setSalary(tempInt);
				tempEmployee.print();
				break;
		}
		cout << endl;
	}
	return 0;
}