//********************************************************** // PROJECT DICTIONARY //********************************************************** #include #include #include #include #include #include #include #include #include //********************************************************** // THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU //********************************************************** class MENU { public : void MAIN_MENU(void) ; void LINE_HOR(int, int, int, char) ; void LINE_VER(int, int, int, char) ; void BOX(int,int,int,int,char) ; } ; //********************************************************** // THIS CLASS CONTROL ALL THE FUNCTIONS RELATED TO // DICTIONARY //********************************************************** class DICTIONARY { public : void ADDITION(void) ; void DELETION(void) ; void LIST(void) ; void INTRODUCTION(void) ; private : void ADD_RECORD() ; void DELETE_RECORD(char []) ; int RECORDS(void) ; int FOUND(char []) ; void DISPLAY(char []) ; char word[30], meaning[80], adjective[50], noun[50] ; char adverb[50], pronoun[50] ; } ; //********************************************************** // FUNCTION TO DRAW HORIZONTAL LINE //********************************************************** void MENU :: LINE_HOR(int column1, int column2, int row, char c) { for ( column1; column1<=column2; column1++ ) { gotoxy(column1,row) ; cout <=Exit" ; gotoxy(26,2) ; cout <<"ADDITION OF WORD AND MEANING" ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER WORD TO ADDED TO THE DICTIONARY" ; gotoxy(1,5) ; clreol() ; cout <<"Word : " ; gets(dword) ; strupr(dword) ; if (dword[0] == '0') return ; if (strlen(dword) < 1 || strlen(dword) > 29) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7NAME SHOULD NOT BLANK OR GREATER THAN 29" ; getch() ; } if (FOUND(dword) && valid) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7WORD ALREADY EXIST" ; getch() ; } } while (!valid) ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER MEANING OF THE WORD" ; gotoxy(1,7) ; cout <<"Meaning" ; gotoxy(1,8) ; clreol() ; gets(dmeaning) ; strupr(dmeaning) ; if (dmeaning[0] == '0') return ; if (strlen(dmeaning) < 1 || strlen(dmeaning) > 79) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7IT SHOULD NOT BLANK OR GREATER THAN 79" ; getch() ; } } while (!valid) ; gotoxy(1,10) ; cout <<"Adjective : " ; gotoxy(1,11) ; cout <<"Noun : " ; gotoxy(1,12) ; cout <<"Adverb : " ; gotoxy(1,13) ; cout <<"Pronoun : " ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER ADJECTIVE or FOR BLANK" ; gotoxy(14,10) ; clreol() ; gets(dadjective) ; strupr(dadjective) ; if (dadjective[0] == '0') return ; if (strlen(dmeaning) > 49) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7IT SHOULD NOT GREATER THAN 49" ; getch() ; } } while (!valid) ; if (strlen(dadjective) == 0) strcpy(dadjective,"null") ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER NOUN or FOR BLANK" ; gotoxy(14,11) ; clreol() ; gets(dnoun) ; strupr(dnoun) ; if (dnoun[0] == '0') return ; if (strlen(dnoun) > 49) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7IT SHOULD NOT GREATER THAN 49" ; getch() ; } } while (!valid) ; if (strlen(dnoun) == 0) strcpy(dnoun,"null") ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER ADVERB or FOR BLANK" ; gotoxy(14,12) ; clreol() ; gets(dadverb) ; strupr(dadverb) ; if (dadverb[0] == '0') return ; if (strlen(dadverb) > 49) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7IT SHOULD NOT GREATER THAN 49" ; getch() ; } } while (!valid) ; if (strlen(dadverb) == 0) strcpy(dadverb,"null") ; do { valid = 1 ; gotoxy(1,25) ; clreol() ; cout <<"ENTER PRONOUN or FOR BLANK" ; gotoxy(14,13) ; clreol() ; gets(dpronoun) ; strupr(dpronoun) ; if (dpronoun[0] == '0') return ; if (strlen(dpronoun) > 49) { valid = 0 ; gotoxy(1,25) ; clreol() ; cout <<"\7IT SHOULD NOT GREATER THAN 49" ; getch() ; } } while (!valid) ; if (strlen(dpronoun) == 0) strcpy(dpronoun,"null") ; gotoxy(1,25) ; clreol() ; do { gotoxy(1,17) ; clreol() ; cout <<"Do you want to save the record (y/n) : " ; ch = getche() ; if (ch == '0') return ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; fstream file ; file.open("DIC.DAT", ios::app) ; strcpy(word,dword) ; strcpy(meaning,dmeaning) ; strcpy(adjective,dadjective) ; strcpy(noun,dnoun) ; strcpy(adverb,dadverb) ; strcpy(pronoun,dpronoun) ; file.write((char *) this, sizeof(DICTIONARY)) ; file.close() ; } //********************************************************** // THIS FUNCTION DISPLAY LIST OF THE WORDS AND MEANING IN // THE DICTIONARY //********************************************************** void DICTIONARY :: LIST(void) { clrscr() ; MENU m ; char tword[30], t1word[30] ; gotoxy(3,5) ; cout <<"Enter character(s) for Meaning of a Word" ; gotoxy(3,6) ; cout <<"or press for whole list or `0' for exit : " ; gets(tword) ; if (tword[0] == '0') return ; int len = strlen(tword) ; clrscr() ; fstream file ; file.open("DIC.DAT", ios::in) ; file.seekg(0,ios::beg) ; int row = 4 ; int found = 0 ; int pageno = 1 ; int flag = 1 ; char ch ; textcolor(BLACK) ; textbackground(WHITE) ; gotoxy(34,2) ; cprintf(" DICTIONARY ") ; textcolor(LIGHTGRAY) ; textbackground(BLACK) ; m.LINE_HOR(1,79,3,196) ; m.LINE_HOR(1,79,24,196) ; while (file.read((char *) this, sizeof(DICTIONARY))) { flag = 1 ; for (int i=0; i= 17) { flag = 0 ; row = 4 ; gotoxy(66,1) ; cout <<"Page no. : " < to exit or any other key to continue..." ; ch = getch() ; if (ch == 27) return ; clrscr() ; textcolor(BLACK) ; textbackground(WHITE) ; gotoxy(34,2) ; cprintf(" DICTIONARY ") ; textcolor(LIGHTGRAY) ; textbackground(BLACK) ; m.LINE_HOR(1,79,3,196) ; m.LINE_HOR(1,79,24,196) ; } else row++ ; } } if ( !found ) { sound(500) ; delay(100) ; nosound() ; gotoxy(1,5) ; cout <<"WORD NOT PRESENT" ; } if (flag) { gotoxy(66,1) ; cout <<"Page no. : " <=Exit" ; gotoxy(5,5) ; cout <<"Enter word or for Help : " ; gets(dword) ; if (dword[0] == '0') return ; if (strlen(dword) == 0) { valid = 0 ; LIST() ; } } while (!valid) ; if (!FOUND(dword)) { gotoxy(5,10) ; cout <<"\7Word not found in dictionary" ; getch() ; return ; } clrscr() ; textcolor(BLACK) ; textbackground(WHITE) ; gotoxy(26,2) ; cprintf(" DELETION IN THE DICTIONARY ") ; textcolor(LIGHTGRAY) ; textbackground(BLACK) ; m.LINE_HOR(1,79,3,196) ; m.LINE_HOR(1,79,24,196) ; gotoxy(71,1) ; cout <<"<0>=Exit" ; DISPLAY(dword) ; do { gotoxy(1,16) ; clreol() ; cout <<"Do you want to Delete this record (y/n) : " ; ch = getche() ; if (ch == '0') return ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; DELETE_RECORD(dword) ; gotoxy(1,20) ; cout <<"\7Record Deleted" ; getch() ; } //********************************************************** // FUNCTION TO PRINT THE PROGRAMMERS NAME & DETAILS //********************************************************** void print(void) { int j=1; for(int m=100;m<=5500;m++) { sound(m); if(j==23) j=1; if(m%240==0) { clrscr(); textcolor(11); gotoxy(25,j); cprintf("Project By"); textcolor(15); gotoxy(35,j+1); cprintf("PUNEET CHHATWAL"); gotoxy(35,j+2); cprintf("Class XII A"); gotoxy(35,j+3); cprintf("J.L.D.A.V. PUBLIC SCHOOL"); j++; } delay(1); } nosound(); clrscr(); }; void main(void) { clrscr(); MENU m; m.BOX(25,13,56,15,218); gotoxy(26,14); textcolor(4); cprintf(" The Best Dictionary Around"); getch(); gotoxy(5,24); cout<<"Loading"; for(int i=0;i<10;i++) { cout<<"."; delay(100); } textbackground(0); print(); MENU menu ; menu.MAIN_MENU() ; }