I tried and looked everywhere on the internet, I can't seem to find much.
Now, without too much talking, to the problem I have: I have to make a project for college that consists of making an "electronic phone-book" using OOP programming logic in C++. The materials I`ve received to do this are extremely vague so I must do on my own somehow.
Here is the code I have done so far(with help from the internet):
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
#include <fstream.h>
void op1()
{
printf("\n Add contact");
getch();
}
void op2()
{
printf("\n Delete contact");
getch();
}
void op3()
{
printf("\n Edit a contact");
getch();
}
void op4()
{
printf("\n Find a contact");
getch();
}
void op5()
{
printf("\n Sort the contacts");
getch();
}
void op6()
{
printf("\n 'About the program, details etc. etc.");
getch();
}
void print_menu()
{
system("cls"); // clearing window
printf("\nMenu:");
printf("\n##############################\n");
printf("\n1. Add contact");
printf("\n2. Delete contact");
printf("\n3. Edit a contact");
printf("\n4. Find a contact");
printf("\n5. Sort the contacts");
printf("\n6. About");
printf("\n7. Exit");
printf("\n\n##############################");
printf("\n\nInput your option: ");
}
// Text centering function - begin
void centerText(char* s)
{
int l=strlen(s);
int pos=(int)((80-l)/2);
for(int i=0;i<pos;i++)
cout<<" ";
cout<<s<<endl;
}
// Text centering functon - end
void main()
{
{
printf("\n 'My University' 'My City' ");
printf("\n Faculty of Electrical Engineer and Computer Science");
printf("\n Study program used: C++\n\n");
centerText("C++ Project");
centerText("<The Phonebook>");
printf("\n");
centerText("<my name, Year I of study, Group>");
printf("\n");
printf("\n");
centerText("<june.2013>");
system("pause>nul"); // Screen is paused until a key is pressed (to allow this text to be viewed)
}
// ... Sequence for password verification ...
{
char password[20], my_password[20]="2013";
system("cls");
printf("WARNING!\n");
printf("Authentication required!\n");
printf("\nType input password: ");
scanf("%19s",password);
if (strcmp(password, my_password)!=0)
{
printf("\n\nIncorrect password !!!\n");
printf("The program will now exit...\n");
getch();
return;
}
printf("\n\nPassword is correct !\n");
printf("The program is executed !\n");
getch();
}
char optiune;
// ... Sequence for option choosing ...
do
{
print_menu();
fflush(stdin);
cin>>optiune;
switch(optiune)
{
case '1': op1(); break;
case '2': op2(); break;
case '3': op3(); break;
case '4': op4(); break;
case '5': op5(); break;
case '6': op6(); break;
case '7': exit(0);
default : printf("\n\nIncorrect option !");
fflush(stdin);
getch();
}
}
while(1);
}
The idea was that I could maybe use this menu in a way like, just inserting in one of the op() functions the redirect to another file, which is 1 function in a separate file. So I would then have this program as a main program and each function that "adds, edits, deletes ..etc will be outside of this program and I would deal with them separately. Thing is ..I have no clue in doing so. I've looked in the "header" working system and I didn't really find anything of value there. Maybe I don't know to look but trust me I've really tried. Any feedback is much appreciated, but remember I am extremely newbie in this. Please, if you can, explain with as much detail as you can. I appreciate anyone who read this entire thing. I will thank the beginning.