Please suggest some improvements for this simple OOP database.
code
Code:
#include<iostream>
#include<string>
using namespace std;
class data
{
int roll;
string name;
bool condition;
public:
data(){condition=0;}
data(int a,string b){roll=a; name=b;}
~data(){}
void setroll(int a){roll=a;}
void setname(string a){name=a;}
int getroll(){return roll;}
string getname(){return name;}
void getdetail()
{
if(condition==0)
cout<<"The data is not entered for this roll no. "<<endl;
else
cout<<"The roll no. of student is "<<roll<<". And name of student is "<<name<<endl;
}
void setdetail(){cout<<"Enter name of student "; cin>>name;}
void setflag(){condition=1;}
};
int main()
{
data student[100];
string terminator;
cout<<"\t\tWEL COME TO STUDENT DATABASE DESIGNED BY ALI SAHU"<<endl<<endl;
cout<<"\t\tPlease enter command 'enter' to enter data"<<endl;
cout<<"\t\tPlease enter command 'edit' to edit data"<<endl;
cout<<"\t\tPlease enter command 'view' to view data "<<endl;
cout<<"\t\tTo terminate program enter exit command"<<endl;
cout<<endl;
while (terminator!="exit")
{ cout<<"command>>";
cin>>terminator;
if(terminator=="exit")
cout<<"Terminating"<<endl;
else if(terminator=="enter"||terminator=="edit")
{
int a;
cout<<"Enter the roll no to enter or edit the student data "; cin>>a;
student[a-1].setdetail();
student[a-1].setroll(a);
student[a-1].setflag();
cout<<"The data is stored"<<endl;
}
else if(terminator=="view")
{
int a;
cout<<"Enter roll no to view result: "; cin>>a;
student[a-1].getdetail();
}
else
cout<<"Wrong command please try again"<<endl;
}
return 0;
}