Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

* Exercise 3: Statistical institution engaged in collection information about Ve

ID: 648242 • Letter: #

Question

*Exercise 3:

Statistical institution engaged in collection information about Vehicles, and in order to organize their search they divide their researching tasks into two parts one for On Road Vehicles and the other for Off Road Vehicles. (See figure 2)

We mean by On Road Vehicles those cars which involve in racing tracks such as Touring and Pan Cars, each car of these has its own ID and the times of winning in the racing. These cars are classified by their Brand Marks (Jaguar, Porsche).

In the main function create a pointer object for base class.

Invoke Printinfo( ) functions properly for each class using base class pointer object.

*Exercise 3: Statistical institution engaged in collection information about Vehicles, and in order to organize their search they divide their researching tasks into two parts one for On Road Vehicles and the other for Off Road Vehicles. (See figure 2) We mean by On Road Vehicles those cars which involve in racing tracks such as Touring and Pan Cars, each car of these has its own ID and the times of winning in the racing. These cars are classified by their Brand Marks (Jaguar, Porsche). In the main function create a pointer object for base class. Invoke Printinfo( ) functions properly for each class using base class pointer object.

Explanation / Answer

include <iostream>
#include<string>
using namespace std;

class Vehicles
{protected:
string type;
string brand;

public:
Vehicles()
{
   type="jagour";
   brand="aclass";
  
  
}
string gettype()
{
return type;
}
string getbrand()
{
   return brand;
}
void printinfo()
{
   cout<<"brand "<<brand;
   cout<<"type "<<type;
}
};

class off_road :public Vehicles
{
   private:
   int miles;
   bool used;
public:
off_road()
{
   miles=900;
   used =true;
}
float getmiles()
{
   return miles;
}
bool isbool()
{
   return true;
}
void printinfo()
{
printinfo();
cout<<miles<<used;  
}
};
class on_road :public Vehicles
{
  
   private :
   int winning;
   int id;
public:
on_road()
{
   winning=90;
id=90;  
}
int getWinning()
{
return winning;
}
int GetOnRoadID()
{
   return id;;
}
void printinfo()
{
   cout<<"winning "<<winning;
   cout<<"on road id "<<id;
}

};


int main() {
   // your code goes here
Vehicles *sPtr;
cout<< sPtr -> getbrand();

cout<<sPtr -> gettype();
off_road offr;
on_road onroa;
sPtr =&offr;
sPtr->printinfo();
sPtr=&onroa;
sPtr->printinfo();
  
  
  
   return 0;
}