Esempio n. 1
0
    /*public*/ Car* Car::copy() {
        Car* car = new Car();
       car->setBuilt(_built);
       car->setColor(_color);
       car->setLength(_length);
//       car->setLoadName(_loadName);
//       car->setReturnWhenEmptyLoadName(_rweLoadName);
       car->setNumber(_number);
       car->setOwner(_owner);
       car->setRoadName(_road);
       car->setTypeName(_type);
       car->loaded=true;
        return car;
    }
Esempio n. 2
0
bool demo::keyReleased(const OIS::KeyEvent &keyEventRef) {
  OgreFramework::getSingletonPtr()->keyReleased(keyEventRef);

  extern Car car;

  switch(keyEventRef.key){

  case OIS::KC_UP :
    car.setSpeed(.0);
    break;
    
  case OIS::KC_DOWN :
    car.setSpeed(.0);
    break;
    
  case OIS::KC_RIGHT :
    car.setSteer(0.0);
    break;
    
  case OIS::KC_LEFT :
    car.setSteer(0.0);
    break;

  case OIS::KC_SPACE :
    car.setBrake(false);
    break;

  }
	
  return true;
}
Esempio n. 3
0
Tile shortWay(const Car& self, const World& world, Tile Tile, int X, int Y)
{
	if ((world.getTilesXY()[X][Y] == EMPTY) ||  (circle(Tile, X, Y))) // Проверка на хождение по кругу и тупиковый тайл(в который нельзя въехать)
	{
		Tile.count = 100;
		return Tile;
	}

	if ((X ==self.getNextWaypointX())&& (Y== self.getNextWaypointY())) // Условие выхода из рекурсии
	{
		Tile.tileX[Tile.count] = X;
		Tile.tileY[Tile.count] = Y;
		return Tile;
	}
	   else
	        {
			Tile.count++;
			//Нужно написать для каждого вида тайла по отдельности.Вроде можно case, но выглядит как-то усрашающе:)
			return TileMinCount(shortWay(self, world, Tile, X + 1, Y), shortWay(self, world, Tile, X, Y + 1), shortWay(self, world, Tile, X, Y - 1), shortWay(self, world, Tile, X - 1, Y));

			}
}
Esempio n. 4
0
int getNextStrategy(const Car& self, const World& world, const Game& game, Move& move) {
    int currentTileIndex = self.getNextWaypointIndex();
    std::vector< std::vector<int> > currentWaypoints(4);
    for (int i = 0; i < 4; ++i) {
        currentWaypoints[i] = world.getWaypoints()[(currentTileIndex + i) % world.getWaypoints().size()];

    }

    //for (int i = 0)


    return 0;
}
Esempio n. 5
0
/**
 * Function: isLotFull()
 * Purpose: Iterates through all the nodes and checks if its the max
 * Parameters: No Pramater: NA
 * Class MemberVariable: NA
 **/
bool Parking::isLotFull()
{
    currentCar = carInFront;
    
    int totalCount = 1;
    
    while(currentCar != 0)
    {
        totalCount++;
        currentCar = currentCar->getLinkToNextCar();
    }
    
    return (totalCount > MAX_SIZE) ? true : false;
}
Esempio n. 6
0
void MyStrategy::move(const Car& self, const World& world, const Game& game, Move& move) {
    if (stuckStrategy(self,  move)) {
        return;
    }
    lastX = self.getX(), lastY = self.getY();
    //int nextStrategy = getNextStrategy(self, game);
    double nextWaypointX = (self.getNextWaypointX() + 0.5) * game.getTrackTileSize();
    double nextWaypointY = (self.getNextWaypointY() + 0.5) * game.getTrackTileSize();

    double cornerTileOffset = 0.25 * game.getTrackTileSize();

    switch (world.getTilesXY()[self.getNextWaypointX()][self.getNextWaypointY()]) {
        case LEFT_TOP_CORNER:
            nextWaypointX += cornerTileOffset;
            nextWaypointY += cornerTileOffset;
            break;
        case RIGHT_TOP_CORNER:
            nextWaypointX -= cornerTileOffset;
            nextWaypointY += cornerTileOffset;
            break;
        case LEFT_BOTTOM_CORNER:
            nextWaypointX += cornerTileOffset;
            nextWaypointY -= cornerTileOffset;
            break;
        case RIGHT_BOTTOM_CORNER:
            nextWaypointX -= cornerTileOffset;
            nextWaypointY -= cornerTileOffset;
            break;
    }

    double angleToWaypoint = self.getAngleTo(nextWaypointX, nextWaypointY);
    double speedModule = hypot(self.getSpeedX(), self.getSpeedY());

    move.setWheelTurn(angleToWaypoint * 32.0 / PI);
    move.setEnginePower(0.85);

    if (speedModule * speedModule * abs(angleToWaypoint) > 2.5 * 2.5 * PI) {
        move.setBrake(true);
    }


}
Esempio n. 7
0
void Render::drawText() {
    font.setPixelSize(24);
    QFontMetrics fmScore(font);
    Car *car = world->getCar();
    QString str;
    qglColor(Qt::red);
    str = tr("Score: %1").arg(QString::number(car->getMaxPossition(), '0', 1));
    renderText(this->width()/2 - fmScore.width(str)/2, height()/6*5, str,
               font);
    font.setPixelSize(14);
    QFontMetrics fm(font);
    int ss = 5*60 - car->getTime();
    QTime time(0, ss/60, ss%60);
    str = tr("Time: %1").arg(time.toString("m:ss"));
    renderText(width() - fm.width(str) - 5, 20, str, font);
    str = tr("Torque: %1").arg(QString::number(car->getTorque(), '0', 1));
    renderText(width() - fm.width(str) - 5, 34, str, font);
    str = tr("Speed: %1").arg(QString::number(car->getSpeed(), '0', 1));
    renderText(width() - fm.width(str) - 5, 48, str, font);
    font.setPixelSize(16);
    QFontMetrics fmGeneration(font);
    int generationNumber = world->getAlgorithm()->getGenerationNum();
    str = tr("Generation: %1").arg(QString::number(generationNumber));
    renderText(width()/2 - fmGeneration.width(str)/2, 20, str, font);
    qglColor(Qt::blue);
    if (speed == 0) {
        str = tr("[PAUSE]");
        font.setPixelSize(32);
        QFontMetrics fmPause(font);
        renderText(width()/2 - fmPause.width(str)/2, height()/2, str, font);
    } else if (speed != 2) {
        str = tr("Playback speed: %1x").arg(QString::number(speed/2.0, '0', 1));
        font.setPixelSize(14);
        renderText(width() - fm.width(str) - 5, 62, str, font);
    }
}
Esempio n. 8
0
void Goal::OnTrigger(Collider* c)
{
	if (c->GetGameObject()->GetComponent<Car>())
	{
		Car* car = c->GetGameObject()->GetComponent<Car>();
	
		if (car->InPlay())
		{	

			rb = c->GetGameObject()->GetComponent<Rigidbody>();
			
			GameObjectManager::GetInstance()->SetPoints(c->GetGameObject());

			Vector3 distance = rb->GetPosition() - this->GetGameObject()->GetComponent<Rigidbody>()->GetPosition();
			distance.Normalize();
			//rb->AddForce(distance);

			car->AddGoal(1);
			car->SetPlay(false);
			car->ReSpawn();
		
		}
	}
}
Esempio n. 9
0
void Canvas::on_startCar_clicked()
{
    if(car.tacStart()) {
        ui->startCar->setText("start");
        if (animationTimer->isActive() )
            animationTimer->stop();
        car.position = 0;
        car.position_x = input.grain_x[0];
        car.position_y = input.grain_y[0];
    }
    else {
        ui->startCar->setText("stop");
        animationTimer->start(600 - 5 * car.speed);
    }
}
Esempio n. 10
0
TEST_F(Ass3Test, Test)
{

	//Wheel testing
	EXPECT_EQ(myWheel->getDiameter(), 25);
	myWheel->setMaterial("plop");
	EXPECT_EQ(myWheel->getMaterial(), "plop");
	

	//Car Testing
	myCar->setLicensePlate("Plop");
	EXPECT_EQ(myCar->getLicensePlate(), "Plop");
	EXPECT_EQ(myCar->getNrWheels(),4);

	myCar->addWheel(1,"a");
	myCar->addWheel(2,"b");
	myCar->addWheel(25,"alu");
	EXPECT_EQ(myCar->getNrWheels(),7);

	myCar->removeWheel(4);
	EXPECT_EQ(myCar->getNrWheels(),6);

	Wheel* wheel(myCar->getWheel(5));
	EXPECT_EQ(wheel->getDiameter(),25);
	EXPECT_EQ(wheel->getMaterial(),"alu");
	
	Car *car = myCar;
	EXPECT_EQ(car->getNrWheels(),6);	

	//Truck Testing
	EXPECT_EQ(myTruck->getPower(),1000);
	Truck *truck(myTruck);
	EXPECT_EQ(truck->getPower(),1000);
	Truck *plop = truck;
	EXPECT_EQ(plop->getPower(),1000);
}
Esempio n. 11
0
    void excute()
    {
        Car *b = new CarModell();
        
        std::cout << "base model of " << b->getDescription() << " , and cost is " << b->getCost() << std::endl;
        
        //let's add some features.
        b = new Navigation(b);
        
        //set cout precision to output double type value.
        std::cout.precision(10);
        
        std::cout << b->getDescription() << " will cost you " << b->getCost() << std::endl;
        
        b = new PremiumSoundSystem(b);
        std::cout << b->getDescription() << " will cost you " << b->getCost() << std::endl;

        b = new ManualTransmission(b);
        std::cout << b->getDescription() << " will cost you " << b->getCost() << std::endl;
        
    }
Esempio n. 12
0
	void ScanBC(Car car, Road road)
	{
		if (((car.GetDirection()==false)&&(car.GetX()>MainWindowWidth/2+10))||
			((car.GetDirection()==true)&&(car.GetX()<MainWindowWidth/2-10)))
			BFlag=true;
		else 
			BFlag=false;

		if (((car.GetX()>MainWindowWidth/2)||(car.GetX()<MainWindowWidth/2))&&(!BFlag))
			CFlag=true;
	}
Esempio n. 13
0
bool IsStraight(Car const & car, std::vector<Cell> const & path, int N, Game const & game, World const & world)
{
    bool bStrait = false;
    if (path.size() >= N + 1)
    {
        double target4X = (path[N].m_x + 0.5) * game.getTrackTileSize();
        double target4Y = (path[N].m_y + 0.5) * game.getTrackTileSize();
        if (car.getAngleTo(target4X, target4Y) < 20*PI/180)
        {
            bStrait = true;
            TileType curType = GetCellType(world.getTilesXY(), GetCell(car, game));
            for (size_t i =1; i < N; ++i)
                if (curType != GetCellType(world.getTilesXY(), path[i]))
                    bStrait = false;
        }
    }
    return bStrait;
}
Esempio n. 14
0
int main()
{
	Car* Tcar = new Car(new ToyotaAbstractFactory);
	Tcar->pushAccelerator();
	std::cout << Tcar->getSpeedValue() << " km/ch" << std::endl;

	Car* Mcar = new Car(new MazdaAbstrctFactory);
	Mcar->pushAccelerator();
	std::cout << Mcar->getSpeedValue() << " km/ch" << std::endl;

	std::cin.get();
	return 0;
}
Esempio n. 15
0
void CarManager::spawn()
{
	unsigned int i;
	Car *car;

	for(i = 0; i < cars.size(); i++)
	{
		car = cars.at(i);
		if(car->getCarState() == CAR_READY && car->getCarType() != BONUS_CAR && car->getCarType() != TRUCK_CAR)
		{
			car->setSlideDirection(DIRECTION_NONE);
			car->initMe();
			//manage the positions of all the cars
			findPositionToSpawn(car);
			car->setCarState(CAR_RUNNING);
			car->setSpeed(200);
			break;
		}
	}
}
Esempio n. 16
0
void CarManager::spawnBonusCar()
{
	unsigned int i;
	Car *car;

	car = cars.at(0);
	if(car->getCarState() == CAR_READY)
	{
		car->setSlideDirection(DIRECTION_NONE);
		car->initMe();
		//manage the positions of all the cars
		findPositionToSpawn(car);
		car->setCarState(CAR_RUNNING);
		car->setSpeed(200);
	}
}
Esempio n. 17
0
void Road::advanceCars(){
  int no_of_cars = getNoOfCars();
  int speed;
  
  if(no_of_cars != 0){
    speed = (ceil((getLength())/no_of_cars));
    std::vector<Car*> cars = getCars();
    
    int i = 0, j = 0;
    if(cars.size() > 0){
      i = cars.size()-1;
      j = cars.size()-1;
    }
    
    double decreaseSpeed = 1;
    while(i >= 0){
      Car* car = cars[i];
      if(car->isFault()){
	car->decreaseFaultyTime();
	int location = car->getLocation();
	
	j = --i;
	int count = 1; // count how many cars there are in the same location with fault car.
	  
	while(((unsigned int)j < cars.size()) && ((cars[j])->getLocation()) == location){
	  Car* same_location_car = cars[j];
	  if(!same_location_car->isFault()){
	    same_location_car->setSpeed(ceil(speed*decreaseSpeed),_simulator->getMaxSpeed());
	    same_location_car->driveCar(getLength());
	  }else{
	    same_location_car->decreaseFaultyTime();
	    count++;
	  }
	  j--; 
	}
	i = j;
	decreaseSpeed *= pow(0.5,count);
      
      }else{
	car->setSpeed(ceil(speed*decreaseSpeed),_simulator->getMaxSpeed());
	car->driveCar(getLength());
	i--;
      }  
    }
  }
  std::stable_sort(getCars().begin(),getCars().end(),CompareCarByLocation());
}
Esempio n. 18
0
bool collisionCarWall(Car& car, Wall& wall, glm::mat4 carMatrix) {
    //can't collide if they are too far apart
    if (!collisionCircleCircle(car.getCenter(), carRadius, wall.getCenter(), wall.getLength()/2 + 1)) { //not very wide, and too lazy to do more percise math
        return false;
    }
    
    glm::mat4 wallMatrix = wall.getMatrix();
    
    glm::vec4 carUR = carMatrix * glm::vec4(0.5,1.0,0.0,1.0);
    glm::vec4 carLR = carMatrix * glm::vec4(0.5,-1.0,0.0,1.0);
    glm::vec4 carLL = carMatrix * glm::vec4(-0.5,-1.0,0.0,1.0);
    glm::vec4 carUL = carMatrix * glm::vec4(-0.5,1.0,0.0,1.0);
    
    glm::vec4 wallUR = wallMatrix * glm::vec4(1.0,0.2,0.0,1.0);
    glm::vec4 wallLR = wallMatrix * glm::vec4(1.0,-0.2,0.0,1.0);
    glm::vec4 wallLL = wallMatrix * glm::vec4(-1.0,-0.2,0.0,1.0);
    glm::vec4 wallUL = wallMatrix * glm::vec4(-1.0,0.2,0.0,1.0);
    
    return collisionRectSAT(carUR, carLR, carLL, carUL,
       wallUR, wallLR, wallLL, wallUL);

}
Esempio n. 19
0
void Render::drawCar() {
    Car *car = world->getCar();
    b2Body *axle, *wheel;
    for (int i = 0; i < 8; i++) {
        wheel = car->getWheel(i);
        if (wheel)
            drawBody(wheel);
        axle = car->getAxleBody(i);
        if (axle)
            drawBody(axle);
    }
    int piecesCount = car->getPiecesCount();
    for (int i = 0; i < piecesCount; i++) {
        drawBody(car->getPiece(i));
    }
    drawBody(car->getBody());
}
Esempio n. 20
0
void Garage::display()
{
	cout << "**************Details of car******************\n";
	Car display;
	for (int i=0; i < totalnoofcar; i++)
	{
		cout << "Make of car " << i+1 << "is\n";
		cout << display.get_make() <<endl;
		cout << "Model of car " << i+1 << "is\n";
		cout << display.get_car_model()<<endl;
		cout << "Registration of car " << i+1 << "is\n";
		cout << display.get_reg_no() <<endl;
		cout << "Year of car " << i+1 << "is\n";
		cout << display.get_year() <<endl;
		cout << "Colour of car " << i+1 << "is\n";
		cout << display.get_car_color() <<endl;
	}
}
Esempio n. 21
0
void CarManager::spawnTruckCar()
{
	if(getCurrentStage() == 1)
		return;

	unsigned int i;
	Car *car;

	car = cars.at(cars.size() - 1);
	if(car->getCarState() == CAR_READY)
	{
		car->setSlideDirection(DIRECTION_NONE);
		car->initMe();
		//manage the positions of all the cars
		findPositionToSpawn(car);
		car->setCarState(CAR_RUNNING);
		car->setSpeed(200);
	}
}
Esempio n. 22
0
/**
 * Function: parkNewCar()
 * Purpose: Instantiate a new car object and link the node
 * Parameters: No Pramater: NA
 * Class MemberVariable:
 *          carInFront - equivalent to headPointer
 *          currentCar - equivalent to currentPointer
 *          lastCar - equivalent to tailPointer
 *          previousToCurrentCar - equivalent to previous (holds the pointer to the one node prior to current being changed)
 **/
void Parking::parkNewCar()
{
    Car *newCarSmellyCar = getNewCar();
    
    // deal with the very first car...
    if (carInFront == 0 && previousToCurrentCar == 0 && currentCar == 0 && lastCar == 0)
    {
        carInFront = newCarSmellyCar;
        previousToCurrentCar = newCarSmellyCar;
        currentCar = newCarSmellyCar;
        currentCar->setAssignedTicketNumber(getNewTicketNumber());
        currentCar->setLinkToNextCar(0);
        lastCar = newCarSmellyCar;
        
        cout << "License Plate #: " << currentCar << " Ticket #: " << currentCar->getAssignedTicketNumber() << " PARKED" << endl;
        //DEBUG
        //currentPointerStatus();
    }
    else if (!isLotFull())
    {
        lastCar->setLinkToNextCar(newCarSmellyCar);
        previousToCurrentCar = currentCar;
        currentCar = lastCar->getLinkToNextCar();
        currentCar->setAssignedTicketNumber(getNewTicketNumber());
        lastCar = currentCar;
        
        cout << "License Plate #: " << currentCar << " Ticket #: " << currentCar->getAssignedTicketNumber() << " PARKED" << endl;
        
        //DEBUG
        //currentPointerStatus();
    }
    else
    {
        cout << "PARKING LOT IS FULL !" << endl;
    }
    
}
Esempio n. 23
0
void PlayerManager::checkCollision(vector< InteractiveObject* > &objectsonScreen)
{
	unsigned int i;
	InteractiveObject *interactiveObj;
	Car* car;
	Obstacles *obstacle;
	for(i = 0 ; i < objectsonScreen.size(); i++)
	{
		interactiveObj = objectsonScreen.at(i);
		collisionSide collSide = player->isCollidingThenFromWhere(interactiveObj);
		if(collSide && interactiveObj->getOnScreen())
		{
			lprintf("collision detected\n");
			//Handle all obstacle cases.
			if(interactiveObj->getObectType().compare("Obstacle") == 0)
			{
				obstacle = (Obstacles*)interactiveObj;
				obstacleType myObsType = obstacle->getObstacleType();
				interactiveObj->setState(READY);
				interactiveObj->setOnScreen(no);
				player->bumpAction(myObsType);
			}
			//Handle all car cases.
			else
			{
				car = (Car*)interactiveObj;

				if(car->getCarType() != BONUS_CAR)
				{
					//In the case of car, we are interested in from where we are having the collision
					switch(collSide)
					{
					case COLLIDING_TOP_LEFT:
						player->setSlideDirection(DIRECTION_LEFT);
						break;

					case COLLIDING_TOP_RIGHT:
						player->setSlideDirection(DIRECTION_RIGHT);
						break;

					case COLLIDING_BOTTOM_LEFT:
						player->setSlideDirection(DIRECTION_LEFT);
						break;

					case COLLIDING_BOTTOM_RIGHT:
						player->setSlideDirection(DIRECTION_RIGHT);
						break;
					}
				}

				carType mycarType = car->getCarType();
				if(car->isActive())
				{
					car->setSlideDirection(player->getSlideDirection() == DIRECTION_LEFT ? DIRECTION_RIGHT : DIRECTION_LEFT);
					car->bumpAction();
					player->bumpAction(mycarType);
				}
			}
		}
	}
}
Esempio n. 24
0
int main() {
    Car car;
    car.run();
    cout << "Hello World!" << endl;
}
Esempio n. 25
0
int main(){
    Car   car;
		car.radio.rfun();
		car.carfun();
}
Esempio n. 26
0
void Game::applyCollision(Car& car1, Car& car2)
{
    int angle1 = car1.getTravelAngle();
    int angle2 = car2.getTravelAngle();

    sf::Vector2f unitVector1(cos(angle1*PI/180), sin(angle1*PI/180));
    sf::Vector2f unitVector2(cos(angle1*PI/180), sin(angle1*PI/180));

    int mass1 = car1.getMass();
    int mass2 = car2.getMass();
    int massTotal = mass1 + mass2;

    double posX1 = car1.getPosX();
    double posY1 = car1.getPosY();
    double posX2 = car2.getPosX();
    double posY2 = car2.getPosY();

    double vel1 = car1.getVelocity();
    double vel2 = car2.getVelocity();

    double momentumInit1X = mass1 * vel1 * unitVector1.x;
    double momentumInit2X = mass2 * vel2 * unitVector2.x;

    double momentumInit1Y = mass1 * vel1 * unitVector1.y;
    double momentumInit2Y = mass2 * vel2 * unitVector2.y;

    double momentumTotalInitX = momentumInit1X + momentumInit2X;
    double momentumTotalInitY = momentumInit1Y + momentumInit2Y;

    double velFinalX = momentumTotalInitX/massTotal;
    double velFinalY = momentumTotalInitY/massTotal;

    double velFinal = sqrt(velFinalX * velFinalX + velFinalY * velFinalY)*2;
    double angleFinal = tan(velFinalY/velFinalX)*10;

    car1.setDriveState(4);
    car2.setDriveState(4);

    //NEED to separate (minimum distance) before setting cars off on their ways
    car1.setTravelAngle(angle2);
    car2.setTravelAngle(angle1);

    car1.setVelocity(vel2);
    car2.setVelocity(vel1);

    std::cout << "car1: " << theCar.getTravelAngle() << "\n";
    std::cout << "car2: " << car.getTravelAngle() << "\n";
}
Esempio n. 27
0
void RemoteProcessClient::writeCar(const Car& car) {
    writeBoolean(true);

    writeLong(car.getId());
    writeDouble(car.getMass());
    writeDouble(car.getX());
    writeDouble(car.getY());
    writeDouble(car.getSpeedX());
    writeDouble(car.getSpeedY());
    writeDouble(car.getAngle());
    writeDouble(car.getAngularSpeed());
    writeDouble(car.getWidth());
    writeDouble(car.getHeight());
    writeLong(car.getPlayerId());
    writeInt(car.getTeammateIndex());
    writeBoolean(car.isTeammate());
    writeEnum<CarType>(car.getType());
    writeInt(car.getProjectileCount());
    writeInt(car.getNitroChargeCount());
    writeInt(car.getOilCanisterCount());
    writeInt(car.getRemainingProjectileCooldownTicks());
    writeInt(car.getRemainingNitroCooldownTicks());
    writeInt(car.getRemainingOilCooldownTicks());
    writeInt(car.getRemainingNitroTicks());
    writeInt(car.getRemainingOiledTicks());
    writeDouble(car.getDurability());
    writeDouble(car.getEnginePower());
    writeDouble(car.getWheelTurn());
    writeInt(car.getNextWaypointX());
    writeInt(car.getNextWaypointY());
    writeBoolean(car.isFinishedTrack());
}
Esempio n. 28
0
	Car * buildWholeCar() {
		Car *car = new Car("LuxuryCar");
		car->setTire(buildTire());
		car->setBody(buildBody());
		return car;
	}
Esempio n. 29
0
bool Car::operator==(const Car &rhs) const {

    return this->getPlate() == rhs.getPlate();
}
    virtual std::uint64_t encodeHdrAndCar()
    {
        MessageHeader hdr;
        Car car;

        hdr.wrap(m_buffer, 0, 0, sizeof(m_buffer))
            .blockLength(Car::sbeBlockLength())
            .templateId(Car::sbeTemplateId())
            .schemaId(Car::sbeSchemaId())
            .version(Car::sbeSchemaVersion());

        car.wrapForEncode(m_buffer, hdr.encodedLength(), sizeof(m_buffer))
            .serialNumber(SERIAL_NUMBER)
            .modelYear(MODEL_YEAR)
            .available(AVAILABLE)
            .code(CODE)
            .putVehicleCode(VEHICLE_CODE);

        for (std::uint64_t i = 0; i < Car::someNumbersLength(); i++)
        {
            car.someNumbers(i, static_cast<std::int32_t>(i));
        }

        car.extras().clear()
            .cruiseControl(CRUISE_CONTROL)
            .sportsPack(SPORTS_PACK)
            .sunRoof(SUNROOF);

        car.engine()
            .capacity(engineCapacity)
            .numCylinders(engineNumCylinders)
            .putManufacturerCode(MANUFACTURER_CODE);

        Car::FuelFigures& fuelFigures = car.fuelFiguresCount(FUEL_FIGURES_COUNT);

        fuelFigures
            .next().speed(fuel1Speed).mpg(fuel1Mpg);

        fuelFigures.putUsageDescription(
            FUEL_FIGURES_1_USAGE_DESCRIPTION, static_cast<int>(strlen(FUEL_FIGURES_1_USAGE_DESCRIPTION)));

        fuelFigures
            .next().speed(fuel2Speed).mpg(fuel2Mpg);
        fuelFigures.putUsageDescription(
            FUEL_FIGURES_2_USAGE_DESCRIPTION, static_cast<int>(strlen(FUEL_FIGURES_2_USAGE_DESCRIPTION)));

        fuelFigures
            .next().speed(fuel3Speed).mpg(fuel3Mpg);
        fuelFigures.putUsageDescription(
            FUEL_FIGURES_3_USAGE_DESCRIPTION, static_cast<int>(strlen(FUEL_FIGURES_3_USAGE_DESCRIPTION)));

        Car::PerformanceFigures &perfFigs = car.performanceFiguresCount(PERFORMANCE_FIGURES_COUNT);

        perfFigs.next()
            .octaneRating(perf1Octane)
            .accelerationCount(ACCELERATION_COUNT)
            .next().mph(perf1aMph).seconds(perf1aSeconds)
            .next().mph(perf1bMph).seconds(perf1bSeconds)
            .next().mph(perf1cMph).seconds(perf1cSeconds);

        perfFigs.next()
            .octaneRating(perf2Octane)
            .accelerationCount(ACCELERATION_COUNT)
            .next().mph(perf2aMph).seconds(perf2aSeconds)
            .next().mph(perf2bMph).seconds(perf2bSeconds)
            .next().mph(perf2cMph).seconds(perf2cSeconds);

        car.putMake(MAKE, static_cast<int>(strlen(MAKE)));
        car.putModel(MODEL, static_cast<int>(strlen(MODEL)));
        car.putActivationCode(ACTIVATION_CODE, static_cast<int>(strlen(ACTIVATION_CODE)));

        return hdr.encodedLength() + car.encodedLength();
    }