/*Performs the 'difference' set operator*/ VehicleRegistry VehicleRegistry::Split(const VehicleRegistry& vr) const { VehicleRegistry differences(*this); //Go through the vr list and use the find function with union as the calling object, if we do find it in the union list then we remove the vehicle from the union list for (int i = 0; i < vr.numvehicles; i++) { if (differences.Find(Vehicle(vr.vehicles[i].GetPlate(), "", "", "")) != -1) { differences.Remove(Vehicle(vr.vehicles[i].GetPlate(), vr.vehicles[i].GetMake(), vr.vehicles[i].GetModel(), vr.vehicles[i].GetColour())); } } return differences; }
/*Performs the 'union' set operator*/ VehicleRegistry VehicleRegistry::Join(const VehicleRegistry& vr) const // a function that returns an object { VehicleRegistry unions(*this); //keyword 'this' is the pointer to the 'calling' object /*Go through the vr list, and use the find function with union as the calling object, if we can't find it in the union list then we add the vehicle to the union list */ for (int i = 0; i < vr.numvehicles; i++) { if (unions.Find(Vehicle(vr.vehicles[i].GetPlate(), "", "", "")) == -1) { unions.Insert(Vehicle(vr.vehicles[i].GetPlate(), vr.vehicles[i].GetMake(), vr.vehicles[i].GetModel(), vr.vehicles[i].GetColour())); } } return unions; }
/*Performs the 'intersection' set operator*/ VehicleRegistry VehicleRegistry::Common(const VehicleRegistry& vr) const { VehicleRegistry common(*this); //keyword 'this' is the pointer to the 'calling' object //Use a double for loop to go through both list and if matching parameters are found we leave it alone, if we find non-matching parameters after going through the entire list //then remove the item for (int i = 0; i < common.numvehicles; i++) { for (int p = 0; p < vr.numvehicles; p++) { if (p < vr.numvehicles && common.vehicles[i].GetPlate() == vr.vehicles[p].GetPlate()) { break; } else if (p == (vr.numvehicles - 1) && common.vehicles[i].GetPlate() != vr.vehicles[p].GetPlate()) { common.Remove(Vehicle(common.vehicles[i].GetPlate(), common.vehicles[i].GetMake(), common.vehicles[i].GetModel(), common.vehicles[i].GetColour())); i = 0; } } } return common; }
void Line::set_num_of_vehicles( int n_vehicles ) { if (n_vehicles<0) { n_vehicles = 0; } int count = n_vehicles-num_of_vehicles(); if (count > 0) { while (count-- > 0) { add_driver( *GenerateDriver( &Driver(Vehicle()), my_road_,index())); } reorder(); } else { while (count++ < 0) { drivers_->pop_back(); } reorder(); } }
void vectorLogs() { std::vector<std::string> stringVec; std::vector<Vehicle> vehicleVec; stringVec.push_back("stringVec"); vehicleVec.push_back(Vehicle("Honda", "Accord", 2013, "vehicleVec")); LOG(INFO) << "stringVec : " << stringVec; LOG(INFO) << "vehicleVec : " << vehicleVec; }
Vehicle ^Ped::CurrentVehicle::get() { if (!IsInVehicle()) { return nullptr; } return gcnew Vehicle(Native::Function::Call<int>(Native::Hash::GET_VEHICLE_PED_IS_IN, this->Handle, false)); }
Traveler_Data::Traveler_Data (int traveler, int time) : Class2_Index (traveler, time), Static_Scale () { Vehicle (0); Link_Dir (0); Offset (0); Lane (0); Distance (0); Speed (0); }
Activity_Data::Activity_Data (int traveler, int activity) : Class2_Index (traveler, activity), Static_Scale () { Purpose (0); Priority (0); Start_Time (0); End_Time (0); Duration (0); Mode (0); Vehicle (0); Location (0); Passengers (0); Constraint (0); }
bool OEFind::parse_database() { char filename[1024]; char confname[1024]; bool exist_flag=false; sprintf(filename, "%s/Vehicle.e", conf_dir); QString filename_CN = filename_CN.fromLocal8Bit(filename); QFile Vehicle(filename_CN); if(!Vehicle.open(QIODevice::ReadOnly)) //配置文件不存在 { exist_flag =true; sprintf(confname,"%s/conf1",conf_dir); QString confname_CN= confname_CN.fromLocal8Bit(confname); QFile conf(confname_CN); if(!conf.open(QIODevice::ReadOnly)) return false; QByteArray Vehicle_Array =QByteArray::fromBase64(conf.readAll()); if(!Vehicle.open(QIODevice::WriteOnly)) return false; Vehicle.write(Vehicle_Array); Vehicle.close(); conf.close(); } Vehicle.close(); DDEScheme scheme; scheme.parse_file(filename); if(!scheme.tables().size()) return false; //printf("DDEScheme %lu\n", scheme.tables().size()); db_read.scheme(&scheme); db_read.m_name = "read"; if(exist_flag) { QString filename_CN = filename_CN.fromLocal8Bit(filename); QFile::remove(filename_CN); } if(!read_oedata()) return false; return true; }
void testApp::setup(){ ofSetFrameRate(30); ofBackground(255); ofSetVerticalSync(true); ofSetCircleResolution(100); ofEnableSmoothing(); debug = true; circleLocation.set(ofGetWidth()/2,ofGetHeight()/2, 0); circleRadius = 200; for (int i=0;i<200;i++) { // in case you'd like to see lots of these in action v.push_back(Vehicle(ofGetWidth()/2,ofGetHeight()/2-5, ofRandom(-10,10), circleLocation, circleRadius)); } }
void listLogs() { std::list<std::string> stringList; std::vector<std::string*> stringPtrList; std::list<Vehicle> vehicleList; std::vector<Vehicle*> vehiclePtrList; stringList.push_back("stringList"); stringPtrList.push_back(new std::string("stringPtrList")); vehicleList.push_back(Vehicle("Honda", "Accord", 2013, "vehicleList")); vehiclePtrList.push_back(new Vehicle("Honda", "Accord", 2013, "vehiclePtrList")); LOG(INFO) << "stringList : " << stringList; LOG(INFO) << "stringPtrList : " << stringPtrList; LOG(INFO) << "vehicleList : " << vehicleList; LOG(INFO) << "vehiclePtrList : " << vehiclePtrList; delete stringPtrList.at(0); delete vehiclePtrList.at(0); }
void ofApp::setup(){ ofSetFrameRate(30); ofBackground(255); ofSetVerticalSync(true); ofSetCircleResolution(100); ofEnableSmoothing(); glEnable(GL_DEPTH_TEST); debug = true; circleLocation.set(ofGetWidth()/2,ofGetHeight()/2, 0); circleRadiusOuter = 200; circleRadiusInner = 150; for (int i=0;i<2;i++) { // in case you'd like to see lots of these in action v.push_back(Vehicle(ofGetWidth()/2,ofGetHeight()/2-5, ofRandom(-2,2))); } }
Vehicle generateVehicle() { //Variable declarations int loopCount; double mass, Cdrag, frontArea, diffRatio, wheelRadius, valueHold, maxRpm, driveForce, brakingForce; std::vector<double> gearRatios, revMap, torqueMap; std::string name; Vehicle returnVehicle; std::cout << std::endl << "--------------------------Enter data for simulation----------------------------" << std::endl; std::cout << std::endl << "Enter name of vehicle"; name = util::getSanitizedInput<std::string>(); std::cout << std::endl << "Enter mass of Vehicle (kg): "; mass = util::getSanitizedInput<double>(); std::cout << std::endl << "Enter Cd: "; Cdrag =util::getSanitizedInput<double>(); //Prompts user for a drive force unless simulation 4 was selected //std::cout << std::endl << "Enter drive force (N): "; //driveForce = util::getSanitizedInput<double>(); std::cout << std::endl << "Enter front area (m^2): "; frontArea = util::getSanitizedInput<double>(); std::cout << std::endl << "Enter wheel radius (m): "; wheelRadius = util::getSanitizedInput<double>(); std::cout << std::endl << "Enter differential ratio: "; diffRatio = util::getSanitizedInput<double>(); std::cout << std::endl << "Vehicle creation complete. Press any key to continue" << std::endl << std::endl; _getch(); return Vehicle(mass, Cdrag, frontArea, diffRatio, wheelRadius, name); }
/** * Constructor de la classe carril * @param graficVehicle gràfic associat al vehicle * @param area àrea de la zona per on es pot moure el vehicle * @param nivell nivell en el que es troba el jugador * @param iniciCarril indica on comença el carril del vehicle */ Carril::Carril(Grafic graficVehicle, int nivell, int iniciCarrilY, int iniciCarrilX) { m_areaTotal = Area(INICI_X, FI_X, INICI_Y, FI_Y); m_iniciCarrilY = iniciCarrilY; m_iniciCarrilX = iniciCarrilX; m_grafic = graficVehicle; m_vehicle = Vehicle(m_grafic, nivell*DESPLACAMENT_COTXE, m_iniciCarrilX); m_nivell = nivell; if (m_iniciCarrilX == INICI_X) { m_vehicle.mouAIniciCarril(m_iniciCarrilX + retardSortidaX(), m_iniciCarrilY); m_cua.afegeix(m_vehicle); } else { m_vehicle.mouAIniciCarril(m_iniciCarrilX - retardSortidaX(), m_iniciCarrilY); m_cua.afegeix(m_vehicle); } }
void Scanner::scanVehicles() { _model.removeRows(0, _model.rowCount()); QDir dir(QString::fromUtf8(JM::System::app().vldr().path().c_str())); if (dir.exists()) { dir.setFilter(QDir::Dirs | QDir::NoSymLinks); QStringList dirList = dir.entryList(); dirList.removeFirst(); dirList.removeFirst(); foreach (QString dirName, dirList) { // check dirName.xml dir.cd(dirName); if (dir.exists(dirName + ".xml")) { _model.insertRow(_model.rowCount()); _model.setData(_model.index(_model.rowCount() - 1), QVariant::fromValue(Vehicle(dir.absoluteFilePath(dirName + ".xml")))); } dir.cdUp(); }
int main(int argc, char** argv) { // 有两辆车需要销售,一辆是普通轿车,而另一辆则是奔驰 Vehicle& vehicle = Vehicle(); // Vehicle& benz = Benz(); //Benz& benz = Benz(); // 向普通销售询问这两辆车的折扣 Sales* pSales = new Sales(); double rate = pSales->GetDiscountRate(vehicle); std::cout << "Sales: The rate for common vehicle is: " << rate << std::endl; rate = pSales->GetDiscountRate(benz); std::cout << "Sales: The rate for benz is: " << rate << std::endl; // 向销售经理询问这两辆车的折扣 SalesManager* pSalesManager = new SalesManager(); rate = pSalesManager->GetDiscountRate(vehicle); std::cout << "Sales Manager: The rate for common vehicle is: " << rate << std::endl; rate = pSalesManager->GetDiscountRate(benz); std::cout << "Sales Manager: The rate for benz is: " << rate << std::endl; return 0; }
void ProjectScene::init() { vehicle=Vehicle(); for (unsigned int i = 0; i < 8; i++) lights[i] = NULL; globals=Global(); XMLSceneMod temp = XMLSceneMod("wall-e.xml", &sceneGraph, lights ,textures,appearances,animations,&cameras, activeCamera, &globals, flagShaders); glEnable(GL_LIGHTING); glEnable (GL_NORMALIZE); //mode //Defines Drawing computations if(strcmp(globals.getMode(), "fill") == 0) glPolygonMode(GL_FILL,GL_TRUE); else if(strcmp(globals.getMode(), "point") == 0) glPolygonMode(GL_POINT,GL_TRUE); else if(strcmp(globals.getMode(), "line") == 0) glPolygonMode(GL_LINE,GL_TRUE); //shading if(strcmp(globals.getShading(),"flat")==0) glShadeModel(GL_FLAT); else if (strcmp(globals.getShading(),"gouraud")==0) { glShadeModel(GL_SMOOTH); } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //background glClearColor(globals.getBackground()[0],globals.getBackground()[1],globals.getBackground()[2],globals.getBackground()[3]); //culling if(strcmp(globals.getFace(), "none") == 0) glDisable(GL_CULL_FACE); else if (strcmp(globals.getFace(), "front") == 0){ glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); } else if (strcmp(globals.getFace(), "back") == 0){ glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } else if (strcmp(globals.getFace(), "both") == 0){ glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); } //order if (strcmp(globals.getFace(), "ccw") == 0) glFrontFace(GL_CCW); else if (strcmp(globals.getFace(), "cw") == 0) glFrontFace(GL_CW); //doublesided if(globals.getDoublesided()) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); else glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); //local if(globals.getLocal()) glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); else glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); //enabled if(globals.getEnabled()) glEnable(GL_LIGHTING); // Sets up some lighting parameters // Computes lighting only using the front face normals and materials glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); // Define ambient light (do not confuse with ambient component of individual lights) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globals.getAmbient()); /* for (unsigned int i = 0; i < 8; i++){ if (lights[i] == NULL) break; cout << lights[i]->showLight(); }*/ this->processDisplayLists(this->sceneGraph.getRoot(), this->sceneGraph.getRoot()); // Animation-related code unsigned long updatePeriod=50; setUpdatePeriod(updatePeriod); }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(255); ofSetBackgroundAuto(true); flowField = FlowField(15); vehicle = Vehicle(ofGetWidth() / 2,ofGetHeight() / 2); }
void Line::time_for_add_driver() { add_driver(*GenerateDriver(&Driver(Vehicle()),my_road_,index_,REAL_METERS)); reorder(); processed_count_=0; }
Vehicle ^Player::LastVehicle::get() { return gcnew Vehicle(Native::Function::Call<int>(Native::Hash::GET_PLAYERS_LAST_VEHICLE)); }