1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
int main()
{
Students b1;
Books b2;
char ch;
string temp1, temp2, temp3, temp4;
while(1)
{system("cls");
cout<<endl;
cout<<"Welcome"<<endl;
cout<<"----------------"<<endl;
cout<<"a.) Add a Book "<<endl;
cout<<"b.) Delete a Book "<<endl;
cout<<"c.) Display the Books "<<endl;
cout<<"d.) Add a student "<<endl;
cout<<"e.) Delete a student "<<endl;
cout<<"f.) Display the students list "<<endl;
cout<<"g.) Exit "<<endl;
cout<<" ENTER YOUR CHOICE ";
cin>>ch;
if (ch=='a'){
cout<<"Enter the Title of the book ";cout<<" ";
std::getline(cin, temp1);std::cin.ignore();
cout<<"Enter the author of the book ";cout<<" ";
std::getline(cin, temp2);std::cin.ignore();
cout<<"Enter the ISBN of the book ";cout<<" ";
std::getline(cin, temp3);std::cin.ignore();
cout<<"Enter the quantity of the book ";cout<<" ";
std::getline(cin, temp4);std::cin.ignore();
b2.addbooks(temp1,temp2,temp3,temp4);
cout<<"The book was succesfully added!\n\n";
ofstream book("book.txt", ios::app);
if (!book) {
cerr << "File could not be opened." << endl;
exit(1);
}book << temp3<<' '<<temp1<<' '<<' '<<temp2<<' '<<temp4<< '\n';
system("pause");
main();
}
else if (ch=='b'){cout<<"Enter the title of the book to be deleted: ";
std::getline(cin, temp1);cin.ignore();
cout<<"Enter the author of the book: ";
std::getline(cin, temp2);cin.ignore();
cout<<"Enter the ISBN of the book: ";
std::getline(cin, temp3);cin.ignore();
cout<<"Enter the quantity of the book: ";
std::getline(cin, temp4);cin.ignore();
b2.removebooks(temp1,temp2,temp3,temp4);
}
else if (ch=='c'){cout<<"The list contains : ";
cout<<b2;}
else if (ch=='d'){ cout<<"Enter the name of the student: ";
std::getline(cin, temp1);cin.ignore();
cout<<"Enter the ID number: ";
std::getline(cin, temp2);cin.ignore();
cout<<"Enter the year of the student: ";
std::getline(cin, temp3);cin.ignore();
cout<<"Enter the no. of books borrowed: ";
std::getline(cin, temp4);cin.ignore();
b1.addstudent(temp1,temp2,temp3,temp4);
cout<<"Student was succesfully added!\n\n";
system("pause");}
else if (ch== 'e'){cout<<"Enter the name of the student to be deleted: ";
std::getline(cin, temp1);cin.ignore();
cout<<"Enter the ID number: ";
std::getline(cin, temp2);cin.ignore();
cout<<"Enter the year of the student: ";
std::getline(cin, temp3);cin.ignore();
cout<<"Enter the borrowed books: ";
std::getline(cin, temp4);cin.ignore();
b1.removestudent(temp1,temp2,temp3,temp4);
}
else if (ch=='f'){ cout<<"The list of the student contains: ";
cout<<b1;
}
else if (ch =='g'){
return 0;
}
else system("cls");
}
}
|