In: Computer Science
Store owners need an application that allows them to determine which books and movies they have rented. The application should save the general information of the borrowed items. The information of the book is: title, classification (genre), the number of pages and the author. The information in the second article is: title, duration, director and type of film. Do the necessary classes to represent the two articles. Each object in the classes must provide the following services: to show ask obtain change compare if two borrowed items are equal
1.All / part 2.Overloading of operators 3.Builder 4.Copy constructor 5.Destroyer 6. Dynamic memory
C++
//C++ CODE TO COPY FOR BOOK RECORD (ARTICLE#1)//
//used header files
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
//book class will keep all book record
class Book
{
public:
string title;
string genre;
int no_of_pages;
string author;
Book *link;
void set_id(int no_of_pages)
{
this->no_of_pages =
no_of_pages;
}
void set_title(string title)
{
this->title = title;
}
void set_genre(string genre)
{
this->genre = genre;
}
void set_author(string author)
{
this->author = author;
}
int get_no_of_pages()
{
return no_of_pages;
}
string get_title()
{
return title;
}
string get_genre()
{
return genre;
}
string get_author()
{
return author;
}
};
Book *head = NULL;
void add()
{
system("cls");
string name;
string qualification;
Book *p = new Book();
cout << "Enter Book no_of_pages: ";
cin >> p->no_of_pages;
cout << "\nEnter Book Title: ";
cin >> p->title;
cout << "\nEnter Book Genre: ";
cin >> p->genre;
cout << "\nEnter Author Name: ";
cin >> p->author;
p->link = NULL;
if (head == NULL)
head = p;
else
{
Book *a = head;
while (a->link != NULL)
{
a =
a->link;
}
a->link = p;
}
}
void Remove()
{
int n = 0;
int n1 = 0;
int no_of_pages;
cout << "\nEnter no_of_pages to Remove Book
Record: ";
cin >> no_of_pages;
Book *p = head;
Book *p1 = head;
if (p->link == NULL)
{
if (p->get_no_of_pages() ==
no_of_pages)
delete p;
head = NULL;
}
else{
while (p != NULL)
{
if
(p1->get_no_of_pages() == no_of_pages)
{
goto no;
}
if
(n<n1)
{
p = p->link;
}
p1 =
p1->link;
n1++;
}
no:
Book *temp = p1->link;
delete p1;
p->link = temp;
}
}
void display()
{
int n = 0;
Book *p = head;
if (head == NULL)
cout << "\nList is
Empty!";
while (p != NULL)
{
cout <<
p->get_no_of_pages() << " ";
cout << p->get_title()
<< " ";
cout << p->get_genre()
<< " ";
cout << p->get_author()
<< " ";
cout << endl;
p = p->link;
}
}
void search()
{
int check = 0;
string name;
cout << "\nEnter Book title to Search From List:
";
cin >> name;
Book *p = head;
while (p != NULL)
{
if
(p->get_title().compare(name)==0)
{
check++;
goto show;
}
p = p->link;
}
show:
if (check == 0)
cout << "\nOpps Record Not
Found!";
else
cout << "Recorde Found!\nNo
of pages: " << p->get_no_of_pages() << "\nTitle: "
<< p->get_title()
<< "\nGenre: " <<
p->get_genre() << "\nAuthor Name: " <<
p->get_author();
}
void count()
{
Book *p = head;
int count = 0;
while (p != NULL)
{
count++;
p = p->link;
}
cout << "\nCounted Data Items: " <<
count;
}
void update()
{
int choice;
string namee;
string exp;
string qua;
int check = 0;
cout << "\nEnter Book Title to Perform Updation:
";
cin >> namee;
Book *p = head;
while (p != NULL)
{
if
(p->get_title().compare(namee)==0)
{
check++;
goto
update;
}
p = p->link;
}
update:
if (check == 0)
cout << "Opps Book Could Not
Found!";
else
{
again:
system("cls");
cout <<
"\n1.Update_Title\n2.Update_Genre\n3.Update_Author\n4.Done\nSelect
Your Choice: ";
cin >> choice;
if (choice == 1)
{
cout <<
"\nEnter Existing Title: ";
cin >>
namee;
if
(p->get_title().compare(namee)==0)
{
cout << "\nEnter New Name: ";
cin >> namee;
p->set_title(namee);
cout << "\nTitle Entered
Successfuly!";
_getche();
goto again;
}
else
{
cout << "\nEntered Title Does Not
Match!";
goto again;
}
}
else if (choice == 2)
{
cout <<
"\nEnter New Genre: ";
cin >>
exp;
p->set_genre(exp);
cout <<
"\nNew Genre Entered Successfuly!";
_getche();
goto
again;
}
else if (choice == 3)
{
cout <<
"\nEnter New Author Name: ";
cin >>
qua;
p->set_author(qua);
cout <<
"\nNew Author Name Entered Successfuly!";
_getche();
goto
again;
}
else if (choice == 4)
{
return;
}
}
}
int main()
{
menue:
system("cls");
int choice = 0;
cout << "\t\t\tWELCOME TO BOOK RECORD MANAGEMENT
SYSTEM TOOL\n\n1.Add_Book Record"
<<"\n2.Remove_Book Record\n3.Display_Book
Record\n4.Search_Book Record\n5.Count_borrowed Books\n6.Update_Book
Information"
<<"\n\n\nSelect Your Choice : ";
cin >> choice;
switch (choice)
{
case 1:
add();
system("cls");
cout << "\nRecorde Added
Successfuly!" << endl;
cout <<
"\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
system("cls");
goto
menue;
}
else
return 0;
break;
case 2:
Remove();
system("cls");
cout << "\nRecorde Removed
Successfuly!" << endl;
cout <<
"\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
system("cls");
goto
menue;
}
else
return 0;
break;
case 3:
system("cls");
display();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 4:
system("cls");
search();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 5:
system("cls");
count();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 6:
system("cls");
update();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
default:
cout << "\nInvalid
Input!";
}
}
//OUTPUT//
//--------------------------------------------------------------------------------------------------------------------------------------------------//
//C++ CODE TO COPY FOR FILM RECORD (ARTICLE#2)//
//used header files
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
//Film class will keep all Film record
class Film
{
public:
string title;
int duration;
string director;
string type_of_film;
Film *link;
void set_duration(int duration)
{
this->duration = duration;
}
void set_title(string title)
{
this->title = title;
}
void set_type_of_film(string type_of_film)
{
this->type_of_film =
type_of_film;
}
void set_director(string director)
{
this->director = director;
}
int get_duration()
{
return duration;
}
string get_title()
{
return title;
}
string get_type_of_film()
{
return type_of_film;
}
string get_director()
{
return director;
}
};
Film *head = NULL;
void add()
{
system("cls");
string name;
string qualification;
Film *p = new Film();
cout << "Enter Film duration: ";
cin >> p->duration;
cout << "\nEnter Film Title: ";
cin >> p->title;
cout << "\nEnter Film type_of_film: ";
cin >> p->type_of_film;
cout << "\nEnter director Name: ";
cin >> p->director;
p->link = NULL;
if (head == NULL)
head = p;
else
{
Film *a = head;
while (a->link != NULL)
{
a =
a->link;
}
a->link = p;
}
}
void Remove()
{
int n = 0;
int n1 = 0;
int duration;
cout << "\nEnter duration to Remove Film Record:
";
cin >> duration;
Film *p = head;
Film *p1 = head;
if (p->link == NULL)
{
if (p->get_duration() ==
duration)
delete p;
head = NULL;
}
else{
while (p != NULL)
{
if
(p1->get_duration() == duration)
{
goto no;
}
if
(n<n1)
{
p = p->link;
}
p1 =
p1->link;
n1++;
}
no:
Film *temp = p1->link;
delete p1;
p->link = temp;
}
}
void display()
{
int n = 0;
Film *p = head;
if (head == NULL)
cout << "\nList is
Empty!";
while (p != NULL)
{
cout <<
p->get_duration() << " ";
cout << p->get_title()
<< " ";
cout <<
p->get_type_of_film() << " ";
cout << p->get_director()
<< " ";
cout << endl;
p = p->link;
}
}
void search()
{
int check = 0;
string name;
cout << "\nEnter Film title to Search From List:
";
cin >> name;
Film *p = head;
while (p != NULL)
{
if
(p->get_title().compare(name)==0)
{
check++;
goto show;
}
p = p->link;
}
show:
if (check == 0)
cout << "\nOpps Record Not
Found!";
else
cout << "Recorde Found!\nNo
of pages: " << p->get_duration() << "\nTitle: "
<< p->get_title()
<< "\ntype_of_film: "
<< p->get_type_of_film() << "\ndirector Name: "
<< p->get_director();
}
void count()
{
Film *p = head;
int count = 0;
while (p != NULL)
{
count++;
p = p->link;
}
cout << "\nCounted Data Items: " <<
count;
}
void update()
{
int choice;
string namee;
string exp;
string qua;
int check = 0;
cout << "\nEnter Film Title to Perform Updation:
";
cin >> namee;
Film *p = head;
while (p != NULL)
{
if
(p->get_title().compare(namee)==0)
{
check++;
goto
update;
}
p = p->link;
}
update:
if (check == 0)
cout << "Opps Film Could Not
Found!";
else
{
again:
system("cls");
cout <<
"\n1.Update_Title\n2.Update_type_of_film\n3.Update_director\n4.Done\nSelect
Your Choice: ";
cin >> choice;
if (choice == 1)
{
cout <<
"\nEnter Existing Title: ";
cin >>
namee;
if
(p->get_title().compare(namee)==0)
{
cout << "\nEnter New Name: ";
cin >> namee;
p->set_title(namee);
cout << "\nTitle Entered
Successfuly!";
_getche();
goto again;
}
else
{
cout << "\nEntered Title Does Not
Match!";
goto again;
}
}
else if (choice == 2)
{
cout <<
"\nEnter New type_of_film: ";
cin >>
exp;
p->set_type_of_film(exp);
cout <<
"\nNew type_of_film Entered Successfuly!";
_getche();
goto
again;
}
else if (choice == 3)
{
cout <<
"\nEnter New director Name: ";
cin >>
qua;
p->set_director(qua);
cout <<
"\nNew director Name Entered Successfuly!";
_getche();
goto
again;
}
else if (choice == 4)
{
return;
}
}
}
int main()
{
menue:
system("cls");
int choice = 0;
cout << "\t\t\tWELCOME TO Film RECORD MANAGEMENT
SYSTEM TOOL\n\n1.Add_Film Record"
<<"\n2.Remove_Film Record\n3.Display_Film
Record\n4.Search_Film Record\n5.Count_borrowed Films\n6.Update_Film
Information"
<<"\n\n\nSelect Your Choice : ";
cin >> choice;
switch (choice)
{
case 1:
add();
system("cls");
cout << "\nRecorde Added
Successfuly!" << endl;
cout <<
"\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
system("cls");
goto
menue;
}
else
return 0;
break;
case 2:
Remove();
system("cls");
cout << "\nRecorde Removed
Successfuly!" << endl;
cout <<
"\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
system("cls");
goto
menue;
}
else
return 0;
break;
case 3:
system("cls");
display();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 4:
system("cls");
search();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 5:
system("cls");
count();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
case 6:
system("cls");
update();
cout <<
"\n\n1.Menue\n0.Exit\nSelect Your Choice: ";
cin >> choice;
if (choice == 1)
{
goto
menue;
system("cls");
goto
menue;
}
else
return 0;
break;
default:
cout << "\nInvalid
Input!";
}
}
Comment down for any queries!
Please give a thumbs up if you are satisfied and helped with the
answer :)