#define NOMINMAX // NOMINMAX constant used in order to use the numeric values in the C++ std library // #include #include #include #include #include #include "login.h" #include "read.h" #include "search.h" #include "create.h" #include "edit.h" #include "view.h" #include "create.h" #include "exit.h" #include "options.h" #include "include.h" #include "menu.h" // using namespace std; //Class for Login class Login { private: int login(); }; //Class for Menu class Menu { public: void printMenu(), options(int ans); private: int ans; }; //Class for Library class library { private: int main(); }; //Class for Viewing the File class View { public: void viewFile(); }; //Class for Viewing the Options class Options { public: void options(int ans); }; //Class for Creating the File class Create { public: void createFile(); }; //Class for Reading the File class Read { public: void readFile(); }; //Class for Exiting class Exit { public: void exitScreen(); }; //Class for Editing a File class Edit { public: void editFile(); }; //Class for Searching a File class Search { public: void searchFile(); }; //Function for Login int login() { string username; //This is a string variable calld username(string variables r 4 saving text) string password; //this is a string variable calld password int tries = 3; //This is a integer variable tries.Here we save the number of tries to ques the //username and password(integer = 4 saving numbers not decimal numbers).And we set it on 0 while(tries) { cout << "Username: "; //displays Username: on the screen cin >> username; //Saves the input in the variable username cout << "Password: "; cin >> password; if(username == "admin" && password == "password") //if username is the same as Admin and password is the //If password is correct then: { system("cls"); //clear screen cout << "Welcome to the Library System! \n"; cout << "_______________________________\n"; printMenu(); system("pause"); return 0; } else { tries--; //tries + 1 } } return -1; }; void printMenu(), options(int ans); void printMenu() { int ans; do { cout << "\nPlease choose from the following options:\n\n"; cout << "-------------------------------------------\n\n"; cout << "1: Search for a file\n\n"; cout << "2: Create a new file\n\n"; cout << "3: View entire catalogue\n\n"; cout << "4: Exit from the program\n\n"; cout << "-------------------------------------------\n\n"; cin >> ans; cin.ignore(80,'\n'); options(ans); } while(ans!=4); }; int main() { int success=0; login(); if (success = 0) { cout << "Invalid Username and Password!\n"; return -1; } else { return 0; } }; void viewFile() { cout << "\nFull catalogue: \n"; readFile(); }; void options(int ans) { switch (ans) { case 1: searchFile(); break; case 2: createFile(); break; case 3: viewFile(); break; case 4: exitScreen(); break; default: cout << "Please select an available option\n\n"; break; } }; void createFile() { char author[30], title[124], fileName[40]; int id; cout << "\nEnter the Author: "; cin >> author; cout << "Enter the book title: "; cin >> title; cout << "Enter I.D.: "; cin >> id; ofstream ID( "id.txt", ios::app ); ID << "\n" << id; cout << "\nEnter the name of the file you want to create: "; cin >> fileName; ofstream Book(fileName, ios::out); Book << "Author: " << author << "\n" << "Title: " << title << "\n" << "I.D. Number: " << id; }; void readFile() { string line; ifstream myfile ("id.txt"); if (myfile.is_open()) { while (! myfile.eof() ) { getline (myfile,line); cout << line << endl; } myfile.close(); } else cout << "Unable to open file"; }; void exitScreen() { std::cout << "\n\nPress Enter to exit..."; std::cin.clear(); std::cin.sync(); std::cin.ignore( std::numeric_limits ::max(), '\n' ); }; void editFile() { cout << "\nThe file contains: \n"; readFile(); char buffer[1024]; ofstream outonly; outonly.open( "id.txt", ios::app ); cout << "\nPlease add your new data: \n"; cout << ", press RETURN on an empty "; cout << "line to quit.\n\n"; do { cin.getline(buffer, 1023); outonly << buffer << endl; } while(*buffer); }; void searchFile() { char nam[40]; cout << "\nPlease enter the file name you are looking for\n\n"; cin >> nam; Sleep(2500); string line; ifstream myfile (nam); if (myfile.is_open()) { cout << "\nThe file contains\n\n"; while (! myfile.eof() ) { getline (myfile,line); cout << line << endl; } myfile.close(); } else cout << "\n\nThis file does not exist you will have to create a new one\n\n"; cout << "\n\n"; system("pause"); cout << "\n"; };