#include <iostream>
#include <string>
usingnamespace std;
class Owner
{
protected:
string department, school, contact_no, status, address;
string reg_no, type, colour, brand;
string name;
double ID_no;
public:
void setDetail();
void getDetail();
};
class VIS:public Owner
{
Owner list[20]; //This is the part that I ask
public:
void addDetail();
void searchDetail();
};
////global variables declared
int x=0,i=0;
double ID[20];
string n[20];
string sta[20];
string dep[20];
string reg[20];
string scn[20];
string typ[20];
string brd[20];
void Owner::setDetail()
{
cout<<"********************************************************************"<<endl<<endl;
cout<<"Please enter name :";
cin>>name;
cout<<"Please enter ID number :";
cin>>ID_no;
cout<<"Please enter status :";
cin>>status;
cout<<"Please enter department :";
cin>>department;
cout<<"Please enter school :";
cin>>school;
cout<<"Please enter contact number :";
cin>>contact_no;
cout<<"Please enter address :";
cin>>address;
cout<<endl;
cout<<"Please insert vehicle registration number:";
cin>>reg_no;
cout<<"Please insert type of vehicle :";
cin>>type;
cout<<"Please insert colour of vehicle :";
cin>>colour;
cout<<"Please insert brand of vehicle :";
cin>>brand;
cout<<"********************************************************************"<<endl<<endl;
ID[i]=ID_no;
n[i]=name;
sta[i]=status;
dep[i]=department;
reg[i]=reg_no;
scn[i]=school;
typ[i]=type;
brd[i]=brand;
}
void Owner::getDetail()
{
cout<<"********************************************************************"<<endl<<endl;
cout<<"Name : "<<name<<endl;
cout<<"ID Number : "<<ID_no<<endl;
cout<<"Status : "<<status<<endl;
cout<<"Department : "<<department<<endl;
cout<<"School : "<<school<<endl;
cout<<"Contact Number : "<<contact_no<<endl;
cout<<"Address : "<<address<<endl<<endl;
cout<<"Vehicle registration number : "<<reg_no<<endl;
cout<<"Type of vehicle : "<<type<<endl;
cout<<"Colour of vehicle : "<<colour<<endl;
cout<<"Brand of vehicle : "<<brand<<endl<<endl;
cout<<"********************************************************************"<<endl<<endl;
}
void VIS::addDetail()
{
char redo;
do
{ system("cls");
x++;
list[i].setDetail();
i++;
system("cls");
cout<<"\nThe following owner information has been added to the system:"<<endl;
for(int i=0; i<x; i++)
{ list[i].getDetail(); }
cout<<"Do you wont to add another owner"<<endl;
cin>>redo;
}while((redo=='y'||redo=='Y'));
}
void VIS::searchDetail()
{
int c;
char redo1;
string name;
do{
system("cls");
cout<<"\t\t*****SEARCH MENU*****"<<endl<<endl;
cout<<"\t1.Name "<<endl;
cout<<"\t2.ID Number"<<endl;
cout<<"\t3.Status"<<endl;
cout<<"\t4.Department "<<endl;
cout<<"\t5.School "<<endl;
cout<<"\t6.Vehicle Registration Number"<<endl;
cout<<"\t7.Type of Vehicle "<<endl;
cout<<"\t8.Brand of Vehicle "<<endl<<endl;
cout<<"\t\t*********************"<<endl<<endl;
cout<<"Search based on :"<<endl;
cin>>c;
switch(c)
{ case 1: cout<<"Please enter the name of owner : ";
cin>>name;
for(int i=0; i<x; i++)
{ if (n[i]==name)
{ cout<<"Matching="<< name<<endl;
list[i].getDetail();
}
}
break;
case 2: cout<<"Please enter the ID of owner : ";
cin>>ID_no;
for(int i=0; i<x; i++)
{ if (ID[i]==ID_no)
{ cout<<"Matching="<< ID_no<<endl;;
list[i].getDetail();
}
}
break;
case 3: cout<<"Please enter the status of owner : ";
cin>>status;
for(int i=0; i<x; i++)
{ if (sta[i]==status)
{ cout<<"Matching="<< status<<endl;;
list[i].getDetail();
}
}
break;
case 4: cout<<"Please enter the department of owner : ";
cin>>department;
for(int i=0; i<x; i++)
{ if (dep[i]==department)
{ cout<<"Matching="<<department<<endl;
list[i].getDetail();
}
}
break;
case 5: cout<<"Please enter the school of owner : ";
cin>>school;
for(int i=0; i<x; i++)
{ if (scn[i]==school)
{ cout<<"Matching="<<school<<endl;
list[i].getDetail();
}
}
break;
case 6: cout<<"Please enter the vehicle registration number of owner : ";
cin>>reg_no;
for(int i=0; i<x; i++)
{ if (reg[i]==reg_no)
{ cout<<"Matching="<<reg_no<<endl;
list[i].getDetail();
}
}
break;
case 7: cout<<"Please enter the type of owner vehicle : ";
cin>>type;
for(int i=0; i<x; i++)
{ if (typ[i]==type)
{ cout<<"Matching="<< type<<endl;
list[i].getDetail();
}
}
break;
case 8: cout<<"Please enter the brand of owner vehicle : ";
cin>>brand;
for(int i=0; i<x; i++)
{ if (brd[i]==brand)
{ cout<<"Matching="<< brand<<endl;
list[i].getDetail();
}
}
break;
default: cout << "Wrong Option....Please Reenter Your Choice: "<<endl;
}
cout<<endl<<endl;
cout<<"Do you want to Search any other field (y/n)?"<<endl;
cin>>redo1;
}while(redo1=='y'||redo1=='Y');
}
int main()
{
VIS info ;
int c;
char ch;
do
{
system("cls");
cout<<"\t\tWelcome to Vehicle Information Software ."<<endl;
cout<<"\t Please choose one of the following commands :"<<endl<<endl<<endl;
cout<<"\t\t 1. Add data"<<endl;
cout<<"\tChoice :";
cin>>c;
system("cls");
switch(c)
{
case 1:
cout<<"\nEnter the information of the new owner"<<endl;
info.addDetail();
break;
case 2:
info.searchDetail();
break;
}
cout<<"Do you want to continue";
cin>>ch;
}
while(ch=='y'||ch=='Y');
system("pause");
return 0;
}