Hi, I am creating a program where I can store data from a person: Bday, address, name, and phone number. I'm suppose to read a file with all the contacts and sort them by last name, search by last name, and print by last name, or by Bday. So I need a menu where I can have the user select what ever operation he wants to do.
I have all my classes done. One class if for the name, one for the address, one for the date of birth, and one class to do the operations of printing the whole contact information.
Now, in my main program, I have two funtions wich I am using as menus for the user. The firs menu is to have the user select 1: get the data from outside file, 2: sort the contacts by last name, 3: search contacts by last name, and 3 print the contacts in different ways. The print function is a bool type, so that I can have more than one option to print.
What my problem is: How do I get the info from my classes to the functions that I have in my main program??
Or is it easier to create a class for my menus???
Any suggestions Please..... I need to get this done by Sunday night, and I'm freacking out, LOL.
I have all my classes done. One class if for the name, one for the address, one for the date of birth, and one class to do the operations of printing the whole contact information.
>.< rage Most of those things should be part of one class, unless you have a very good reason not to. In the later case I would love to hear what it is.
Iss an aasignment for class, so I guess what the book is trying to have me to do is to see how inheratance and composition work by inheriting all of these diferent classes into one class that will do the operations. The assignment is to create a book full of contacts. I followed all instructions of how the book wants me name all the classes and I know what the operations have to do. But since I need a menu to have the user select all these diferent options, I'm having a real problem by figuiring it out.
Yup, that's actually an expectable reason, not a good reason mind you, but if that's what the assignment is telling you to do then that's what we have to do. What kind of menu? Drop down? or multi choice? Also what platform?
# include <iostream>
# include <iomanip>
# include <conio.h>
# include <string>
# include <fstream>
# include <vector>
# include "addressBookType.h"//This is a class that inhereted three more classes
using namespace std;
const int maxPeople = 500;//array to store maximum people
bool mainMenu(vector<addressBookType>& contacts);
//Main Menu for the user.
void getData(vector<addressBookType>& contacts);
//Funtion to store the data from outside file.
void sortData();
//Function to sort contacts by last name.
void searchData();
//Funtion to search contact by last name
bool printData();
//menu to print data in diferent ways.
void printContact();//Print full info
void printbMonth();//Pritn by birthday month
void printLname();//Print by last name
void printRela();//Print relatives
//Main Program starts
int main()
{
vector<addressBookType>contacts;
personalinfo();//Header function call.
while (mainMenu(contacts)){}//Main menu funtion call.
system("pause");
system("cls");
return 0;
}//End of main program
//Value-Returning Functions:
//The header for the program
void personalinfo()
{
cout << "\t\t\t\Online Address Book" << endl;
cout << "\t\t\t\Long Beach City College " << endl;
cout << "\t\t\t4901 E. Carson Street " << endl;
cout << "\t\t\t\Long Beach, CA 90808 " << endl;
cout <<""<< endl;
cout << " ***********************************************" << endl;
cout<<""<<endl;
cout << "\t\t\ PRESS ANY KEY TO START THE PROGRAM " << endl;
cout<<""<<endl;
system("pause");
system("cls");
}
//Funtion for main menu for the user
bool mainMenu(vector<addressBookType>& contacts)
{
bool flag = bool();
char choice = char();
cout << "********** Welcome to Fast Online Address Book **********" << endl;
cout << " Type Number to Select " << endl;
cout <<""<<endl;
cout << "1 Get the data" << endl;
cout << "2 Sort Contacts" << endl;
cout << "3 Search Contact"<< endl;
cout << "4 Print Contact" << endl;
cout << "5 Exit" << endl;
choice= getch();
system("cls");
switch (choice)
{
case '1':
getData(contacts);
flag=true;
break;
case '2':
sortData();
flag=true;
break;
case '3':
searchData();
flag=true;
break;
case '4':
printData();
flag=true;
break;
case '5':
flag=false;
break;
default:
flag=true;
cout<< "Invalid Selection" << endl;
system("pause");
system("cls");
break;
}//End of switch
return flag;
}
//Funtion to read the input file
void getData(vector<addressBookType>& contacts)
{
addressBookType list[maxPeople];
int count;
addressBookType temp;
ifstream infile;