void Dialog::on_savePushButton_clicked()
{
    QString nickName = ui->nickNameLineEdit->text();
    QString firstName = ui->firstNameLineEdit->text();
    QString lastName = ui->lastNameLineEdit->text();
    QString phoneNumber = ui->phoneNumberLineEdit->text();
    QString email = ui->emailLineEdit->text();

    Person person( nickName, firstName, lastName,
                   phoneNumber, email );

    try {
        m_database.savePerson( person );
    } catch ( const LogicError &e ) {
        QString errorText( e.what() );
        QMessageBox::information( this, tr( "Error" ), errorText );
    } catch ( const FileError &e ) {
        QString errorText( e.what() );
        QMessageBox::information( this, tr( "Error" ), errorText );
    } catch( ... ) {
        QString errorText( "Unknown expection" );
        QMessageBox::information( this, tr( "Error" ), errorText );
    }
}
Example #2
0
void StudentList::append(int number,std::string maleOrFemale,std::string name){
    Student person(number,maleOrFemale,name);
    students.push_back(person);
}
Example #3
0
void OverLoad()
{
	Person person(NULL);
}
Example #4
0
File: main.cpp Project: CCJY/coliru
int main()
{    
    Person person(PersonId("1"), FirstName("John"), LastName("Smith"), Address("Sea"), Birthday("Easter"), Children({PersonId("2"), PersonId("3")}));
    std::cout << "Person: " << person << std::endl;
    std::cout << ss.str() << std::endl;
}
		void IfcAlignmentModel::initIfcModel()
		{
			clearIfcModel();

			shared_ptr<IfcProject> project( new IfcProject( 1 ) );
			insertEntity(project);

			shared_ptr<IfcPerson> person( new IfcPerson() );
			person->m_FamilyName = shared_ptr<IfcLabel>( new IfcLabel( "FamilyName" ) );
			person->m_GivenName = shared_ptr<IfcLabel>( new IfcLabel( "GivenName" ) );
			insertEntity(person);

			shared_ptr<IfcOrganization> org( new IfcOrganization() );
			org->m_Name = shared_ptr<IfcLabel>(new IfcLabel( "OrganizationName" ));
			insertEntity(org);

			shared_ptr<IfcPersonAndOrganization> person_org( new IfcPersonAndOrganization() );
			person_org->m_ThePerson = person;
			person_org->m_TheOrganization = org;
			insertEntity(person_org);

			shared_ptr<IfcApplication> app( new IfcApplication() );
			app->m_ApplicationDeveloper = org;
			app->m_Version = shared_ptr<IfcLabel>( new IfcLabel( "1.0" ) );
			app->m_ApplicationFullName = shared_ptr<IfcLabel>( new IfcLabel( "IfcAlignment" ) );
			app->m_ApplicationIdentifier = shared_ptr<IfcIdentifier>( new IfcIdentifier( "IfcAlignment" ) );
			insertEntity(app);


			shared_ptr<IfcCartesianPoint> point( new IfcCartesianPoint() );
			point->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>( new IfcLengthMeasure( 0.0 ) ) );
			point->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>( new IfcLengthMeasure( 0.0 ) ) );
			point->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>( new IfcLengthMeasure( 0.0 ) ) );
			insertEntity(point);

			shared_ptr<IfcAxis2Placement3D> axis_placement( new IfcAxis2Placement3D() );
			axis_placement->m_Location = point;
			insertEntity(axis_placement);

			shared_ptr<IfcOwnerHistory> owner_history ( new IfcOwnerHistory() );
			owner_history->m_OwningUser = person_org;
			owner_history->m_OwningApplication = app;
			owner_history->m_ChangeAction = shared_ptr<IfcChangeActionEnum>( new IfcChangeActionEnum( IfcChangeActionEnum::ENUM_ADDED ) );
			insertEntity(owner_history);

			shared_ptr<IfcDimensionalExponents> dim_exp( new IfcDimensionalExponents() );
			dim_exp->m_LengthExponent = 0;
			dim_exp->m_MassExponent = 0;
			dim_exp->m_TimeExponent = 0;
			dim_exp->m_ElectricCurrentExponent = 0;
			dim_exp->m_ThermodynamicTemperatureExponent = 0;
			dim_exp->m_AmountOfSubstanceExponent = 0;
			dim_exp->m_LuminousIntensityExponent = 0;
			insertEntity(dim_exp);

			// length unit [m]
			shared_ptr<IfcSIUnit> si_unit( new IfcSIUnit() );
			si_unit->m_UnitType = shared_ptr<IfcUnitEnum>( new IfcUnitEnum( IfcUnitEnum::ENUM_LENGTHUNIT ) );
			si_unit->m_Name = shared_ptr<IfcSIUnitName>( new IfcSIUnitName( IfcSIUnitName::ENUM_METRE ) );
			insertEntity(si_unit);

			// plane unit [rad]
			shared_ptr<IfcSIUnit> plane_angle_unit( new IfcSIUnit() );
			plane_angle_unit->m_UnitType = shared_ptr<IfcUnitEnum>( new IfcUnitEnum( IfcUnitEnum::ENUM_PLANEANGLEUNIT ) );
			plane_angle_unit->m_Name = shared_ptr<IfcSIUnitName>( new IfcSIUnitName( IfcSIUnitName::ENUM_RADIAN ) );
			insertEntity(plane_angle_unit);

			// assign units
			shared_ptr<IfcUnitAssignment> unit_assignment( new IfcUnitAssignment() );
			unit_assignment->m_Units.push_back( si_unit );
			unit_assignment->m_Units.push_back( plane_angle_unit );
			insertEntity(unit_assignment);


			project->m_GlobalId = shared_ptr<IfcGloballyUniqueId>(new IfcGloballyUniqueId( CreateCompressedGuidString22() ) );
			project->m_OwnerHistory = owner_history;
			project->m_Name = shared_ptr<IfcLabel>(new IfcLabel( "IfcAlignment project" ) );
			project->m_UnitsInContext = unit_assignment;

			// set up world coordinate system
			shared_ptr<IfcDirection> axis( new IfcDirection() );
			insertEntity(axis);
//             axis->m_DirectionRatios.push_back( 0.0 );
//             axis->m_DirectionRatios.push_back( 0.0 );
//             axis->m_DirectionRatios.push_back( 1.0 );
		
			shared_ptr<IfcDirection> ref_direction( new IfcDirection() );
			insertEntity(ref_direction);
//             ref_direction->m_DirectionRatios.push_back( 0.0 );
//             ref_direction->m_DirectionRatios.push_back( 0.0 );
//             ref_direction->m_DirectionRatios.push_back( 1.0 );

			shared_ptr<IfcCartesianPoint> location( new IfcCartesianPoint() );
			insertEntity(location);
			location->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>(new IfcLengthMeasure(0.0) ) );
			location->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>(new IfcLengthMeasure(0.0) ) );
			location->m_Coordinates.push_back( shared_ptr<IfcLengthMeasure>(new IfcLengthMeasure(0.0) ) );

			shared_ptr<IfcAxis2Placement3D> world_coordinate_system( new IfcAxis2Placement3D() );
			insertEntity(world_coordinate_system);
			world_coordinate_system->m_Location = location;
			world_coordinate_system->m_Axis = axis;
			world_coordinate_system->m_RefDirection = ref_direction;

			// 3d representation context
			shared_ptr<IfcGeometricRepresentationContext> geom_context( new IfcGeometricRepresentationContext() );
			insertEntity(geom_context);
			geom_context->m_CoordinateSpaceDimension = shared_ptr<IfcDimensionCount>(new IfcDimensionCount( 3 ) );
			geom_context->m_WorldCoordinateSystem = world_coordinate_system;

			updateCache();
		}
TEST(AttackCharacterTest, MagesTakeMostPhysicalDamageAndHasLeastStartingHP){
	Character person(MAGE);
	EXPECT_EQ(MAGE_HP, person.getRemainingHP());
	attackAndCheckHP(&person, MAGE_HP - 50);
}
TEST(AttackCharacterTest, WarriorsTakeEvenMoreReducedDamageAndHaveHighHP){
	Character person(WARRIOR);
	EXPECT_EQ(WARRIOR_HP, person.getRemainingHP());
	attackAndCheckHP(&person, WARRIOR_HP - 30);
}
TEST(AttackCharacterTest, RoguesTakeReducedDamageAndHaveMediumHP){
	Character person(ROGUE);
	EXPECT_EQ(ROGUE_HP, person.getRemainingHP());
	attackAndCheckHP(&person, ROGUE_HP - 40);
}
Example #9
0
static void passenger_box(double x,double y,double z,
                          double dx,double dy,double dz,
                          double th)
{
    //  Set specular color to white
    float white[] = {1,1,1,1};
    float Emission[]  = {0.0,0.0,0.01*emission,1.0};
    glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shinyvec);
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,Emission);
    //  Save transformation
    glPushMatrix();
    //  Offset
    glTranslated(x,y,z);
    glRotated(th,0,1,0);
    glScaled(dx,dy,dz);
    person(0, +1.5, 0, 0.5, 0.5);
    // Textures
    //glEnable(GL_TEXTURE_2D);
    //glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    //glColor3f(1,1,1);
    //glBindTexture(GL_TEXTURE_2D,texture[0]);
    //  passenger_box
    // ball(0, +1.5, 0, 0.5);
    //  Front
    // glBindTexture(GL_TEXTURE_2D,texture[0]);
    glBegin(GL_QUADS);
    glNormal3f( 0, 0, 1);
    glTexCoord2f(0,0); glVertex3f(-1,-1, 1);
    glTexCoord2f(1,0); glVertex3f(+1,-1, 1);
    glTexCoord2f(1,1); glVertex3f(+1,+1, 1);
    glTexCoord2f(0,1); glVertex3f(-1,+1, 1);
    glEnd();
    //  Back
    // glBindTexture(GL_TEXTURE_2D,texture[0]);
    glBegin(GL_QUADS);
    glNormal3f( 0, 0,-1);
    glTexCoord2f(0,0); glVertex3f(+1,-1,-1);
    glTexCoord2f(1,0); glVertex3f(-1,-1,-1);
    glTexCoord2f(1,1); glVertex3f(-1,+1,-1);
    glTexCoord2f(0,1); glVertex3f(+1,+1,-1);
    glEnd();
    //  Right
    // glBindTexture(GL_TEXTURE_2D,texture[0]);
    glBegin(GL_QUADS);
    glNormal3f(+1, 0, 0);
    glTexCoord2f(0,0); glVertex3f(+1,-1,+1);
    glTexCoord2f(1,0); glVertex3f(+1,-1,-1);
    glTexCoord2f(1,1); glVertex3f(+1,+1,-1);
    glTexCoord2f(0,1); glVertex3f(+1,+1,+1);
    glEnd();
    //  Left
    // glBindTexture(GL_TEXTURE_2D,texture[0]);
    glBegin(GL_QUADS);
    glNormal3f(-1, 0, 0);
    glTexCoord2f(0,0); glVertex3f(-1,-1,-1);
    glTexCoord2f(1,0); glVertex3f(-1,-1,+1);
    glTexCoord2f(1,1); glVertex3f(-1,+1,+1);
    glTexCoord2f(0,1); glVertex3f(-1,+1,-1);
    glEnd();
    //  Bottom
    // glBindTexture(GL_TEXTURE_2D,texture[0]);
    glBegin(GL_QUADS);
    glNormal3f( 0,-one, 0);
    glTexCoord2f(0,0); glVertex3f(-1,-1,-1);
    glTexCoord2f(1,0); glVertex3f(+1,-1,-1);
    glTexCoord2f(1,1); glVertex3f(+1,-1,+1);
    glTexCoord2f(0,1); glVertex3f(-1,-1,+1);
    glEnd();
    //  End
    //  Undo transofrmations
    glPopMatrix();
    glDisable(GL_TEXTURE_2D);
}
Example #10
0
char *emote_processor( CHAR_DATA *ch, char *argument, bool fPemote, bool fSemote,
  CHAR_DATA *vch )
{
  static char buf[MAX_STRING_LENGTH];
  CHAR_DATA *wch;
  OBJ_DATA *obj;
  bool fBegin = TRUE, fPoss = FALSE;
  char word[MAX_INPUT_LENGTH];
  char *pin = argument;

  for ( pin = argument; *pin != '\0'; pin++ ) {
    if ( *pin == '@' ) {
	fBegin = FALSE;
	break;
    }
  }

  pin = argument;
  buf[0] = '\0';

  /* If no @, copy emoter's short desc. */
  if (fBegin) {
    //    if (vch == ch) {
    //      strcat(buf, (fPemote ? "your" : "you"));
    //    } else {
      strcpy(buf, person(vch, ch));
      if ( fPemote ) {
	if ( buf[strlen(buf)-1] == 's' )
	  strcat( buf, "'" );
	else
	  strcat( buf, "'s" );
	//      }
	//    }
      }  
      strcat( buf, " " );
  }

  while ( *pin != '\0' ) {
    fPoss = FALSE;
    switch( *pin ) {
    default:
      one_emote_argument( pin, word );
      strcat( buf, word );
      pin = pin + (strlen( word ) - 1);
      break;
      
    case ' ':
      strcat( buf, " " );
      break;
      
    case '@':
      if (vch == ch) {
	strcat(buf, (fPemote ? "your" : "you"));
      } else {
	strcat(buf, person(vch, ch));
	if ( fPemote )
	  strcat( buf, (buf[strlen(buf)-1] == 's') ? "'" : "'s");
      }
      break;
      
    case '%':
      fPoss = TRUE;
    case '~':
      one_emote_argument( &pin[1], word );	      
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
	if (can_see_obj(vch, obj)) {
	  strcat( buf, obj->short_descr );
	  if ( fPoss ) {
	    if ( word[strlen(word) - 1] == 's' )
	      strcat( buf, "'" );
	    else
	      strcat( buf, "'s" );
	  }
	} else
	  strcat( buf, (fPoss ? "something's" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
	if (fSemote) 
	  wch->leader = ch;
	if (vch == wch) {
	  strcat(buf, (fPoss ? "your" : "you"));
	} else {
	  strcat(buf, person(vch, wch));
	  if (fPoss) {
	    if ( buf[strlen(buf)-1] == 's' )
	      strcat( buf, "'" );
	    else
	      strcat( buf, "'s" );
	  }
	}
      } else {
	sprintf( buf, "%s is not here.\n\r", word );
	send_to_char( buf, ch );
	return NULL;
      }
      
      pin = pin + strlen( word );
      fPoss = FALSE;
      break;
      
      /* %m  him/her */
    case '!':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
	strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
	if (fSemote)
	  wch->leader = ch;
	strcat(buf, ((vch == wch) ? "you" : him_her[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }

      pin = pin + strlen( word );
      break;
	
	/* %s  his/her */
    case '^':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
        strcat(buf, ((can_see_obj(vch, obj)) ? "its" : "something's"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
        if (fSemote)
          wch->leader = ch;
        strcat(buf, ((vch == wch) ? "your" : his_her[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }

      pin = pin + strlen( word );
      break;
      
      /* %s  he/she */
    case '#':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
        strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
        if (fSemote)
          wch->leader = ch;
        strcat(buf, ((vch == wch) ? "you" : he_she[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }
      
      pin = pin + strlen( word );
      break;
    }
    
    pin++;
  }

  strcat( strip_punct(buf), ".\n\r" );
  buf[0] = UPPER( buf[0] );
  return buf;
}
Example #11
0
#include "divida_tests.h"

#include <divida/beneficiary.h>
#include <divida/date.h>
#include <divida/expense.h>
#include <divida/group.h>
#include <divida/item.h>
#include <divida/person.h>
#include <divida/report.h>

TEST_CASE("Integration Test", "[integration]")
{
	auto group = divida::group("Camping Friends");

	auto arav = group.person("Arav Jindal");
	auto marco = group.person("Marco Sanchez");
	auto grace = group.person("Grace Yun");
	auto maggie = group.person("Maggie McDonald");

	divida::expense expenseFood{ "Food", divida::date::create(12, 7, 2009), grace };
	expenseFood.add_items(
		{ { "Apples", 4.67f },
		{ "Hot dogs", 8.55f },
		{ "Hot dog buns", 4.36f },
		{ "Beans", 3.79f },
		{ "Trail mix", 9.82f },
		{ "Potato chips", 5.03f } },
		{ divida::beneficiary{ arav }, divida::beneficiary{ marco }, divida::beneficiary{ grace }, divida::beneficiary{ maggie } }
	);

	divida::expense expenseCampsites{ "Campsites", divida::date::create(13, 7, 2009), arav };
Example #12
0
const QByteArray Profile::id() const
{
    return person()->uid();
}
int main(int argc, char** argv) {

	//////////////////////////////////////////////////////////////////////////////////////////////
	// Slide 9 - 11
	{
		int myvar = 25;					// create variable with value 25 (gets address 1776)
		int* foo  = &myvar;				// store address 1776 in a pointer
		int bar	  = myvar;				// copy value 25 to another parameter bar
		int& baz  = *foo;				// dereferencing = getting the value from the pointer: baz is equal to the value (25) pointed to by foo (at address 1776)
		int  baz2 = *foo;				// dereferencing and copying into
	}
	
	{
		int a(1);						// on the stack
		int b		= 2;				// on the stack
		int *p_c	= new int;			// p_c is assigned 4 bytes in the heap
		*p_c		= 3;				// p_c is pointing at 3
		int *array	= new int[10];		// array is assigned 40 bytes in the heap
		array[0] = a;
		array[1] = b;
		array[2] = *p_c;				// the value that the pointer is pointing to is copied to the first element of the array

		delete p_c;
		delete[] array;
	}

	//////////////////////////////////////////////////////////////////////////////////////////////
	/// add breakpoints : constructor, copy-constructor and destructor
	/// slide 11
	{
		Person person("Frank");			// on the stack
		Person clone(person);			// copy constructor
		Person& clone_ref = clone;		// creating a reference to the clone
		Person clone_again = clone;		// call copy constructor again

		Donation donation(person, 100);	// on the stack
	} // both person and donation's destructors are called


	//////////////////////////////////////////////////////////////////////////////////////////////
	/// slide 12
	{
		Person frank("Frank");							// on the stack
		Person* p_willy = new Person("Willy");   		// on the heap
		std::cout << frank.GetName() << std::endl;
		std::cout << p_willy->GetName() << std::endl << std::endl;

		Donation donation(*p_willy, 100);								// on the stack
		Donation* p_donation = new Donation(donation);					// create pointer on the heap and call the copy-constructor;
		p_donation->SetAmount(200);										// pass by value
		std::unique_ptr<Donation> up_donation(new Donation(donation));	// up_donation is on the stack, the new donation is on the heap, but will be automatically destructed when up_donation is out of scope
		up_donation->SetAmount(300);									// pass by value

		const Donation& donation_const_ref = donation;					// holding a const reference will prevent us from modifying it

		std::cout << donation << std::endl;
		std::cout << *p_donation << std::endl;
		std::cout << *up_donation << std::endl;

		delete p_donation;		// if not here : memory leak
		delete p_willy;			// idem
	}

	system("pause");
	return 0;
}