コード例 #1
0
ファイル: main.cpp プロジェクト: gawallsibya/BIT_C-CPP
void main()
{
	// 이름, 학번, 학년, 학과
	g_list.insertNode( new Employee("홍길동", 11, "1", "IT"));
	g_list.insertNode( new Employee("김길동", 11, "1", "IT"));
	g_list.insertNode(2, new Employee("고길동", 11, "1", "IT"));

//	Employee *pData = g_list.deleteNode(1);
//	cout << "삭제되는 데이터 : ";
//	pData->printdata();

	//검색
	for(int i=1; i<= g_list.length(); i++)
	{
		Node *cur = g_list.retrieveNode(i);
		Employee *pData = cur->data;
		if( strcmp(pData->getName().c_str() , "홍길동")==0)
		{
			pData->printdata();
			return;
		}		
	}
	

//	g_list.display();
}
コード例 #2
0
ファイル: EmployeeDriver.cpp プロジェクト: ashkon91/Comsc200
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;
	}
}
コード例 #3
0
int main(){
  Employee E;
  fstream file("emp.bin",ios::in|ios::out|ios::binary);
  file.seekg(0,ios::end);
  cout<<"file size is: "<<file.tellg()<<endl;
  file.seekg(0);
  for(int i=0;!file.fail();i++){
    file.read((char*)&E, sizeof(Employee));
    if(!file.fail()){
      cout<<(i+1)<<"---------------------"<<endl<<E<<endl;
    }
  }
  file.clear();
  file.seekp((ios::pos_type)(sizeof(E)*2));
  E.set("Fardood", "Soley", 1234, 12345.123);
  file.write((const char*)&E,sizeof(E));
  file.seekg(0);
  for(int i=0;!file.fail();i++){
    file.read((char*)&E, sizeof(Employee));
    if(!file.fail()){
      cout<<(i+1)<<"---------------------"<<endl<<E<<endl;
    }
  }
  return 0;
}
コード例 #4
0
ファイル: Constructors.cpp プロジェクト: jannunzi/CS1500
int main() {
	Employee alice = {"Alice", "Wonderland", -123.32f};
	alice.display();

	alice.setSalary(-125.32);
	alice.display();

	Employee bob("Bob", "Marley", 21.2);
	bob.display();

	Employee charlie("Chalie", "Garcia");
	charlie.display();

	cout << bob.getSalary() << endl;

	Employee* ptr = &alice;
	ptr = &bob;
	ptr = &charlie;

	ptr->setSalary(123.32);
	ptr->display();

	ptr = &bob;
	ptr->display();

	ptr = new Employee("Dan", "Akroid", 234.43);
	ptr->display();
	
	delete ptr;

	ptr = &alice;
	ptr->display();
}
コード例 #5
0
template <typename T> void add(vector<T*> &list)
{
    // Create a new college member
    T *collegeMember = new T();
    
    // Get their information from the user
    getCollegeMemberInfo(collegeMember);
    
    // If they are an employee, get their information too
    Employee *employee = dynamic_cast<Employee*>(collegeMember);
    if (employee)
    {
        employee->setDepartment(getNonEmptyString("Enter the department: "));
        employee->setJobTitle(getNonEmptyString("Enter the job title: "));
        employee->setSalary(getInteger("Enter the salary: ", 0));
    }
    
    // If they are a student, get their information too
    Student *student = dynamic_cast<Student*>(collegeMember);
    if (student)
    {
        student->setAcademicDepartment(getNonEmptyString("Enter the academic department: "));
        student->setMajor(getNonEmptyString("Enter the major: "));
    }
    
    // Insert the new college member into the list
    list.push_back(collegeMember);
}
コード例 #6
0
ファイル: fig13_23.cpp プロジェクト: qh997/CppLearning
void virtualViaRef(const Employee &baseClassRef)
{
	baseClassRef.print();
	cout << endl;
	SHOW(baseClassRef.earnings());
	cout << "\n" << endl;
}
コード例 #7
0
TEST(ServiceChargeTransactionTest, PayrollTest) {
	int empid = 7;
	AddHourlyEmployee ahe(empid, "Test7", "Home7", 50.00);
	ahe.Execute();

	Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid);
	EXPECT_TRUE(e != 0);
	Affiliation * af(new UnionAffiliation());
	e->SetAffilication(af);

	int memberId = 86;
	((DatabaseProxy *)getInstance())->AddUnionMember(memberId, e);

	Date date(2005, 8, 8);
	ServiceChargeTransaction sct(memberId, date, 12.95);
	sct.Execute();

	e = ((DatabaseProxy *)getInstance())->GetEmployee(empid);
	UnionAffiliation* uf = 
		dynamic_cast<UnionAffiliation*>(e->GetAffilication());
	EXPECT_TRUE(uf != 0);

	ServiceCharge sc = uf->GetServiceCharge(date);
	EXPECT_TRUE(sc.GetAmount() == 12.95);
}
コード例 #8
0
Employee::Employee(const Employee &orig)
{
    CollegeMember::copy(orig);
    this->setDepartment(orig.department());
    this->setJobTitle(orig.jobTitle());
    this->setSalary(orig.salary());
}
コード例 #9
0
void test( int argc, char* argv[] )
{
      // Create the Datastore and Manager objects
      EmployeeDatastore theEmpDatastore;
      EmployeeManager   theEmpMgr;
      Employee          theEmp;

      // Connect to database
      cout << "Connecting to " << theEmpDatastore.datastoreName() << "..." << endl;
      if ( argc >= 3 )
         theEmpDatastore.connect( argv[1], argv[2] );
      else
         theEmpDatastore.connect();
      theEmpDatastore.enableAutoCommit( false );
      cout <<"...Connected" << endl;

      // Count all Employees in Department D11
      int numEmp = theEmp.numEmpInDept( "D11" );
      cout << "Count of all Employees in Department D11: " << numEmp << endl;

      // Disconnect from the database
      theEmpDatastore.rollback();
      theEmpDatastore.disconnect();

      // All done
      cout << "Done" << endl;
}
コード例 #10
0
main()
{
  Student* s = new Student("250000000");
  Employee* e = reinterpret_cast<Employee*>(s);

  cout << e->id() << endl;;
}
コード例 #11
0
bool DataLayer::retrieveEmployees(vector<Employee*> *emp)
{
    if(connectDB())
    {
        QSqlQuery qry;
        Employee *e;
        qry.prepare("select * from employee");
        if(qry.exec())
        {
            while(qry.next())
            {
                //cout<<qry.value("CNIC").toString().toStdString()<<endl;

                    e=new Employee;

                    QString cnic=qry.value("cnic").toString();
                    QString name=qry.value("name").toString();
                    QString type=qry.value("_Type").toString();
                    int phone_no=qry.value("phone").toInt();
                    float salary=qry.value("salary").toFloat();
                    QString password=qry.value("password").toString();
                    float rate=qry.value("hourlyrate").toInt();
                    float work=qry.value("hoursworked").toFloat();

                    //cout<<name.toStdString()<<endl;
                        e->setAttributes(name,cnic,type,phone_no,salary, password,rate,work);
                        emp->push_back(e);
                    }
                }

            return true;
        }

    return false;
}
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;
}
コード例 #13
0
ファイル: Application.cpp プロジェクト: konorati/OldProjects
void Application::loadEmployees()
{
	string tmpString;
	Employee *pTemp;
	employeeList.open("EmployeeList.txt", ios::in);
	while(employeeList.good())
	{
		pTemp = new Employee();
		getline(employeeList, tmpString);
		pTemp->setName(tmpString);
		getline(employeeList, tmpString);
		pTemp->setSSNum(atoi(tmpString.c_str()));
		getline(employeeList, tmpString);
		pTemp->setWage(atof(tmpString.c_str()));
		getline(employeeList, tmpString);
		pTemp->setHoursWorked(atof(tmpString.c_str()));
		if(employeeList.good())
		{
			getline(employeeList, tmpString); //Get rid of blank line
		}
		employees.push_back(*pTemp);
		managers.begin()->employees.push_back(*pTemp);
	}

	employeeList.close();
}
コード例 #14
0
int main(void) {
    // Test
    Employee e = Employee("Imed Eddine", "Nezzar", 1, 22, 0, PROGRAMMER);
    e.details();
    // code goes here
    return 0;
}
コード例 #15
0
TEST(PaydayTransactionForCommisionedEmployeeTest, PayrollTest) {
    ((DatabaseProxy *)getInstance())->ClearEmployees();

    int empid = 101;
    Date date(2012, 10, 10);
    double amount = 1000.00;

    AddCommisionEmployee ace(empid, "name02", "Home6", 1000.00, 0.5);
    ace.Execute();

    SalesReceiptTransaction srt(empid, date, amount);
    srt.Execute();

    Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid);
    PaymentClassification* pc = e->GetPaymentClassification();
    EXPECT_TRUE(pc != 0);

    CommisionClassification* cc = dynamic_cast<CommisionClassification*>(pc);
    EXPECT_TRUE(cc != 0);

    SalesReceipt receipt(cc->GetSalesReceipt(date));
    EXPECT_TRUE(receipt.GetAmount() == amount);

    Date paydate(2011, 2, 14);

    PaydayTransaction pt(paydate);
    pt.Execute();
    PayCheck *check = pt.GetPayCheck(empid);

    EXPECT_TRUE(check->GetName() == "name02");
    EXPECT_EQ(check->GetGrossPay(), 1500.00);
    EXPECT_EQ(check->GetDeductions(), 0.0);
    EXPECT_EQ(check->GetNetPay(), 1500.00);
}
コード例 #16
0
ファイル: database.cpp プロジェクト: jervisfm/ExampleCode
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;
}
コード例 #17
0
TEST(TimeCardTransactionTest, PayrollTest) {

	AddHourlyEmployee ahe(5, "Test5", "Shanghai", 100.00);
	ahe.Execute();

	Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(5);
	EXPECT_TRUE(e->GetName() == "Test5");
	EXPECT_TRUE(e->GetAddress() == "Shanghai");
	EXPECT_TRUE(e->GetEmpId() == 5);

	Date date(2010, 10, 10);

	TimeCardTransaction tct(5, date, 10);
	tct.Execute();

	e = ((DatabaseProxy *)getInstance())->GetEmployee(5);
	PaymentClassification* pc = e->GetPaymentClassification();
	EXPECT_TRUE(pc != 0);

	HourlyClassification* hc = dynamic_cast<HourlyClassification*>(pc);
	EXPECT_TRUE(hc != 0);

	TimeCard timecard(hc->GetTimeCard(date));
	EXPECT_TRUE(timecard.GetHours() == 10);	
}
コード例 #18
0
ファイル: main.cpp プロジェクト: vanyaua/OOP_cpp
int main(){

Employee emp,a,c[3];
emp.setEmployee("nameTwo",10,1);

Employee q("nameOne",5,3);

c[0].setEmployee("name0",19,50);

a=q;
cout << a.getName() << endl;

Employee *p;
p=new Employee[3];
p-> setEmployee("Imya",19,50);
cout << p->getName() << endl;

int (Employee::*omg)();
omg=&Employee::getLevel;
cout << (q.*omg)() << endl;
cout << q.getLevel() << endl;


return 0;
}
コード例 #19
0
ファイル: with_static_cast.cpp プロジェクト: Demelode/cs3307a
main()
{
  Student* s = new Student("250000000");
  Employee* e = static_cast<Employee*>(s);

  cout << e->id();
}
コード例 #20
0
int main()
{
	Employee* alice = new Employee("Alice", "Wonderland", 3211232, ENGINEERING);
	Employee* bob = new Employee("Bob", "Marley", 3211232, MARKETING);
	Employee* charlie = new Employee("Charlie", "Gargia", 3211232, MARKETING);
	Employee* dan = new Employee("Daniel", "Craig", 123123, HR);
	Employee* edward = new Employee("Edward", "Norton", 21211212, ENGINEERING);
	Employee* frank = new Employee("Frank", "Herbert", 233223, SALES);
	Employee* gregory = new Employee("Gregory", "Peck", 344334, MARKETING);

	EmployeeBinarySearchTree* tree = new EmployeeBinarySearchTree();

	tree->insert(dan);
	tree->insert(bob);
	tree->insert(alice);
	tree->insert(charlie);
	tree->insert(frank);
	tree->insert(edward);
	tree->insert(gregory);

	/*
		The tree now looks like this:

					Daniel
			Bob				Frank
		Alice		Charlie		Edward		Gregory
	*/

	cout << endl << "In Order: " << endl;
	tree->traverseInOrder();

	cout << endl << "Pre Order: " << endl;
	tree->traversePreOrder();

	cout << endl << "Post Order: " << endl;
	tree->traversePostOrder();

	cout << endl << "Depth First Search: " << endl;
	Employee* found = tree->depthFirstSearch("Bob");
	if (found != NULL)
	{
		found->display();
	}
	else
	{
		cout << "Not Found" << endl;
	}

	cout << endl << "Breadth First Search: " << endl;
	found = tree->breadthFirstSearch("Frank");
	if (found != NULL)
	{
		found->display();
	}
	else
	{
		cout << "Not Found" << endl;
	}
	getchar();
}
コード例 #21
0
ファイル: main.cpp プロジェクト: kempt09/CSC242-CSC252
Employee makesMore(Employee a, Employee b){
  if (a.getHourlyPay() > b.getHourlyPay()){
    return a;
  } else {
    return b;
  }
};
コード例 #22
0
ファイル: bin2stream4.cpp プロジェクト: FahdW/OOP344-20123
int main(){
  Employee E;
  cout<<sizeof(Employee)<<endl;
  fstream file("emp.bin",ios::out|ios::in|ios::binary);
  file.seekg((ios::off_type)0, ios::end);
  int loc = file.tellg();
  cout<<"before: "<<endl;
  while(loc > 0 ){
    loc -= sizeof(Employee);
    file.seekg((ios::pos_type)loc);
    file.read((char*)&E, sizeof(Employee));
    cout<<E<<endl;
  }
  file.seekp((ios::pos_type)sizeof(Employee)*2);
  E.set("Fardad", "Soley", 999, 99999.99);
  file.write((const char*)&E, sizeof(Employee));
  file.seekp((ios::pos_type)0);
  E.set("kang", "park", 8888, 999999.99);
  file.write((const char*)&E, sizeof(Employee));
  file.seekg((ios::off_type)0, ios::end);
  loc = file.tellg();
  cout<<"after: "<<endl;
  while(loc > 0 ){
    loc -= sizeof(Employee);
    file.seekg((ios::pos_type)loc);
    file.read((char*)&E, sizeof(Employee));
    cout<<E<<endl;
  }
  return 0;
}
コード例 #23
0
/**
 * @brief This removes an employee from the global list so that
 * he/she is no longer hireable.
 */
static void E_EmployeeDelete_f (void)
{
	/* Check syntax. */
	if (cgi->Cmd_Argc() < 2) {
		Com_Printf("Usage: %s <num>\n", cgi->Cmd_Argv(0));
		return;
	}

	/* num - menu index (line in text) */
	int num = employeeScrollPos + atoi(cgi->Cmd_Argv(1));

	Employee* employee = E_GetEmployeeByMenuIndex(num);
	/* empty slot selected */
	if (!employee)
		return;

	if (employee->isHired()) {
		if (!employee->unhire()) {
			cgi->UI_DisplayNotice(_("Could not fire employee"), 2000, "employees");
			Com_DPrintf(DEBUG_CLIENT, "Couldn't fire employee\n");
			return;
		}
	}
	E_DeleteEmployee(employee);
	cgi->Cbuf_AddText("employee_init %i\n", employeeCategory);

	num = std::max(0, num - 1);
	cgi->Cbuf_AddText("employee_select %i\n", num);
	cgi->Cbuf_AddText("hire_select %i\n", num);

	cgi->Cbuf_AddText("employee_update_count\n");
}
コード例 #24
0
ファイル: database.cpp プロジェクト: jervisfm/ExampleCode
/**
   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();
}
コード例 #25
0
ファイル: cash_reconcile.cpp プロジェクト: cwarden/quasar
void
CashReconcile::slotShiftClose()
{
    QDate date = _date->getDate();
    Id station_id = stationId();
    Id employee_id = employeeId();

    // Posting time is current time if closing for today or 11:59:59 PM
    QTime time = QTime::currentTime();
    if (date != QDate::currentDate())
	time = QTime(23, 59, 59);

    QString name;
    if (station_id != INVALID_ID) {
	Station station;
	_quasar->db()->lookup(station_id, station);
	name = station.name();
    } else if (employee_id != INVALID_ID) {
	Employee employee;
	_quasar->db()->lookup(employee_id, employee);
	name = employee.nameFL();
    } else {
	name = "<None>";
    }
    if (name.isEmpty()) name = tr("<blank>");

    QString message = "Are you sure you want to ringoff \n\"" + name + "\"";
    int choice = QMessageBox::warning(this, tr("Ringoff?"), message,
				      tr("Yes"), tr("No"));
    if (choice != 0) return;

    // Create the shift
    Shift shift;
    shift.setStoreId(_store->getId());
    shift.setStationId(station_id);
    shift.setEmployeeId(employee_id);
    shift.setPostDate(date);
    shift.setPostTime(time);
    if (!_quasar->db()->create(shift)) {
	message = tr("Failed creating shift close transaction");
	QMessageBox::critical(this, tr("Error"), message);
	return;
    }

    QApplication::setOverrideCursor(waitCursor);
    qApp->processEvents();

    bool result = _quasar->db()->shiftClose(shift);
    QApplication::restoreOverrideCursor();

    if (!result) {
	message = tr("Failed setting shift in transactions");
	QMessageBox::critical(this, tr("Error"), message);
    } else {
	message = "The shift for \"" + name + "\"\nhas been closed";
	QMessageBox::information(this, tr("Information"), message);
	slotRefresh();
    }
}
コード例 #26
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();
}
コード例 #27
0
ファイル: Persistence.cpp プロジェクト: hartenfels/Cpp101
ptree
unparse(const Employee& employee)
{
    ptree tree;
    tree.put("name",    employee.getName());
    tree.put("address", employee.getAddress());
    tree.put("salary",  employee.getSalary());
    return tree;
}
コード例 #28
0
/**
 * @brief Callback for employee_hire command
 * @note a + as parameter indicates, that more than @c maxEmployeesPerPage are possible
 * @sa CL_AssignSoldier_f
 */
static void E_EmployeeHire_f (void)
{
	/* num - menu index (line in text), button - number of button */
	int num, button;
	const char *arg;
	Employee* employee;
	base_t *base = B_GetCurrentSelectedBase();

	if (!base)
		return;

	/* Check syntax. */
	if (cgi->Cmd_Argc() < 2) {
		Com_Printf("Usage: %s <+num>\n", cgi->Cmd_Argv(0));
		return;
	}

	arg = cgi->Cmd_Argv(1);

	/* check whether this is called with the text node click function
	 * with values from 0 - #available employees (bigger values than
	 * maxEmployeesPerPage) possible ... */
	if (arg[0] == '+') {
		num = atoi(arg + 1);
		button = num - employeeScrollPos;
	/* ... or with the hire pictures that are using only values from
	 * 0 - maxEmployeesPerPage */
	} else {
		button = atoi(cgi->Cmd_Argv(1));
		num = button + employeeScrollPos;
	}

	employee = E_GetEmployeeByMenuIndex(num);
	/* empty slot selected */
	if (!employee)
		return;

	if (employee->isHired()) {
		if (!employee->unhire()) {
			Com_DPrintf(DEBUG_CLIENT, "Couldn't fire employee\n");
			cgi->UI_DisplayNotice(_("Could not fire employee"), 2000, "employees");
		} else {
			cgi->UI_ExecuteConfunc("employeehire %i", button);
		}
	} else {
		if (!E_HireEmployee(base, employee)) {
			Com_DPrintf(DEBUG_CLIENT, "Couldn't hire employee\n");
			cgi->UI_DisplayNotice(_("Could not hire employee"), 2000, "employees");
			cgi->UI_ExecuteConfunc("employeehire %i", button);
		} else {
			cgi->UI_ExecuteConfunc("employeefire %i", button);
		}
	}
	E_EmployeeSelect(employee);

	E_UpdateGUICount_f();
}
コード例 #29
0
ファイル: main.cpp プロジェクト: modyskyline/OOP_Concepts
int main()
{
	Date birth(7,1,1990,1);
	Date hire (10,1,2016,2);

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

}
コード例 #30
0
ファイル: EmployeeList.cpp プロジェクト: jayrulez/ourprs
/*Employee* EmployeeList::GetEmployee(Employee Emp)
{
    return &Emp;
}*/
void EmployeeList::ShowEmployeeList()
{
    Employee *CacheEmployee = Head;
    while(CacheEmployee!=NULL)
    {
        //CacheEmployee->ShowEmployee();
        CacheEmployee=CacheEmployee->getNext();
    }
}