Ejemplo n.º 1
0
int main()
{
	MyString object1("This"), object2("is");
	MyString object3("a test.");
	MyString object4 = object1;
	MyString object5("is only a test");
	char string1[] = "a test.";

	std::cout << "Object1: " << object1 << std::endl;
	std::cout << "Object2: " << object2 << std::endl;
	std::cout << "Object3: " << object3 << std::endl;
	std::cout << "Object4: " << object4 << std::endl;
	std::cout << "Object5: " << object5<< std::endl;
	std::cout << "String 1:" << string1 << std::endl;
	object1 += " ";
	object1 +=object2;
	object1 += " ";
	object1 += object3;
	object1 += " ";
	object1 += object4;
	object1 += " ";
	object1 += object5;
	object1 += " ";
	std::cout << "object1: " << object1 << std::endl;

   return 0;
}
Ejemplo n.º 2
0
int main()
{
   // Define and initialize several MyString objects.
   MyString object1("This"), object2("is");
   MyString object3("a test.");
   MyString object4 = object1;  
   MyString object5("is only a test.");
   // Define a C-string.
   char string1[] = "a test.";

   // Display the MyString objects.
   cout << "object1: " << object1 << endl;
   cout << "object2: " << object2 << endl;
   cout << "object3: " << object3 << endl;
   cout << "object4: " << object4 << endl;
   cout << "object5: " << object5 << endl;

   // Display the C-string.
   cout << "string1: " << string1 << endl;

   // Test the overloaded += operator.
   object1 += " ";
   object1 += object2;
   object1 += " ";
   object1 += object3;
   object1 += " ";
   object1 += object4;
   object1 += " ";
   object1 += object5;
   cout << "object1: " << object1 << endl;

   return 0;
}
Ejemplo n.º 3
0
bool pair_test( )
{
  std::pair< int, char > object1( 1, 'H' );
  std::pair< int, char > object2( 0, 'H' );
  std::pair< int, char > object3( 1, 'G' );

  // Does std::make_pair do something reasonable?
  if( !( object1 == std::make_pair( 1, 'H' ) ) ) FAIL;

  // Verify std::pair's relational operators.
  if( !( object1 == object1 ) ) FAIL;
  if(  ( object1 == object2 ) ) FAIL;
  if(  ( object1 == object3 ) ) FAIL;
  if( !( object2 <  object1 ) ) FAIL;
  if( !( object3 <  object1 ) ) FAIL;
  if( !( object2 <  object3 ) ) FAIL;

  // Make sure the other relational operators can be instantiated properly.
  if( !( object1 != object2 ) ) FAIL;
  if( !( object1 >  object2 ) ) FAIL;
  if(  ( object1 <= object2 ) ) FAIL;
  if( !( object1 >= object2 ) ) FAIL;

  // This sort of thing comes up when map's value_type is used.
  std::pair< const int, int > object( std::make_pair( 1, 2 ) );
  if( !( object.first == 1 ) || !( object.second == 2 ) ) FAIL;

  return true;
}
Ejemplo n.º 4
0
TEST(collideWorld, box2box)
{
	Vector3 p1(1.0f, -1.0f, 1.0f);
	Vector3 p2(-1.01f, 1.01f, -1.01f);
	Vector3 p3(-1.0f, 1.0f, -1.0f);
	Vector3 p4(-3.0f, 3.0f, -3.0f);
	AABB aabb1(p1, p2);
	AABB aabb2(p3, p4);
	CollidableObject object1(&aabb1, p1, 0);
	CollidableObject object2(&aabb2, p1, 1);
	Collide collide;

	collide.collision(&object1, &object2);

	EXPECT_TRUE(collide.getCollide());
/**
	CollisionWorld world;
	world.addObject(object1);
	world.addObject(object2);
	world.computeCollision();

	printf("# of objects: %d\n", world.getObjectSize());
	printf("# of collides: %d\n", world.getCollideSize());
*/
}
Ejemplo n.º 5
0
Port & Port::operator-=(int b) // subtracts b from bottles, if available
{
    n_bottles -= b;
    Port* p;
    p = new Port;
    Port object1(n_brand, n_style, n_bottles);
    *p = object1;
    delete p;
    return *p;
}
Ejemplo n.º 6
0
Port & Port::operator+=(int b) // adds b to bottles
{
    n_bottles += b;
    Port* p;
    p = new Port;
    Port object1(n_brand, n_style, n_bottles);
    *p = object1;
    delete p;
    return *p;
}
Ejemplo n.º 7
0
    void test_normal()
    {
        A* a_obj = new A();
        int member = a_obj->getMember();
        cSmartPtr<A> object2(a_obj, SMARTPTR_DESTRUCT_DELETE);
        cSmartPtr<A> object1(object2);

        TESTS_ASSERT_EQUAL(member, object2->getMember());
        TESTS_ASSERT_EQUAL(member, object1->getMember());

        A* obj1 = object1;
        A* obj2 = object2;
        TESTS_ASSERT_EQUAL(obj1, obj2);
    };
Ejemplo n.º 8
0
int main()
{
	simpleObject	object1(100,100,100);
	simpleObject	object2(50, 50, 50);

	display_object_info( "object1", object1 );
	display_object_info( "object2", object2 );

	printf("moving object2 by -20,10,0...\n");
	object2.translate( -20, 10, 0 );

	display_object_info( "object2", object2 );

	return 0;		
}
Ejemplo n.º 9
0
int main(int argc, const char* argv[])
{
    /* Get x translation from commandline */
    if (argc == 2) {
        user_x_translate = atoi( argv[1] );
    }

    dpoint          point1(100, 100, 100);
    dpoint          point2(50, 50, 50);
    simpleObject    object1("object_1", point1);
    simpleObject    object2("object_2", point2, 10, 10);

    /* Use the new function display_info() to output object information */
    object1.display_info( stdout );
    object2.display_info( stdout );

    printf("\nChecking if objects are equal...\n");

    /* check if these objects occupy the same location */
    printf("object1 & object2 %s occupy the same place...\n",
        (object1 == object2)?"DO":"DO NOT");
        
    printf("moving object2 by 50,50,50...\n");
    object2.translate( 50, 50, 50 );

    object2.display_info( stdout, "object2" );
    /* check if these objects occupy the same location */
    printf("object1 & object2 %s occupy the same place...\n",
        (object1 == object2)?"DO":"DO NOT");
    
    printf("\n");
    
    /* Test the new complexObject class */
    complexObject    object3( "object_3", 20, -10, 30, 15, 15, 8, 0.5 );
    object3.display_info( stdout );
    
    /* Attempt to move it out of range!!! */
    
    printf("Translating object3 by %d, 0, 0...\n", user_x_translate);
    if (!object3.translate( user_x_translate, 0, 0 )) {
        printf("Unable to move object3 by %d, 0, 0!\n", user_x_translate);
    }
    
    object3.display_info( stdout );
    
    return 0;        
}
Ejemplo n.º 10
0
TEST(collideWorld, ray2sphere)
{
	Vector3 p1(0.0f, 0.0f, 0.0f);
	Vector3 p2(0.0f, 4.0f, 0.0f);
	Vector3 vecDir(0.0f, 2.0f, 0.0f);
	float r = 2.0f;
	Sphere sphere(p2, r);
	Ray ray(p1, vecDir);
	CollidableObject object1(&ray, p1, 0);
	CollidableObject object2(&sphere, p1, 1);
/*
	CollisionWorld world;
	world.addObject(object1);
	world.addObject(object2);
	world.computeCollision();

	printf("# of objects: %d\n", world.getObjectSize());
	printf("# of collides: %d\n", world.getCollideSize());
	*/
}
Ejemplo n.º 11
0
TEST(collideWorld, sphere2sphere)
{
	Vector3 p1(0.0f, 0.0f, 0.0f);
	Vector3 p2(1.0f, 0.0f, 0.0f);
	float r1 = 0.5f;
	float r2 = 0.51f;
	Sphere sphere1(p1, r1);
	Sphere sphere2(p2, r2);
	CollidableObject object1(&sphere1, p1, 0);
	CollidableObject object2(&sphere2, p1, 1);
	Collide collide;
/**
	CollisionWorld world;
	world.addObject(object1);
	world.addObject(object2);
	world.computeCollision();

	printf("# of objects: %d\n", world.getObjectSize());
	printf("# of collides: %d\n", world.getCollideSize());
*/
}
Ejemplo n.º 12
0
OscFixedODE::~OscFixedODE()
{
    ODEConstraint *c = static_cast<ODEConstraint*>(special());
    if (!object2())
        static_cast<ODEObject*>(object1()->special())->connectBody();
}
Ejemplo n.º 13
0
    void testSerialization ()
    {
        testcase ("serialization");

        unexpected (sfGeneric.isUseful (), "sfGeneric must not be useful");

        SField const& sfTestVL = SField::getField (STI_VL, 255);
        SField const& sfTestH256 = SField::getField (STI_HASH256, 255);
        SField const& sfTestU32 = SField::getField (STI_UINT32, 255);
        SField const& sfTestObject = SField::getField (STI_OBJECT, 255);

        SOTemplate elements;
        elements.push_back (SOElement (sfFlags, SOE_REQUIRED));
        elements.push_back (SOElement (sfTestVL, SOE_REQUIRED));
        elements.push_back (SOElement (sfTestH256, SOE_OPTIONAL));
        elements.push_back (SOElement (sfTestU32, SOE_REQUIRED));

        STObject object1 (elements, sfTestObject);
        STObject object2 (object1);

        unexpected (object1.getSerializer () != object2.getSerializer (),
            "STObject error 1");

        unexpected (object1.isFieldPresent (sfTestH256) ||
            !object1.isFieldPresent (sfTestVL), "STObject error");

        object1.makeFieldPresent (sfTestH256);

        unexpected (!object1.isFieldPresent (sfTestH256), "STObject Error 2");

        unexpected (object1.getFieldH256 (sfTestH256) != uint256 (),
            "STObject error 3");

        if (object1.getSerializer () == object2.getSerializer ())
        {
            WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0);
            WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
            fail ("STObject error 4");
        }
        else
        {
            pass ();
        }

        object1.makeFieldAbsent (sfTestH256);

        unexpected (object1.isFieldPresent (sfTestH256), "STObject error 5");

        unexpected (object1.getFlags () != 0, "STObject error 6");

        unexpected (object1.getSerializer () != object2.getSerializer (),
            "STObject error 7");

        STObject copy (object1);

        unexpected (object1.isFieldPresent (sfTestH256), "STObject error 8");

        unexpected (copy.isFieldPresent (sfTestH256), "STObject error 9");

        unexpected (object1.getSerializer () != copy.getSerializer (),
            "STObject error 10");

        copy.setFieldU32 (sfTestU32, 1);

        unexpected (object1.getSerializer () == copy.getSerializer (),
            "STObject error 11");

        for (int i = 0; i < 1000; i++)
        {
            Blob j (i, 2);

            object1.setFieldVL (sfTestVL, j);

            Serializer s;
            object1.add (s);
            SerialIter it (s.slice());

            STObject object3 (elements, it, sfTestObject);

            unexpected (object1.getFieldVL (sfTestVL) != j, "STObject error");

            unexpected (object3.getFieldVL (sfTestVL) != j, "STObject error");
        }
    }
Ejemplo n.º 14
0
void class13Driver(){
    
    int id;
    int price;
    string category;
    string brand;
    int quantity;
    string style;
    string color;
    string material;
    string country;
    string clothsize;
    string clothtype;
    
    cout<<"Enter product ID : ";
    cin>>id;
    cout<<"Enter product price : ";
    cin>>price;
    cin.ignore(1000,'\n');
    cout<<"Enter product category(Mens,Womens,Kids) : ";
    getline(cin,category);
    cout<<"Enter product brand name : ";
    getline(cin,brand);
    cout<<"Enter product quantity : ";
    cin>>quantity;
    
    cout<<endl;
    cout<<"-------------- Default output---------------\n";
    Product object1(id,price,category,brand,quantity);
    object1.print();

    cout<<endl;
    cout<<"-------------- Cloth ---------------\n";
    
    cout<<"Enter product ID : ";
    cin>>id;
    cout<<"Enter product price : ";
    cin>>price;
    cin.ignore(1000,'\n');
    cout<<"Enter product category(Mens,Womens,Kids) : ";
    getline(cin,category);
    cout<<"Enter product brand name : ";
    getline(cin,brand);
    cout<<"Enter product quantity : ";
    cin>>quantity;
    cin.ignore(1000,'\n');
    cout<<"Enter cloth size : ";
    getline(cin,clothsize);
    cout<<"Enter cloth maden country : ";
    getline(cin, country);
    cout<<"Enter cloth type : ";
    getline(cin,clothtype);
    
    cout<<endl;
    cout<<"-------------- Cloth output---------------\n";
    Cloths object2(id,price,category,brand,quantity,clothsize,country,clothtype);
    object2.showClothsList();
    
    cout<<endl;
    cout<<"-------------- Bag ---------------\n";
    
    cout<<"Enter product ID : ";
    cin>>id;
    cout<<"Enter product price : ";
    cin>>price;
    cin.ignore(1000,'\n');
    cout<<"Enter product category(Mens,Womens,Kids) : ";
    getline(cin,category);
    cout<<"Enter product brand name : ";
    getline(cin,brand);
    cout<<"Enter product quantity : ";
    cin>>quantity;
    cin.ignore(1000,'\n');
    cout<<"Enter bag style : ";
    getline(cin, style);
    cout<<"Enter bag color : ";
    getline(cin, color);
    cout<<"Enter bag material : ";
    getline(cin, material);
    
    cout<<endl;
    cout<<"-------------- Bag output---------------\n";
    
    Bag object3(id,price,category,brand,quantity,style,color,material);
    object3.showBag();
    
}