int main() { Hondurato car1(20, 0, 20, 25); Hondurato car2(7, 20000, 18, 20); Hondurato car3(10, 120000, 15, 20); std::cout << "-- Car 1 --\nFuel: " << car1.get_fuel() << "/" << car1.get_tank_capacity() << "\n" << "Odometer: " << car1.get_odometer() << ", MPG: " << car1.get_mpg() << "\n"; std::cout << "-- Car 2 --\nFuel: " << car2.get_fuel() << "/" << car2.get_tank_capacity() << "\n" << "Odometer: " << car2.get_odometer() << ", MPG: " << car2.get_mpg() << "\n"; std::cout << "-- Car 3 --\nFuel: " << car3.get_fuel() << "/" << car3.get_tank_capacity() << "\n" << "Odometer: " << car3.get_odometer() << ", MPG: " << car3.get_mpg() << "\n"; std::cout << "\nCar 1 drives at 60mph for 45 minutes to it's destination.\nIt has " << car1.drive(60, 45) << " gallons of fuel left.\n"; std::cout << "Car 2 drives at 80mph for 1 hour and 20 minutes to it's destination.\nIt has " << car2.drive(80, 80) << " gallons of fuel left.\n"; std::cout << "Car 3 drives at 30mph for 30 minutes to it's destination.\nIt has " << car3.drive(30, 30) << " gallons of fuel left.\n"; std::cout << "Car 2 fuels up, it now has " << car2.addFuel(5) << " gallons in it's tank.\n"; std::cout << "Car 3 fuels up, it now has " << car3.addFuel(0) << " gallons in it's tank.\n"; return 0; }
int main(void) { List<Car> l; Car car(MERCEDES_BENZ, 10, 2010, 100, "qwerty"); Car car2(TOYOTA, 10, 2010, 100, "qwerty2"); Car car3(MERCEDES_BENZ, 10, 2010, 100, "qwerty3"); l.PushBack(car); l.PushBack(car2); l.PushBack(car3); l.Print(cout); cout<<"\n\n"; l.Compact(); l.Print(cout); cout<<"\n\n\n"; l.Diffuse(); //l.PushBack(car); cout << l; return 0; }
void display(){ //clear the display glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(BLACK, 0); //color black glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /******************** / set-up camera here ********************/ //load the correct matrix -- MODEL-VIEW matrix glMatrixMode(GL_MODELVIEW); //initialize the matrix glLoadIdentity(); //now give three info //1. where is the camera (viewer)? //2. where is the camera is looking? //3. Which direction is the camera's UP direction? //instead of CONSTANT information, we will define a circular path. gluLookAt(200*cos(cameraAngle), 200*sin(cameraAngle), 150, 0,0,0, 0,0,1); //NOTE: the camera still CONSTANTLY looks at the center // cameraAngle is in RADIAN, since you are using inside COS and SIN //again select MODEL-VIEW glMatrixMode(GL_MODELVIEW); /**************************** / Add your objects from here ****************************/ //border glColor3f(1,1,1); glBegin(GL_LINES);{ glVertex3f(-100, -100, 0); glVertex3f(-100, 100, 0); glVertex3f(-100, 100, 0); glVertex3f(100, 100, 0); glVertex3f(100, 100, 0); glVertex3f(100, -100, 0); glVertex3f(100, -100, 0); glVertex3f(-100, -100, 0); }glEnd(); //roads glColor3f(1,1,1); glBegin(GL_QUADS);{ glVertex3f(-100,-20,0); glVertex3f(-100,20,0); glVertex3f(100,20,0); glVertex3f(100,-20,0); }glEnd(); glColor3f(1,1,1); glBegin(GL_QUADS);{ glVertex3f(-20,100,0); glVertex3f(20,100,0); glVertex3f(20,-100,0); glVertex3f(-20,-100,0); }glEnd(); //moving car pos1 += .1; if(pos1>180) pos1 = 0; car1(pos1); pos2 += .05; if(pos2>180) pos2 = 0; car2(pos2); pos3 += .075; if(pos3>180) pos3 = 0; car3(pos3); //top left buildings 1st row drawBuilding(-90, -90, -90, -70, 50); drawBuilding(-90, -60, -90, -40, 30); //top left buildings 2nd row drawBuilding(-60, -90, -60, -70, 60); drawBuilding(-55, -60, -55, -40, 40); //top right buildings 1st row drawBuilding(-90, 90, -90, 70, 70); drawBuilding(-90, 60, -90, 40, 50); //top right buildings 2nd row drawBuilding(-60, 90, -60, 75, 80); drawBuilding(-60, 70, -60, 35, 45); //middle left buildings drawBuilding(40, -90, 40, -70, 40); drawBuilding(40, -60, 40, -40, 50); //middle right buildings drawBuilding(30, 90, 30, 70, 30); drawBuilding(30, 60, 30, 40, 50); //bottom left buildings drawBuilding(70, -90, 70, -70, 30); drawBuilding(75, -60, 75, -40, 30); //bottom right buildings drawBuilding(70, 90, 70, 70, 90); drawBuilding(70, 65, 70, 40, 30); //ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE) glutSwapBuffers(); }