using
namespace
std;
class
Taxi
{
private:
string driver_name;
string maker;
string color;
public:
int
calls;
int
passengers;
static
int
Tpassengers;
Taxi(string name, string maker, string color)
{
this->driver_name=name;
this->maker=maker;
this->color=color;
this->passengers=0;
this->calls=0;
}
Taxi(int
pass)
{
this->passengers=pass;
}
int
NPassenger()
{
int
x = (rand()%10)+1;
return
x;
}
Taxi
operator
+= (const
Taxi x){
this->passengers +=x.passengers;
this->calls+=1;
return
*this;
}
void
write_Taxi_info()
{
ofstream outFile;
outFile.open("CTC.txt", std::ios_base::app);
outFile.close();
}
};
int
Taxi::Tpassengers{0};
int
main()
{
srand((unsigned)time(0));
Taxi** taxis =
new
Taxi*[6];
taxis[0] =
new
Taxi("xyz qwe","erty","blue");
taxis[1] =
new
Taxi("xyz qwe","erty","blue");
taxis[2] =
new
Taxi("xyz qwe","erty","blue");
taxis[3] =
new
Taxi("xyz qwe","erty","blue");
taxis[4] =
new
Taxi("xyz qwe","erty","blue");
taxis[5] =
new
Taxi("xyz qwe","erty","blue");
char
choice;
cout <"\nwelcome to="" ctc="">"\nwelcome>
do{
cout <"\ndo you="" need="" a="">"\ndo>
cin >>choice;
if(choice!='Y' && choice!='y')
{
break;
}
int
taxi = rand()%6;
cout <"taxi>"taxi><><" will="" pick="" you="" up="" in="" a="" few="">">
int
pass=taxis[taxi]->NPassenger();
Taxi* temp =
new
Taxi(pass);
*taxis[taxi]+=*temp;
Taxi::Tpassengers+=pass;
}while(1);
cout < "************************************************************************"=""><>
cout <"\t\t*ctc taxi="" served="" a="" total="" of="">"\t\t*ctc>< taxi::tpassengers=""><" passengers="">">
cout <><>
cout <><>
cout < "*each="" taxi="" serve="" total="" number="" of="" passenger="" in="" this="" shift="" as="">
cout <><>
cout <>< taxis[0]-="">calls <">">< taxis[1]-="">calls
<">">< taxis[2]-="">calls <">">< taxis[3]-="">calls <">">< taxis[4]-="">calls <">">< taxis[5]-="">calls
<">">< taxis[0]-="">passengers <>< taxis[1]-="">passengers <>< taxis[2]-="">passengers <>
< taxis[3]-="">passengers <>< taxis[4]-="">passengers <>< taxis[5]-="">passengers <>
cout<><>
int
index=0;
int
sum=taxis[0]->passengers;
for(int
i=1;i<>
{
if(taxis[i]->passengers>taxis[index]->passengers)
{
index=i;
}
sum+=taxis[i]->passengers;
}
cout<"today taxi="">"today><><" served="" most="">">
cout<"today on="" average="" each="" taxi="" served="">"today><><><">">
return
0;
}