Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <fstream>
- #include <string.h>
- #include <conio.h>
- using namespace std;
- class Library
- {
- public:
- char bookname[100], auname[50], sc1[50];
- int q, B, p;
- Lib()
- {
- strcpy(bookname, "No Book Name");
- strcpy(auname, "No Author Name");
- strcpy(sc1, "No Publication Year");
- q = 0;
- B = 0;
- p = 0;
- }
- void get();
- void pass();
- void librarian();
- void password();
- void getdata();
- void show(int);
- void modify();
- void search(int);
- int branch(int);
- };
- void Library::getdata()
- {
- int i;
- fflush(stdin);
- cout << "\n\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t PLEASE FILL UP THE\t\t<><>";
- cout << "\n\t\t<><>\t\tFORMS TO ADD\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t \t\t\t\t ";
- cout << "\n\t\t\tEnter a Book's Name : ";
- cin.getline(bookname, 100);
- for (i = 0; bookname[i] != '\0'; i++)
- {
- if (bookname[i] >= 'a' && bookname[i] <= 'z')
- bookname[i] -= 32;
- }
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t \t\t\t\t ";
- cout << "\n\t\t\tEnter a Author's Name : ";
- cin.getline(auname, 50);
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t \t\t\t\t ";
- cout << "\n\t\t\tEnter a Publication Year : ";
- cin.getline(sc1, 50);
- }
- void Library::show(int i)
- {
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Book Name : " << bookname << "\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Book's Author Name : " << auname << " <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Book's Publication Year : " << sc1 << " <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- }
- void Library::modify()
- {
- char ch, st1[100];
- int i = 0, b, cont = 0;
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t- Please choose one option-\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |1| Add New Book\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |2| Delete A Book\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |3| Go back\t\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\tEnter your choice : ";
- cin >> i;
- if (i == 1)
- {
- system("cls");
- B = branch(2);
- system("cls");
- getdata();
- ofstream outf("Booksdata.txt", ios::app | ios::binary);
- outf.write((char *)this, sizeof(*this));
- outf.close();
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Book added Successfully.\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- }
- else if (i == 2)
- {
- system("cls");
- b = branch(2);
- ifstream intf1("Booksdata.txt", ios::binary);
- if (!intf1)
- {
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t File Not Found\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Press any key to continue.....";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- intf1.close();
- system("cls");
- librarian();
- }
- intf1.close();
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Please choose one option\t<><>";
- cout << "\n\t\t<><>\t\tfor Deletion\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |1| By Book Name\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t Enter the number of your choice : ";
- cin >> i;
- fflush(stdin);
- if (i == 1)
- {
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\tEnter Book Name : ";
- cin.getline(st1, 100);
- ofstream outf("temp.txt", ios::app | ios::binary);
- ifstream intf("Booksdata.txt", ios::binary);
- intf.read((char *)this, sizeof(*this));
- while (!intf.eof())
- {
- for (i = 0; b == B && bookname[i] != '\0' && st1[i] != '\0' && (st1[i] == bookname[i] || st1[i] == bookname[i] + 32); i++)
- ;
- if (bookname[i] == '\0' && st1[i] == '\0')
- {
- cont++;
- intf.read((char *)this, sizeof(*this));
- }
- else
- {
- outf.write((char *)this, sizeof(*this));
- intf.read((char *)this, sizeof(*this));
- }
- }
- intf.close();
- outf.close();
- remove("Booksdata.txt");
- rename("temp.txt", "Booksdata.txt");
- }
- else
- {
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Incorrect Input.....\n";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Press any key to continue.....";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- modify();
- }
- if (cont == 0)
- {
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Book Not Found.\n";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Press any key to continue.....";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- modify();
- }
- else
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Deletion Successful.\n";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- }
- else if (i == 3)
- {
- system("cls");
- librarian();
- }
- else
- {
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Wrong Input.\n";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Press any key to continue.....";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- modify();
- }
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t\t Press any key to continue.....";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- librarian();
- }
- int Library::branch(int x)
- {
- int i;
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t- Please Choose one Branch - <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t|1| Major Subjects\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t|2| Minors Subject\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t|3| Go to Main Menu\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Select [ 1 - 2 - 3 ]\t\t<><>";
- cout << "\n\t\t<><> Enter your choice number : \t<><>";
- cout << "\n\t\t\t\t ";
- cin >> i;
- switch (i)
- {
- case 1:
- return 1;
- break;
- case 2:
- return 2;
- break;
- case 3:
- system("cls");
- if (x == 1)
- librarian();
- default:
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t<><>\t PLEASE ENTER CORRECT OPTION\t <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- branch(x);
- }
- }
- void Library::search(int x)
- {
- int i,b,cont=0;
- char ch[100];
- system("cls");
- b=branch(x);
- ifstream intf("Booksdata.txt",ios::binary);
- if(!intf)
- {
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Book Not Found.\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Press any key to continue.....\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- if(x==1)
- librarian();
- }
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\tPlease Choose one option \t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |1| Search By Name\t<><>";
- cout << "\n\t\t<><> Enter Your Choice : \t<><>";
- cout << "\n\t\t\t\t\t";
- cin>>i;
- fflush(stdin);
- intf.read((char*)this,sizeof(*this));
- if(i==1)
- {
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout<<"\n\t\tEnter Book's Name : ";
- cin.getline(ch,100);
- system("cls");
- while(!intf.eof())
- {
- for(i=0;b==B&&q!=0&&bookname[i]!='\0'&&ch[i]!='\0'&&(ch[i]==bookname[i]||ch[i]==bookname[i]+32);i++);
- if(bookname[i]=='\0'&&ch[i]=='\0')
- {
- cout<<"\n\t\tBook Found :-\n";
- show(x);
- cont++;
- break;
- }
- intf.read((char*)this,sizeof(*this));
- }
- }
- else
- {
- cont++;
- cout<<"\n\t\tPlease enter correct option";
- getch();
- system("cls");
- search(x);
- }
- intf.close();
- if(cont==0)
- cout<<"\n\t\tThis Book is not available \n";
- cout<<"\n\t\tPress any key to continue.....";
- getch();
- system("cls");
- if(x==1)
- librarian();
- }
- void Library::get()
- {
- int i;
- cout << "\n\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\tMINI LIBRARY INVENTORY SYSTEM\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Project in Computer\t <><>";
- cout << "\n\t\t<><>\t Programming 2(CCS1203)\t<><>";
- cout << "\n\t\t<><>\t Mr. Paul Cedrix Moreno\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t\tPrepared by:\t <><>";
- cout << "\n\t\t<><>\t Quiachon, Mildred Joy P.\t<><>";
- cout << "\n\t\t<><>\t 1st Year - BSIT 1207\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t- PLEASE CHOOSE ONE TO LOGIN - <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |1| Librarian Module\t <><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t |2| Close the Application\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\t Select [ 1 - 2 ]\t\t<><>";
- cout << "\n\t\t<><> Enter your choice number : \t<><>";
- cout << "\n\t\t\t\t ";
- cin>>i;
- if(i==1)
- {
- system("cls");
- pass();
- }
- else if(i==2)
- {
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\tTHANK YOU FOR USING M.L.I.S <><>";
- cout << "\n\t\t<><>\t\t Prepared by:\t\t<><>";
- cout << "\n\t\t<><>\t Quiachon, Mildred Joy P.\t<><>";
- cout << "\n\t\t<><>\t 1st Year - BSIT 1207\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- exit(0);
- }
- else
- {
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\tPLEASE ENTER CORRECT OPTION\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- get();
- }
- }
- void Library::pass()
- {
- int i = 0;
- char ch, st[21], ch1[21] = {"pass"};
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><> Please enter a Librarian\t<><>";
- cout << "\n\t\t<><>\t Password first\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t Enter Password : ";
- while (1)
- {
- ch = getch();
- if (ch == 13)
- {
- st[i] = '\0';
- break;
- }
- else if (ch == 8 && i > 0)
- {
- i--;
- cout << "\b \b";
- }
- else
- {
- cout << "*";
- st[i] = ch;
- i++;
- }
- }
- ifstream inf("password.txt");
- inf >> ch1;
- inf.close();
- for (i = 0; st[i] == ch1[i] && st[i] != '\0' && ch1[i] != '\0'; i++)
- ;
- if (st[i] == '\0' && ch1[i] == '\0')
- {
- system("cls");
- librarian();
- }
- else
- {
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t WRONG PASSWORD, TRY AGAIN.\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- pass();
- }
- }
- void Library::librarian()
- {
- int i;
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t WELCOME LIBRARIAN\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t- Please Choose One Option -\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t |1| Modify Book\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t |2| Go to Main Menu\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t |3| Close Application\t\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t |4| Search Book\t\t<><>";
- cout << "\n\t\t<><>\t Select [ 1 - 2 - 3 - 4]\t<><>";
- cout << "\n\t\t<><> Enter your choice number : \t<><>";
- cout << "\n\t\t\t\t ";
- cin >> i;
- switch (i)
- {
- case 1:
- modify();
- break;
- case 2:
- system("cls");
- get();
- break;
- case 3:
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><>\tTHANK YOU FOR USING M.L.I.S <><>";
- cout << "\n\t\t<><>\t\t Prepared by:\t\t<><>";
- cout << "\n\t\t<><>\t Quiachon, Mildred Joy P.\t<><>";
- cout << "\n\t\t<><>\t 1st Year - BSIT 1207\t<><>";
- cout << "\n\t\t<><>\t\t\t\t <><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- exit(0);
- break;
- case 4:
- system("cls");
- search(2);
- break;
- default:
- system("cls");
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><>\t PLEASE ENTER CORRECT OPTION\t<><>";
- cout << "\n\t\t<><>\t\t\t\t\t<><>";
- cout << "\n\t\t<><><><><><><><><><><><><><><><><><><><><><>";
- getch();
- system("cls");
- librarian();
- }
- }
- int main()
- {
- Library obj;
- obj.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement