00001 // Truck.cpp: implementation of the Truck class. 00002 // 00004 00005 #include "stdafx.h" 00006 #include "Truck.h" 00007 00008 using namespace std; 00009 00011 // Construction/Destruction 00013 00015 Truck::Truck(){ 00016 /* 00017 HEAD = 0; DAY = 0; MONTH = 0; YEAR = 5; HOUR = 0; 00018 MIN = 0; SEC = 0; hNDT = 0; SPEED = 0; GVW = 0; 00019 LENGTH = 0; NAXLES = 0; DIRN = 0; LANE = 0; TRNS = 0; 00020 */ 00021 00022 } 00023 00025 Truck::~Truck() 00026 { 00027 for(int i = 0; i < m_vAxles.size(); i++) 00028 delete m_vAxles.at(i); 00029 m_vAxles.clear(); 00030 } 00031 00033 void Truck::returnTruckData(int truckData[]) 00034 { 00035 00036 truckData[0] = m_Head; 00037 truckData[1] = m_Day; 00038 truckData[2] = m_Month; 00039 truckData[3] = m_Year; 00040 truckData[4] = m_Hour; 00041 truckData[5] = m_Min; 00042 truckData[6] = m_Sec; 00043 truckData[7] = m_Hndt; 00044 truckData[8] = m_Velocity; // must change to dm/s 00045 truckData[9] = m_GVW; // change to kg/100 00046 truckData[10] = m_Length; // change to dm 00047 truckData[11] = m_NoAxles; 00048 truckData[12] = m_intDir; //m_DirPointsToRight == true ? 1 : 2; 00049 truckData[13] = m_Lane; 00050 truckData[14] = m_Trns; 00051 00052 for(int i = 0; i <= 33; i++) 00053 { 00054 if( (truckData[i] < 0) || (truckData[i] > 9999) ) truckData[i] = 0; 00055 } 00056 } 00057 00058 bool Truck::operator<(const Truck& x) 00059 { 00060 double a = this->getTime(); 00061 double b = x.getTime(); 00062 return a < b; 00063 } 00064 00065 bool Truck::operator==(Truck& x) 00066 { 00067 const int N = 33; 00068 int truck1[N]; int truck2[N]; 00069 returnTruckData(truck1); 00070 x.returnTruckData(truck2); 00071 00072 bool same = true; int i = 0; 00073 while(same && i < N) 00074 { 00075 if(truck1[i] != truck2[i]) 00076 same = false; 00077 i++; 00078 } 00079 return same; 00080 } 00081 00089 void Truck::createSAFTVehicle(std::string data) 00090 { 00091 Vehicle::createSAFTVehicle(data); 00092 m_OverhangFront = 0.0; 00093 m_OverhangBack = 0.0; 00094 } 00095 00103 void Truck::createCASTORVehicle(std::string data) 00104 { 00105 Vehicle::createCASTORVehicle(data); 00106 m_OverhangFront = 0.0; 00107 m_OverhangBack = 0.0; 00108 } 00109 00110 00111 00112