#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <fstream.h>
#include <dos.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <graphics.h>
char *dir={"files.rec"};
/**--declaring macros--**/#define size 16
#define xy(z) (8*(z-1))
class directory{
public:
char *getdata(int);
void database(int),
intro(),
empty(),
mainprogram(int),
fileoptions(int),
helpoptions(int),
addentry(),
modify(),
search(),
erase(),
sorry();
int access();
/*--end of class directory-**/ };
struct info{
char name[size];
char number[size];
char location[size];
char info[size];
/**--end of info structure--**/ }n;
char *directory::getdata(int type){
char data[size],key,x=0;do{
key=getch();
if(key==13&&x>0)break;elseif((key!=8&&x==13)||(key==13&&x==0)){
sound(500);delay(100);nosound();key=0x1b;}elseif(isalnum(key)&&x<size-1){
data[x]=key;x++;if(type==0)printf("*");
else cout<<key; }elseif(key==8&&x>0){printf("%c%c%c",8,32,8);x--;}else{
sound(500);delay(100);nosound();}}
while(x<size-1);data[x]='\0';return data;
/**--end of function--**/ }
int directory::access(){
directory code;
int access=0;loop:clearviewport();
rectangle(getmaxx()/2-140,getmaxy()/2-20,getmaxx()/2+135,getmaxy()/2+4);
outtextxy(getmaxx()/2-127,getmaxy()/2-12,"Enter Accesscode:");
gotoxy(43,15);if(!strcmp(code.getdata(0),"password")){
clearviewport();sound(1000);
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);
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;elsereturn 1;
/**--end of function--**/ }
void display(){
int color=getcolor();
setcolor(0);
outtextxy(xy(40),xy(57),"Programmed By: Noel A. Dacara BSCS-101P");
while(!kbhit()){
time_t t; time(&t);
setcolor(9);rectangle(8,xy(56)-1,getmaxx()-8,xy(59)-4);
setfillstyle(1,4);bar(9,xy(56),xy(38),xy(59)-5);
setcolor(0);
outtextxy(15,xy(57),ctime(&t)); delay(100);}
setcolor(color);
/**--end of function--**/ }
void typeme(int left,int top,constchar *word,int interval){
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); }
/**--end of function--**/ }
void screensaver(){
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
int color=getcolor();
setcolor(3); settextstyle(2,0,6);
outtextxy(xy(26),xy(26)," WELCOME TO THE WORLD OF TECHNOLOGY! ");
outtextxy(xy(26),xy(30)," This program aims to satisfy the humans");
outtextxy(xy(26),xy(34)," needs on useful and functional programs.");
outtextxy(xy(26),xy(38)," Hope you'll enjoy using this! Thank You!");
setcolor(color); settextstyle(0,0,1);
/**--end of function--**/ }
void directory::sorry(){
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
int color=3,previous=getcolor();
int x=0, y=0, z=0;
while(z<2){
setcolor(color++);settextstyle(2,0,6);
typeme(xy(31)+x,xy(26)+y,"SORRY..NOT FINISH",30);
typeme(xy(36)+x,xy(29)+y,"IN THIS PART YET!",30);
setcolor(0);
typeme(xy(31)+x,xy(26)+y,"SORRY..NOT FINISH",30);
typeme(xy(36)+x,xy(29)+y,"IN THIS PART YET!",30);
x+=20; y+=20; z++; }
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
setcolor(previous); settextstyle(0,0,1);
/**--end of function--**/ }
void directory::empty(){
strncpy(n.name,"",size);
strncpy(n.number,"",size);
strncpy(n.location,"",size);
strncpy(n.info,"",size);
/**--end of function--**/ }
void directory::intro(){
int a,b,c,d;
clearviewport();setfillstyle(8,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(8),d,xy(8));line(c,xy(51),d,xy(51));
bar(0,xy(9),a,xy(50));bar(b,xy(9),getmaxx(),xy(50));
sound(10*(a+250));delay(1);}delay(300);
bar(0,xy(9),getmaxx(),xy(50));
settextstyle(0,0,2);outtextxy(xy(11),xy(5),"ELECTRONIC TELEPHONE DIRECTORY");
settextstyle(0,0,1);setcolor(4);
line(xy(40),xy(40)-5,getmaxx()-50,xy(40)-5);
setcolor(1);outtextxy(50,getmaxy()-59,"Now Loading..");setcolor(4);
rectangle(47,getmaxy()-62,getmaxx()-48,getmaxy()-48);
for(a=300;a>0;a-=5){sound(10*(a+250));delay(20);}delay(200);nosound();
for(a=150,b=10;a<=getmaxx()-50;++a,++b){
setfillstyle(1,0);bar(xy(10),xy(5),xy(72),xy(7));
settextstyle(0,0,2);if(b==14)b=10;setcolor(b);
outtextxy(xy(11),xy(5),"ELECTRONIC TELEPHONE DIRECTORY");
setfillstyle(1,1);bar(49,getmaxy()-60,a,getmaxy()-50);gotoxy(7,25);
settextstyle(0,0,1);setcolor(3);
if(a<230)outtextxy(50,getmaxy()-59,"Now Loading..");elseif(a<290)outtextxy(50,getmaxy()-59,"Locating data files..");elseif(a<350)outtextxy(50,getmaxy()-59,"Checking drive memory space..");elseif(a<420)outtextxy(50,getmaxy()-59,"Setting system to graphics mode..");elseif(a<480)outtextxy(50,getmaxy()-59,"Detecting internal unit errors..");elseif(a<530)outtextxy(50,getmaxy()-59,"Initializing program components..");elseif(a<getmaxx()-50)outtextxy(50,getmaxy()-59,"Starting database utility..");delay(10);}
outtextxy(50,getmaxy()-59,"Starting database utility..");
sound(1000);delay(100);nosound();delay(100);
sound(1000);delay(100);nosound();delay(500);clearviewport();
/**--end of function--**/ }
void directory::database(int x){
directory database;
char *dbase[4]={" MAIN PROGRAM ",
" FILE OPTIONS ",
" HELP OPTIONS ",
" QUIT PROGRAM "},key;
char *dfunc[4]={" Add, edit, search, and erase records on current directory. ",
" Display and modify file options and program settings. ",
" View instructions, shortcut keys, and details about the program.",
" Save and exit main programs to windows. "};
int set=x,unset=set+1,x1coor[4]={48,184,320,456};
if(unset==5)unset=0;
setfillstyle(1,1);bar(20,xy(18)+5,xy(23)+2,xy(50)-5);
setcolor(1);settextstyle(0,0,2);
rectangle(xy(23)+7,xy(18)+5,getmaxx()-21,xy(50)-5);
outtextxy(xy(11),xy(5)+5,"ELECTRONIC TELEPHONE DIRECTORY");
rectangle( 45,77,178,97);rectangle(181,77,314,97);
rectangle(317,77,450,97);rectangle(453,77,586,97);
setcolor(0);line(45,65,586,65);settextstyle(0,0,1);
rectangle( 8,xy(52),getmaxx()-8,xy(55));
rectangle( 9,xy(52)+1,getmaxx()-9,xy(55)-1);
outtextxy( 48,84,dbase[0]);
outtextxy(184,84,dbase[1]);
outtextxy(320,84,dbase[2]);
outtextxy(456,84,dbase[3]);
screensaver();
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; }
setcolor(1);outtextxy(x1coor[set],84,dbase[set]);
setcolor(2);rectangle(x1coor[set]-1,79,x1coor[set]+128,95);
setcolor(0);outtextxy(x1coor[unset],84,dbase[unset]);
setcolor(4);rectangle(x1coor[unset]-1,79,x1coor[unset]+128,95);
setfillstyle(1,1);bar(15,xy(52)+2,getmaxx()-15,xy(55)-2);
setcolor(3);outtextxy(20,xy(53),dfunc[set]);setcolor(4);
display();
key=getch();goto loop;next:
switch(set){case 0: database.mainprogram(0); break;
case 1: database.fileoptions(0); break;
case 2: database.helpoptions(0); break;
case 3: exit(EXIT_FAILURE); }
}while(set!=3);return;
/**--end of function--**/ }
void directory::mainprogram(int x){
directory main;
char *dbase[5]={" Add New Entry ",
" Search Directory ",
" Update Records ",
" Delete Files ",
" Back to Main "},key;
char *dfunc[5]={" Add a new entry on directory.",
" Search for saved records on directory by type.",
" Edit existing records on directory.",
" Erase files on directory permanently.",
" Return to main menu."};
int coor[5]={26,28,30,32,34},set=x,unset=set+1;
setfillstyle(1,1);bar(20,xy(18)+5,xy(23)+2,xy(50)-5);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
outtextxy(xy(5),xy(23),"Main Program Menu");
line(xy(5),xy(24)+2,xy(22),xy(24)+2);
outtextxy(xy(5),xy(26),dbase[0]);
outtextxy(xy(5),xy(28),dbase[1]);
outtextxy(xy(5),xy(30),dbase[2]);
outtextxy(xy(5),xy(32),dbase[3]);
outtextxy(xy(5),xy(34),dbase[4]);
screensaver();
do{loop:
sound(300);delay(50);nosound();
switch(key){
/*-up-*/case 72: --set;unset=set+1;if(set==-1)set=4; break;
/*down*/case 80: ++set;unset=set-1;if(set==5)set=0; break;
/*-a'-*/case 97: unset=set;set=0;if(set==unset)--unset; break;
/*-s'-*/case 115: unset=set;set=1;if(set==unset)--unset; break;
/*-u'-*/case 117: unset=set;set=2;if(set==unset)--unset; break;
/*-d'-*/case 100: unset=set;set=3;if(set==unset)--unset; break;
/*-b'-*/case 98: unset=set;set=4;if(set==unset)--unset; break;
/*entr*/case 13: goto next; }
setcolor(3);outtextxy(xy(5),xy(coor[set]),dbase[set]);
setcolor(2);outtextxy(xy(5),xy(coor[set]),"þ");
setcolor(4);outtextxy(xy(5),xy(coor[unset]),dbase[unset]);
setcolor(1);outtextxy(xy(5),xy(coor[unset]),"þ");
setfillstyle(1,1);bar(15,xy(52)+2,getmaxx()-15,xy(55)-2);
setcolor(3);outtextxy(20,xy(53),dfunc[set]);setcolor(4);
display();
key=getch();goto loop; next:
switch(set){
case 0: main.addentry(); main.mainprogram(0);
case 1: main.search(); main.mainprogram(1);
case 2: main.modify(); main.mainprogram(2);
case 3: main.erase(); main.mainprogram(3);
case 4: main.database(0);break;
/**--end of switch--**/ }
}while(set!=4); main.database(0);
/**--end of function--**/ }
void directory::fileoptions(int x){
directory options;
FILE *file;
char *dbase[5]={" Change Directory ",
" Save Files ",
" Memory Status ",
" View Settings ",
" Back to Main "},key,*data,*data2;
char *dfunc[5]={" Change current directory. ",
" Save files to new location. ",
" View memory status of the program. ",
" Display program settings.",
" Return to main menu. "};
int coor[5]={26,28,30,32,34},set=x,unset=set+1;
setfillstyle(1,1);bar(20,xy(18)+5,xy(23)+2,xy(50)-5);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
outtextxy(xy(5),xy(23),"File Options Menu");
line(xy(5),xy(24)+2,xy(22),xy(24)+2);
outtextxy(xy(5),xy(26),dbase[0]);
outtextxy(xy(5),xy(28),dbase[1]);
outtextxy(xy(5),xy(30),dbase[2]);
outtextxy(xy(5),xy(32),dbase[3]);
outtextxy(xy(5),xy(34),dbase[4]);
screensaver();
do{loop:
sound(300);delay(50);nosound();
switch(key){
/*-up-*/case 72: --set;unset=set+1;if(set==-1)set=4; break;
/*down*/case 80: ++set;unset=set-1;if(set==5)set=0; break;
/*-c'-*/case 99: unset=set;set=0;if(set==unset)--unset; break;
/*-s'-*/case 115: unset=set;set=1;if(set==unset)--unset; break;
/*-m'-*/case 109: unset=set;set=2;if(set==unset)--unset; break;
/*-v'-*/case 118: unset=set;set=3;if(set==unset)--unset; break;
/*-b'-*/case 98: unset=set;set=4;if(set==unset)--unset; break;
/*entr*/case 13: /*{goto next; };*/break; }
setcolor(3);outtextxy(xy(5),xy(coor[set]),dbase[set]);
setcolor(2);outtextxy(xy(5),xy(coor[set]),"þ");
setcolor(4);outtextxy(xy(5),xy(coor[unset]),dbase[unset]);
setcolor(1);outtextxy(xy(5),xy(coor[unset]),"þ");
setfillstyle(1,1);bar(15,xy(52)+2,getmaxx()-15,xy(55)-2);
setcolor(3);outtextxy(20,xy(53),dfunc[set]);setcolor(4);
display(); int found=0; key=getch();
if(key!=13) goto loop; //next:switch(set){case 0: options.sorry(); /*options.direct();*/ options.fileoptions(0);
case 1: options.sorry(); /*options.save(); */ options.fileoptions(1);
case 2:
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
file=fopen(dir,"rb");
while(fread(&n,sizeof(n),1,file)){
++found; }
gotoxy(30,12);cout<<"Searching files available...";
delay(1000);
gotoxy(30,14);cout<<"Checking directory...";
delay(1000);
gotoxy(30,16);cout<<"Directory found.";
gotoxy(30,18);cout<<"Number of files stored:";
gotoxy(55,18);cout<<found<<" Records";
gotoxy(30,21);cout<<"Press any key to continue...";
fclose(file);
getch();
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/*options.memory();*/ options.fileoptions(2);
case 3: options.sorry(); /*options.settng();*/ options.fileoptions(3);
case 4: options.database(1); break;
/**--end of switch--**/ } options.database(1);
}while(set!=4); options.database(1);
/**--end of function--**/ }
void directory::helpoptions(int x){
directory help;
char *dbase[5]={" Instructions ",
" Shortcut Keys ",
" Read Me ",
" About ",
" Back to Main "},key;
char *dfunc[5]={" Display program instruction on screen. ",
" View shortcut keys on screen. ",
" Display read me page. ",
" Show details about the program. ",
" Return to main menu. "};
int coor[5]={26,28,30,32,34},set=x,unset=set+1;
setfillstyle(1,1);bar(20,xy(18)+5,xy(23)+2,xy(50)-5);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
outtextxy(xy(5),xy(23),"Help Options Menu");
line(xy(5),xy(24)+2,xy(22),xy(24)+2);
outtextxy(xy(5),xy(26),dbase[0]);
outtextxy(xy(5),xy(28),dbase[1]);
outtextxy(xy(5),xy(30),dbase[2]);
outtextxy(xy(5),xy(32),dbase[3]);
outtextxy(xy(5),xy(34),dbase[4]);
screensaver();
do{loop:
sound(300);delay(50);nosound();
switch(key){
/*-up-*/case 72: --set;unset=set+1;if(set==-1)set=4; break;
/*down*/case 80: ++set;unset=set-1;if(set==5)set=0; break;
/*-i'-*/case 105: unset=set;set=0;if(set==unset)--unset; break;
/*-s'-*/case 115: unset=set;set=1;if(set==unset)--unset; break;
/*-r'-*/case 114: unset=set;set=2;if(set==unset)--unset; break;
/*-a'-*/case 97: unset=set;set=3;if(set==unset)--unset; break;
/*-b'-*/case 98: unset=set;set=4;if(set==unset)--unset; break;
/*entr*/case 13: {goto next; }; /* break; */ }
setcolor(3);outtextxy(xy(5),xy(coor[set]),dbase[set]);
setcolor(2);outtextxy(xy(5),xy(coor[set]),"þ");
setcolor(4);outtextxy(xy(5),xy(coor[unset]),dbase[unset]);
setcolor(1);outtextxy(xy(5),xy(coor[unset]),"þ");
setfillstyle(1,1);bar(15,xy(52)+2,getmaxx()-15,xy(55)-2);
setcolor(3);outtextxy(20,xy(53),dfunc[set]);setcolor(4);
display();
key=getch();goto loop;next:
int m=getcolor();
switch(set){case 0:
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
settextstyle(2,0,5); setcolor(3);
outtextxy(xy(30),xy(25),"INSTRUCTIONS:");
outtextxy(xy(30),xy(27),"This program is a user-friendly program and");
outtextxy(xy(30),xy(29),"easy to understand. You simply select your");
outtextxy(xy(30),xy(31),"desired option. The function of each options");
outtextxy(xy(30),xy(33),"are displayed in a bar located at the bottom");
outtextxy(xy(30),xy(35),"part of the screen.You can also go to shortcut");
outtextxy(xy(30),xy(37),"keys option to view their respective keys.");
getch(); setcolor(m); settextstyle(0,0,1);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/*help.instruct(); */ help.helpoptions(0);
case 1:
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
settextstyle(2,0,5); setcolor(3);
outtextxy(xy(30),xy(25),"SHORTCUT KEYS");
outtextxy(xy(30),xy(27),"The first letter of each option is their");
outtextxy(xy(30),xy(29),"shortcut keys. Example-[i] for INSTRUCTIONS");
outtextxy(xy(30),xy(31),"[m]-MAIN PROGRAM [a]-ADD NEW ENTRY");
outtextxy(xy(30),xy(33),"[f]-FILE OPTIONS [s]-SEARCH DIRECTORY");
outtextxy(xy(30),xy(35),"[h]-HELP OPTIONS [u]-UPDATE RECORD");
outtextxy(xy(30),xy(37),"[q]-QUIT PROGRAM [d]-DELETE FILE and more..");
getch(); setcolor(m); settextstyle(0,0,1);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/*help.shortcut(); */ help.helpoptions(1);
case 2:
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
settextstyle(2,0,5); setcolor(3);
outtextxy(xy(30),xy(25),"WARNING:");
outtextxy(xy(30),xy(27),"Any unauthorized use ,duplication,");
outtextxy(xy(30),xy(29),"sale, or distribution of this program");
outtextxy(xy(30),xy(31),"is punishable by law. Please inform");
outtextxy(xy(30),xy(33),"the programmer for your permission to");
outtextxy(xy(30),xy(35),"do so at his email add: n831@thecutest.com.");
outtextxy(xy(30),xy(37),"Enjoy using this program!");
getch(); setcolor(m); settextstyle(0,0,1);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/*help.readme(); break;*/ help.helpoptions(2);
case 3:
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
settextstyle(2,0,5); setcolor(3);
outtextxy(xy(30),xy(26),"Programmed By:");
outtextxy(xy(30),xy(28),"Noel A. Dacara BSCS-101P");
outtextxy(xy(30),xy(32),"System Technology Institute");
outtextxy(xy(30),xy(35),"All Rights Reserved");
outtextxy(xy(30),xy(37),"Copyright(c) 2003");
getch(); setcolor(m); settextstyle(0,0,1);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/*help.about(); break;*/ help.helpoptions(3);
case 4: help.database(2); break;
/**--end of switch--**/ } help.database(2);
}while(set!=4); help.database(2);
/**--end of function--**/ }
void directory::addentry(){
back:
char data[size];
settextstyle(0,0,1);
FILE *add; directory rec;
add=fopen(dir,"ab");
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Input Entry Details";
gotoxy(30,14);cout<<"Name : ";
strcpy(data,rec.getdata(1));
gotoxy(30,16);cout<<"Phone Number : ";
strcpy(n.number,rec.getdata(1));
gotoxy(30,18);cout<<"Location : ";
strcpy(n.location,rec.getdata(1));
gotoxy(30,20);cout<<"Other Info : ";
strcpy(n.info,rec.getdata(1));
int exist=0;
while(fread(&n,sizeof(n),1,add)){
if(!strcmp(data,n.name)) exist=1; }
if(exist==1){ delay(1000);
gotoxy(30,22); cout<<"Record already exist! "; delay(1000); }
else {
strcpy(n.name,data);
gotoxy(30,22);cout<<"Save to directory?[y/n] ";
if(getche()=='y'){
fwrite(&n,sizeof(n),1,add); delay(1000);
gotoxy(30,22);cout<<"File has been saved! "; delay(1000);
fclose(add);
gotoxy(30,22);cout<<"Want to input another Entry?[y/n] ";
if(getche()=='y')goto back; } rec.mainprogram(0); }
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
/**--end of function--**/ }
void directory::search(){
back:
char data[size]; int found=0;
FILE *find; directory rec;
find=fopen(dir,"rb");
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Select Type of Search:";
gotoxy(30,14);cout<<"[1] By Name ";
gotoxy(30,15);cout<<"[2] By Number";
gotoxy(30,16);cout<<"[3] By Location";
gotoxy(30,17);cout<<"[4] Cancel Search";
switch(getch()){
case'1':
gotoxy(30,19);cout<<"Enter Name to Search: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,find)){
if(!strcmpi(data,n.name)) found=1; }
break;
case'2':
gotoxy(30,19);cout<<"Enter Number to Search: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,find)){
if(!strcmpi(data,n.number)) found=1; }
break;
case'3':
gotoxy(30,19);cout<<"Enter Location to Search: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,find)){
if(!strcmpi(data,n.location)) found=1; }
break;
case'4':
setfillstyle(1,0); bar(xy(24),xy(19),getmaxx()-35,xy(49));
rec.mainprogram(1);
default:
gotoxy(30,19); cout<<"Invalid Choice!"; sound(1000);
delay(200); nosound(); goto back;
/**--end of switch--**/ }
if(found==0){ delay(1000); gotoxy(30,21);
cout<<"Record not found!"; delay(1000); }
if(found==1){
delay(1000);
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Record Found!";
gotoxy(30,14);cout<<"Name : "<<n.name;
gotoxy(30,16);cout<<"Phone Number : "<<n.number;
gotoxy(30,18);cout<<"Location : "<<n.location;
gotoxy(30,20);cout<<"Other Info : "<<n.info;
gotoxy(30,22);cout<<"Press any key to exit.."; getch(); }
fclose(find); rec.mainprogram(1);
/**--end of function--**/ }
void directory::modify(){
back:
char data[size]; int found=0;
FILE *edit, *edit1, *edit2; directory rec;
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Select How to Locate File:";
gotoxy(30,14);cout<<"[1] By Name";
gotoxy(30,15);cout<<"[2] By Number";
gotoxy(30,16);cout<<"[3] By Location";
gotoxy(30,17);cout<<"[4] Cancel";
switch(getch()){
case'1':
edit1=fopen(dir,"rb+");
edit2=fopen("temp.rec","wb");
gotoxy(30,19);cout<<"Enter Name: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),3,edit1)){
if(!strcmpi(data,n.name)) found=1; }
break;
case'2':
edit1=fopen(dir,"rb+");
edit2=fopen("temp.rec","wb");
gotoxy(30,19);cout<<"Enter Phone Number: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),3,edit1)){
if(!strcmpi(data,n.number)) found=1; }
break;
case'3':
edit1=fopen(dir,"rb+");
edit2=fopen("temp.rec","wb");
gotoxy(30,19);cout<<"Enter Location: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),3,edit1)){
if(!strcmpi(data,n.location)) found=1; }
break;
case'4':
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
rec.mainprogram(2);
default:
gotoxy(30,19); cout<<"Invalid Choice!";
delay(1000); goto back;
/**--end of switch--**/ }
if(found==0){delay(1000); gotoxy(30,21);
cout<<"Record not Found!"; fcloseall(); delay(1000); }
else{
rec.empty();
fwrite(&n,sizeof(n),1,edit2);
fcloseall();
remove(dir);
rename("temp.rec",dir);
edit=fopen(dir,"ab");
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Enter New Records";
gotoxy(30,14);cout<<"Name : ";
strcpy(n.name,rec.getdata(1));
gotoxy(30,16);cout<<"Number : ";
strcpy(n.number,rec.getdata(1));
gotoxy(30,18);cout<<"Location : ";
strcpy(n.location,rec.getdata(1));
gotoxy(30,20);cout<<"Other Info : ";
strcpy(n.info,rec.getdata(1));
fwrite(&n,sizeof(n),1,edit);
delay(100);
gotoxy(30,22);cout<<"Saving record to directory.. "; delay(1500);
gotoxy(30,22);cout<<"Record successfully modified!";delay(1000);
fclose(edit); } rec.mainprogram(2);
/**--end of function--**/ }
void directory::erase(){
back:
char data[size]; int found=0;
FILE *erase1, *erase2; directory rec;
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
gotoxy(30,12);cout<<"Deleting Records on Directory";
gotoxy(30,14);cout<<"[1] By Name";
gotoxy(30,15);cout<<"[2] By Phone Number";
gotoxy(30,16);cout<<"[3] By Location";
gotoxy(30,17);cout<<"[4] Cancel";
erase1=fopen(dir,"rb");
erase2=fopen("temp.rec","wb");
switch(getch()){
case'1':
gotoxy(30,19);cout<<"Enter Name: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,erase1)){
if(!strcmpi(data,n.name)) found=1; }
break;
case'2':
gotoxy(30,19);cout<<"Enter Phone Number: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,erase1)){
if(!strcmpi(data,n.number)) found=1; }
break;
case'3':
gotoxy(30,19);cout<<"Enter Location: ";
strcpy(data,rec.getdata(1));
while(fread(&n,sizeof(n),1,erase1)){
if(!strcmpi(data,n.location)) found=1; }
break;
case'4':
fcloseall();
setfillstyle(1,0);bar(xy(24),xy(19),getmaxx()-35,xy(49));
rec.mainprogram(3);
default:
gotoxy(30,21); cout<<"Invalid Choice!";
delay(1000); fcloseall(); goto back;
/**--end of switch--**/ }
if(found==0){ gotoxy(30,21); delay(1000);
cout<<"Record not found!"; delay(1000); }
else{
rec.empty();
fwrite(&n,sizeof(n),1,erase2);
fcloseall();
remove(dir);
rename("temp.rec",dir);
delay(1000); gotoxy(30,19);
cout<<"Deleting "<<data<<".. ";delay(1500);
gotoxy(30,19);cout<<"Record has been deleted! ";delay(1000);
} fcloseall(); rec.mainprogram(3);
/**--end of function--**/ }
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();setcolor(4);
typeme(xy(2),xy(20),"Developed By: Noel A. Dacara BSCS-101P",30);
delay(500);setcolor(0);
typeme(xy(2),xy(20),"Developed By: Noel A. Dacara BSCS-101P",30);
delay(2000);
/**--end of function--**/ }
void main(){
directory base;
atexit(quit);
int gd=DETECT,gm,error,a,b,c,d;
initgraph(&gd,&gm,"c:\\programs\\tc\\bgi");
error=graphresult();
if(error!=0){sound(1000);printf("Initializing Graphic Components Failed!%s\n",
grapherrormsg(error));delay(500);nosound();exit(EXIT_FAILURE);}
do{
sound(1000);delay(100);nosound();delay(100);a++;}while(a<4);
if(base.access()==1)exit(EXIT_FAILURE);
base.intro();
setcolor(4);
for(a=0,b=0,c=getmaxy(),d=getmaxx();c>=0;a++,b++,c--,d--){
line(0,0,0,a);
line(0,getmaxy(),b,getmaxy());
line(getmaxx(),getmaxy(),getmaxx(),c);
line(d,0,getmaxx(),0);delay(1);}
rectangle(0,0,getmaxx(),getmaxy());delay(100);
setfillstyle(1,4);bar(5,5,getmaxx()-5,xy(16));
setfillstyle(1,4);bar(5,xy(16)+5,getmaxx()-5,xy(60));
setfillstyle(1,0);bar(15,xy(18),getmaxx()-16,xy(50));
setcolor(1);rectangle(8,8,getmaxx()-8,xy(16)-3);
rectangle(8,xy(16)+10,getmaxx()-8,xy(50)+6);
base.database(0);
exit(EXIT_SUCCESS);
/**--end of program--**/ }