You are on page 1of 5

LAB TASK

Shahryar Qasim
Section: “A” 2nd Semester
21011556-041
REPORT TITLE

Library Management System:


#include<iostream>
#include<conio.h>
#include<string.h>
#include<process.h>
using namespace std;
class library
{
public:
virtual void get()
{

}
virtual void show()
{

}
};
class Name:public library
{
char name;
void get()
{
cout<<"\nName of the library : ";
cin>>name;

}
};
class schedule:public library
{
int timing;
void get()
{
cout<<"\n Schedule of the library = ";
cin>>timing;
}
};
class books
{
public:
int stock;
char author[20], publisher[20];
char bookname[20];
float price;
PAGE 2
REPORT TITLE
void loadbooks();
void display();
};

void books::loadbooks() //scope resolution operator to use public function from book
class
{
cout<<"\nName of the book you want :";
cin>>bookname;
cout<<"\nWritten by :";
cin>>author;
cout<<"\nPublished by :";
cin>>publisher;
cout<<"\nPrice of the book :";
cin>>price;
cout<<"\nStock present in the library :";
cin>>stock;
cout<<"\n******************\n";
}

void books::display() //scope resolution operator to use public function from book
class
{
cout<<"\nName of the Book:"<<bookname;
cout<<"\nAuthor of the Book:"<<author;
cout<<"\nPublisher of the Book:"<<publisher;
cout<<"\nPrice of the Book:"<<price;
cout<<"\nStock Present:"<<stock;
cout<<"\n******************\n";
}

int main()
{
library*ptr[2];
ptr[0]=new Name;
ptr[1]=new schedule;
for(int i=0;i<=2;i++)
{
ptr[i]->get();
ptr[i]->show();
cout<<endl;
}

books ob[10];
int ch, n;

do
{
PAGE 3
REPORT TITLE
cout<<"\n*******MENUE******\n";
cout<<"\n******************\n";
cout<<"\n1.Load Books\n2.Display\n3.Search\n4.Exit\n";
cout<<"\n\nEnter your Choice:";
cin>>ch;
switch(ch)
{
case 1: cout<<"Enter Number of Books:";
cin>>n;
for(int i=0;i<n;i++)
ob[i].loadbooks();
break;
case 2:
for(int i=0;i<n;i++)
ob[i].display();
break;
case 3:

char bname[20], aname[20];


cout<<"Enter name of the Book:";
cin>>bname;
cout<<"Enter name of the Author:";
cin>>aname;
for(int i=0;i<n;i++)
{
if(strcmp(bname, ob[i].bookname)==0&&strcmp(aname,ob[i].author)) //strcmp used
to compare two strings
//used sting.h file for strcmp
{
cout<<"\nBook Present\n\n";
cout<<"\nName of the Book:"<<ob[i].bookname;
cout<<"\nAuthor of the Book:"<<ob[i].author;
cout<<"\nPublisher of the Book:"<<ob[i].publisher;
cout<<"\nPrice of the Book:"<<ob[i].price;
cout<<"\nStock Present:"<<ob[i].stock;
cout<<"\n-------------\n";
break;
}
else
{
cout<<"Sorry Book Is Not Present!!!";
break;
}
}
break;
default: cout<<"Please Enter a valid choice!!";
case 4: exit(1);
}
PAGE 4
REPORT TITLE
}while(1);
}

PAGE 5

You might also like