Make your Own Movie Library Using C++
Program Name
Movie Library
Description
Movies are viewed by huge mass of people across the globe. There are various aspects to a movie. It includes name, genre, actor, actress, director and so on. A Hardcore movie fan may remember all those information of tons of movies but for simple fans or just viewers its tough job. And for the movie retailers its troublesome task to keep details in the record book and go through it manually to find a specified movie. So, to make this grueling task easier i’ve built up this program.
“Movie Library” targets to ease the task of storing information about movies and find any specified movie in the database effortlessly. This program provides simple interface, user friendly working environment and a great time saver. It has a built in format for input so user will just have to type in the information. User can choose to add a new movie information, search a particular movie thorough the library database or delete a movie.
The project is developed using simple yet powerful, C++ language.
Source Code
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
#include <conio.h>
#include <process.h>
#include <math.h>
#include <dos.h>
#include <graphics.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
//#####Movie Library#######
#define size 16
#define xy(z) (8*(z-1))
class movie
{
char movie_name[50];
char year[4];
char genere[10];
char budget[15];
char actress[15];
char actor[25];
char director[25];
char rating[10];
char nmovie_name[50];
public:
char *getdata(int);
int access();
void intro2();
void assign();
void deleted();
void search();
void database(int);
void putdata();
char* cus(){return movie_name;}
};
char *movie::getdata(int type)
{
char data[size],key,x=0;
do
{
key=getch();
if(key==13&&x>0)break;
else
if((key!=8&&x==13)||(key==13&&x==0))
{
sound(500);delay(100);nosound();key=0x1b;
}
else
if(isalnum(key)&&x<size-1)
{
data[x]=key;x++;
if(type==0)
cout<<("*");
else
cout<<key;
}
else
if(key==8&&x>0)
{
cout<<("%c%c%c",8,32,8);
x--;
}
else
{
sound(500);delay(100);
nosound();
}
}
while(x<size-1);
data[x]='\0';
return data;
}
void typeme(int left,int top,const char *word,int interval)
{
//Auto Type Effect
char code[2];
int length=strlen(word);
for(int i=0;i<=length;i++)
{
code[0]=word[i];
code[1]='\0';
outtextxy(left+xy((i+1)*2),top,code);
delay(interval);
}
}
void screensaver()
{
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
int color=getcolor();
setcolor(10); settextstyle(2,0,7);
outtextxy(xy(15),xy(20)," !!! WELCOME TO THE MOVIE LIBRARY !!!");
outtextxy(xy(3),xy(26),"This program provides movie informations to user");
outtextxy(xy(3),xy(30),"They can even add own collection of details.");
outtextxy(xy(3),xy(34),"Hope you'll enjoy using this! Thank You!");
setcolor(1);settextstyle(2,0,8);
outtextxy(xy(18),xy(40),"Programmed By :-");
outtextxy(xy(11),xy(44),"Xuvaz");
setcolor(color); settextstyle(0,0,1);
}
void introball()
{
//Intro Ball Animation
float xaxis=1,yaxis=0.00000,j=.8,count=.1;
float r=17;
sleep(1);
for(float k=1;k<4.05;k++)
{
for(float i=90;i<270;i+=30)
{
yaxis=cos(((i*22/7)/180))/j;
if(yaxis>0)
yaxis=-yaxis;
xaxis+=10;
setcolor(1);
setfillstyle(1,1);
circle(xaxis,yaxis*100+200,r);
floodfill(xaxis,yaxis*100+200,1);
delay(100);
setcolor(0);
setfillstyle(1,0);
circle(xaxis,yaxis*100+200,r);
floodfill(xaxis,yaxis*100+200,0);
}
sound(1000);
delay(50);
nosound();
j+=count;
count+=.1;
}
}
int movie::access()
{
delay(1000);
movie code;
int access=0;
loop:clearviewport();
setcolor(1);settextstyle(0,0,4);outtextxy(xy(16),getmaxy()/2-100,"Enter Password");
rectangle(getmaxx()/2-140,getmaxy()/2-20,getmaxx()/2+135,getmaxy()/2+4);
setcolor(15);
settextstyle(0,0,1);
outtextxy(getmaxx()/2-127,getmaxy()/2-12,"Password:");
gotoxy(39,15);
if(!strcmp(code.getdata(0),"xevil"))
{
clearviewport();sound(1000);
setcolor(9);
rectangle(getmaxx()/2-140,getmaxy()/2-20,getmaxx()/2+135,getmaxy()/2+4);
outtextxy(getmaxx()/2-110,getmaxy()/2-12,"A C C E S S G R A N T E D !");
delay(500);
nosound();
return 0;
}
clearviewport();sound(1000);
setcolor(4);
rectangle(getmaxx()/2-140,getmaxy()/2-20,getmaxx()/2+135,getmaxy()/2+4);
outtextxy(getmaxx()/2-105,getmaxy()/2-12,"A C C E S S D E N I E D !");
delay(500);
nosound();
access++;
if(access<3)goto
loop;
else
clearviewport();
settextstyle(2,0,11);
outtextxy(getmaxx()/2-250,getmaxy()/2-12,"Wrong Password.Auto Exit.");
delay(1500);
exit(EXIT_SUCCESS);
return 0;
}
void intro()
{
cleardevice();
{
float r=17;
setcolor(1);
setfillstyle(1,1);
circle(242,163,r);
floodfill(242,163,1);
delay(300);
{
for(int rr=0;rr<=10;rr++)
{
setcolor(0);
setfillstyle(0,0);
circle(242,163,rr);
delay(50);
}
}
}
{
//MVIE LIBRARY display
settextstyle(0,0,5);
setcolor(1);
delay(50);
outtextxy(135,145," M ");delay(200);
outtextxy(235,145," V ");delay(200);
outtextxy(285,145," I ");delay(200);
outtextxy(335,145," E ");delay(200);
outtextxy(85,230," L ");delay(200);
outtextxy(135,230," I ");delay(300);
outtextxy(185,230," B ");delay(300);
outtextxy(235,230," R ");delay(200);
outtextxy(285,230," A ");delay(200);
outtextxy(335,230," R ");delay(200);
outtextxy(385,230," Y ");delay(500);
}
//Different color rectangle display
for(int lt=10,rt=570,bt=420,co=1;lt<90;lt+=10,rt+=10,bt+=10,co+=2)
{
setcolor(co);
rectangle(lt,lt,rt,bt);delay(100);
}
setcolor(15);settextstyle(2,0,9);typeme(170,getmaxy()-140,"LIBRARY GOES ELECTRONIC\n\n\n",80);
delay(1300);
}
void movie::intro2()
{
int a,b,c,d;
clearviewport();
setfillstyle(0,1);
for(a=0,b=getmaxx(),c=getmaxx()/2,d=getmaxx()/2;a<getmaxx()/2+3;a+=5,b-=5,c-=5,d+=5)
{
line(c,xy(12),d,xy(12));line(c,xy(48),d,xy(48));
bar(0,xy(13),a,xy(47));bar(b,xy(13),getmaxx(),xy(47));
bar(0,xy(13),getmaxx(),xy(47));
} delay(70);
setcolor(1);settextstyle(0,0,4);outtextxy(xy(17),xy(5),"DISCLAIMER");
settextstyle(2,0,4);setcolor(9);
delay(150);
typeme(xy(10),xy(16),"WARNING!",20);
typeme(xy(2),xy(19),"Any unauthorized use ,sale ,editing",20);
typeme(xy(2),xy(22),"or distribution of this program",20);
typeme(xy(2),xy(25),"is strictly prohibited.",20);
setcolor(15);typeme(xy(2),xy(30),"You can contact the programmers at",20);
typeme(xy(2),xy(33),"imxevil@hotmail.com",20);
setcolor(12);
typeme(xy(20),xy(38),"Developed by:",30);
line(xy(15),xy(40),xy(50),xy(40));
settextstyle(2,0,6);typeme(xy(5),xy(42),"Xuvaz",30);
setcolor(4);
rectangle(47,getmaxy()-62,getmaxx()-48,getmaxy()-48);
delay(500);
for(a=150,b=9;a<=getmaxx()-50;++a,b++)
{
settextstyle(0,0,2);
if(b==13)
b=9;
setcolor(b);
settextstyle(0,0,2);outtextxy(48,getmaxy()-80,"Now Loading..");
setfillstyle(1,15);bar(49,getmaxy()-60,a,getmaxy()-50);gotoxy(7,25);
settextstyle(0,0,1);setcolor(1);
if(a<230)outtextxy(50,getmaxy()-59,"Loading Movie Library..");else
if(a<290)outtextxy(50,getmaxy()-59,"Locating data files..");else
if(a<350)outtextxy(50,getmaxy()-59,"Checking drive memory space..");else
if(a<420)outtextxy(50,getmaxy()-59,"Setting system to graphics mode..");else
if(a<480)outtextxy(50,getmaxy()-59,"Detecting internal unit errors..");else
if(a<530)outtextxy(50,getmaxy()-59,"Initializing program components..");else
if(a<getmaxx()-50)outtextxy(50,getmaxy()-59,"Starting Movie Library..");delay(10);
}
settextstyle(0,0,2);outtextxy(370,getmaxy()-80,"Loading Complete.");
sound(1000);delay(100);nosound();delay(100);
sound(1000);delay(100);nosound();delay(500);
clearviewport();
}
void quit(){
int a,b,c;
setcolor(0);
for(a=1,b=getmaxy()-1,c=200;a<=getmaxy()/2;a++,b--,c--){
line(1,a,getmaxx()-1,a);
line(1,b,getmaxx()-1,b);sound(10*(c+200));
delay(1);}
delay(300);nosound();
settextstyle(2,0,7);
setcolor(12);
typeme(xy(2),xy(20),"Thanks For Using This Program.",50);
delay(500);setcolor(0);
typeme(xy(2),xy(20),"Thanks For Using This Program.",50);
delay(100);setcolor(8);
typeme(xy(2),xy(20),"Developed by: ",50);
delay(50);setcolor(9);
typeme(xy(28),xy(20),"Xuvaz",50);
delay(500);setcolor(0);
typeme(xy(28),xy(20),"xuvaz",50);
delay(100);setcolor(4);
typeme(xy(2),xy(35),"For your comments and your suggestions",50);
delay(500);setcolor(12);
typeme(xy(2),xy(45),"Email : imxevil@hotmail.com",50);
delay(3000);
}
void movie::assign()
{
setfillstyle(1,0);bar(xy(1),xy(19),getmaxx()-1,xy(49));
gotoxy(23,9);cout<<"Input Entry Details\n";
cout<<"\n\tEnter Movie Name: ";
cin>>movie_name;
cout<<"\tEnter the Genere of the Movie: ";
cin>>genere;
cout<<"\tEnter the Year the Movie was Released: ";
cin>>year;
cout<<"\tEnter Budget of the Movie: ";
cin>>budget;
cout<<"\tEnter Actress of the Movie: ";
cin>>actress;
cout<<"\tEnter Actor of the Movie: ";
cin>>actor;
cout<<"\tEnter Director of the Movie: ";
cin>>director;
cout<<"\tRate the Movie (1-9) :";
cin>>rating;
}
void movie::putdata()
{
cout<<"\n Movie Name : "<<movie_name;
cout<<"\n Year Released : "<<year;
cout<<"\n Genere of the Movie : "<<genere;
cout<<"\n Budget of the Movie : "<<budget;
cout<<"\n Actress of the Movie : "<<actress;
cout<<"\n Actor of the Movie : "<<actor;
cout<<"\n Director of the Movie : "<<director;
cout<<"\n Ratings : "<<rating<<endl;
}
void movie::search()
{
again:
clearviewport();
setcolor(9);
settextstyle(0,0,3);outtextxy(xy(13),xy(7),"SEARCH MOVIE LIBRARY");
line(0,85,getmaxx(),85);
line(0,120,getmaxx(),120);
gotoxy(5,5);
movie rec;
fstream file;
file.open("c:\\dat5.dat",ios::ate|ios::in|ios::out|ios::binary);
cout<<"\n\nEnter Movie Name: ";
cin>>nmovie_name;
file.seekg(0,ios::beg);
char found=0;
while(file.read((char *)&rec, sizeof(rec)))
{
if(strcmp(nmovie_name,rec.cus())==0)
{
found=1;
rec.putdata();
}
}
file.clear();
if(found==0)
{
settextstyle(0,0,1);
outtextxy(xy(6),xy(20),"\n=== Specified Record Not Found ===\n");
}
getch();
cleardevice();
setcolor(9);
settextstyle(2,0,8);outtextxy(xy(6),xy(15),"Want to Search another Movie?[y/n] ");
if(getche()=='y')
goto again;
rec.database(0);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
}
void movie::deleted()
{
top:
again:
clearviewport();
setcolor(10);
settextstyle(0,0,3);outtextxy(xy(5),xy(7),"DELETE MOVIE FROM LIBRARY");
line(0,85,getmaxx(),85);
line(0,120,getmaxx(),120);
gotoxy(5,5);
movie delitem;
fstream file;
file.open("c:\\dat5.dat",ios::ate|ios::in|ios::out|ios::binary);
char ch;
char nmovie_name[20];
int choice;
cout<<"\n\n Enter Movie Name: ";
cin>>nmovie_name;
file.seekg(0,ios::beg);
settextstyle(0,0,1);
outtextxy(xy(6),xy(20),"Wait Please...Deletion may take some time");
fstream tempFile("c:\\dat1.dat",ios::ate |ios::out| ios::out | ios::binary);
int found=0;
while(file)
{
file.read((char *) &delitem, sizeof(delitem));
if(strcmp(delitem.cus(),nmovie_name)!=0 && !file.eof())
{
cin.get(ch);
tempFile.write((char *) &delitem, sizeof(delitem));
}
else
{
found=1;
}
}
if(found==0){
outtextxy(xy(6),xy(25),"ITEM NOT FOUND -- No Deletion Possible");
}
else{
outtextxy(xy(6),xy(25),"ITEM FOUND -- Deleted Successfully");
}
tempFile.flush();
file.flush();
tempFile.close();
file.close();
remove("c:\\dat5.dat");
rename("c:\\dat1.dat","c:\\dat5.dat");
getch();
cleardevice();
setcolor(10);
settextstyle(2,0,8);outtextxy(xy(6),xy(15),"Want to DELETE another Movie?[y/n] ");
if(getche()=='y')
goto top;
delitem.database(0);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
}
void movie::database(int x)
{
movie database;
cleardevice();
screensaver();
char *dbase[4]={" New Movie ",
" Search ",
" Delete ",
" Quit Program "},key;
char *dfunc[4]={" Add New Movie Information. ",
" Search and Display Movies Information. ",
" Delete Movie Information.",
" Exit To Windows. "};
int set=x,unset=set+1,x1coor[4]={48,184,320,456};
if(unset==5)unset=0;
setcolor(9);line(0,120,getmaxx(),120);line(0,400,getmaxx(),400);
setcolor(15);settextstyle(0,0,4);
outtextxy(120,30,"MOVIE LIBRARY");
setcolor(12);rectangle( 45,77,178,97);rectangle(181,77,314,97);
rectangle(317,77,450,97);rectangle(453,77,586,97);
setcolor(1);line(45,65,586,65);line(47,63,584,63);
setcolor(1);
settextstyle(0,0,1);
rectangle( 8,xy(52),getmaxx()-8,xy(55));
rectangle( 9,xy(52)+1,getmaxx()-9,xy(55)-1);
setcolor(0);
outtextxy( 48,84,dbase[0]);
outtextxy(184,84,dbase[1]);
outtextxy(320,84,dbase[2]);
outtextxy(456,84,dbase[3]);
do
{
loop:
sound(300);delay(50);nosound();
switch(key)
{
/*left*/case 75: --set;unset=set+1;if(set==-1)set=3; break;
/*rght*/case 77: ++set;unset=set-1;if(set==4)set=0; break;
/*-m'-*/case 109: unset=set;set=0;if(set==unset)--unset; break;
/*-f'-*/case 102: unset=set;set=1;if(set==unset)--unset; break;
/*-h'-*/case 104: unset=set;set=2;if(set==unset)--unset; break;
/*-q'-*/case 113: unset=set;set=3;if(set==unset)--unset; break;
/*entr*/case 13: goto next;
}
settextstyle(0,0,1);
setcolor(10);outtextxy(x1coor[set],84,dbase[set]);
setcolor(14);rectangle(x1coor[set]-1,79,x1coor[set]+128,95);
setcolor(0);outtextxy(x1coor[unset],84,dbase[unset]);
setcolor(0);rectangle(x1coor[unset]-1,79,x1coor[unset]+128,95);
setfillstyle(1,9);bar(15,xy(52)+2,getmaxx()-15,xy(55)-2);
setcolor(0);settextstyle(2,0,6);outtextxy(20,xy(52),dfunc[set]);
key=getch();
goto loop;
next:
switch(set)
{
case 0:
{
begin:
movie rec;
fstream file;
file.open("C:\\dat5.dat", ios::ate | ios::in | ios::out | ios::binary);
char ch;
rec.assign();
cin.get(ch);
file.write((char *)&rec, sizeof(rec));
file.close();
gotoxy(30,22);cout<<"Want to ADD another Movie?[y/n] ";
if(getche()=='y')
goto begin;
rec.database(0);
break;
}
case 1:database.search();break;
case 2:database.deleted(); break;
case 3:
quit();
exit(EXIT_FAILURE); }
}
while(set!=3);
return;
}
void main()
{
movie base;
clrscr();
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
introball();
intro();
base.access();
base.intro2();
delay(1000);
base.database(0);
cleardevice();
}
This program was developed by me for college project and some parts of the article were coded with the help of online tutorials and sources.
Thank you
xuvaz
23 years old,male
kathmandu,Nepal



