In: Computer Science
C++: Write a student class for the library, which have the following:
Username, password, Maximum number of copies that a student is allowed to keep(less than 5), maximum borrow periods(less than 30 days per book), list of copy(array)
cpp and h
//Here is the class containing for the stude nt in c++
class student{
private:
string username;
string password;
int no_of_copies;
string copies[5]; //array for storing copies name borrowed by student
public :
student
{
no_of_copies=1;
}
int checkUsernamePassword(string username,string password)
{
if((this.username==username)&&(this.password==password))
{
return 1;
}
else
{
cout<<"Please Check username and password"<<endl;
}
}
void IssueBook(string bookName)
{
if(no_of_copies<5)
{
no_of_copies;
copies[no_of_copies]=bookName;
}
else
{
cout<<"Your limit exceed please return any book "<<endl;
}
}
void returnBook(string bookName)
{
for(int i=1;i<=no_of_copies;i++)
{
int j=0;
if(copies[i]==bookName)
{
cout<<"Book returned"<<endl;
j=i;
while(j<=no_of_copies)
{
copies[j]=copies[j+1];
j++;
}
}
}
}
};