//This sample main program may be used to test C++ code generation scripts.
//In With Class load cppcar.omt.  Run the scripts cpphead1.sct and cppfunc1.sct
//or borland scripts.
//Create a project in your C++ environment.  Add cppmain.cpp, vehicle.cpp, 
//car.cpp, motor.cpp, passenge.cpp, tire.cpp, and cellular.cpp.
//Comments and suggestions are solicited Richard Felsinger, RCF Associates
//960 Scottland Dr, Mt Pleasant, SC 29464 tele 803-881-3648 71162.755@compuserve.com

#include "stdafx.h"
#include "car.h"
#include <iostream.h>

int main ()
{ 
  Car car1;                                                     //Invokes default constructor
  car1.operate();                                       //Invokes operation function
 
  cin >> car1;                          //Invokes input function >>
  cout << car1;                                 //Invokes output function << 

  int aSpeed, aNumber;                  //Create int variables
  long aTotal;                          //Create long variable
  car1.setspeed (55);                                   //Invokes set accessor function
  aSpeed = car1.getspeed();                     //Invokes get accessor function 
  Car::settotalCarsBuilt (20000);   //Invokes set accessor function for static data member
  aTotal = Car::gettotalCarsBuilt(); //Invokes get accessor function for static data member
  
  Car car2 (car1);                                //Invokes copy constructor
  Car car3 (55);                                  //Invokes constructor with arguments
  car1 = car2;                                    //Invokes assignment operator

												//Invokes equality operator
  if (car1 == car2) cout << "Cars are equal." << "\n";
  else cout << "Cars are not equal." << "\n";

  car1.registerIt();                    //Invokes redefined virtual function
  car1.operate();                       //Invokes a function    
  car1.setnumber(1111);                 //Invokes set accessor function from base class
  aNumber = car1.getnumber();  //Invokes get accessor function from base class

  Motor motor1, motor2;     //Create motor objects
  car1.operate();           //Invokes traversal function to access aggregation part
  car1.setMotor(motor1);    //Invokes set accessor function to set aggregation part
  motor2 = car1.getMotor(); //Invokes get accessor function to get aggregation part

  CellularPhone phone1, phone2;       //Create phone objects
  car1.setCellularPhone (&phone1);    //Invokes set accessor function for association object
  car1.makePhoneCall();         //Invokes traversal function to access association object
  phone2 = *car1.getCellularPhone ();  //Invokes get accessor function to get association object
  BOOL phoneStatus = car1.existsCellularPhone ();  //Invokes exists function for association object
  phoneStatus = car1.existsCellularPhone (&phone1);//Invokes exists function for association object
  car1.removeCellularPhone();         //Invokes remove function for association object
  
  CObList tireCollection;   
  
//  tireCollection = car1.getTireCollection(); //Invokes get accessor function for collection of aggregation objects
  Tire tire1(50), tire2(60);      
  tireCollection.AddTail(&tire1);	  
  tireCollection.AddTail(&tire2);	  
                    //Creates tire objects

  car1.setTireCollection (tireCollection);   //Invokes set accessor function for collection of aggregation objects

  tire1 = car1.getFirstTire();           //Invokes get accessor function for 1:M aggregation object
  BOOL tireStatus = car1.existsTire (tire1);//Invokes exists function for 1:M aggregation object
  car1.inflateTire();                                                   //Invokes traversal function for 1:M aggregation object
  
  CObList passengerCollection;
//passengerCollection = car1.getPassengerCollection(); //Invokes get accessor function for collection of association objects
  car1.setPassengerCollection (passengerCollection);   //Invokes set accessor function for collection of association objects
  
  Passenger passenger1, passenger2, passenger3, passenger4; //Create passenger objects
  car1.addPassenger(&passenger1);         //Invokes add function for 1:M association object
  car1.addPassenger(&passenger2);               //Invokes add function for 1:M association object
  car1.addPassenger(&passenger3);         //Invokes add function for 1:M association object
  car1.addPassenger(&passenger4);         //Invokes add function for 1:M association object
  car1.checkPassengerSeatBelt();                                //Invokes traversal function for 1:M association object
	 
  BOOL passengerStatus;
//  passengerStatus = car1.existsPassenger ();        //Invokes exists function for association object
  passengerStatus = car1.existsPassenger (passenger1);   //Invokes exists function for association object

  cin >> car1;                                                                          //Invokes the >> operator to input text information
  cout << car1;                                                                         //Invokes the << operator to output text information

  car1.removeLastPassenger ();                  //Invokes removeLast function for 1:M association object
  car1.removeAllPassengers();             //Invokes removeAll function for 1:M association object
  
  return 0;                     //Default destructor is invoked
}


