Código:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;
struct costumerInfo
{
string name;
string addr;
string city;
string state;
string zip;
string phoNum;
};
int main()
{
int menupri = 0; //contador del do while(menupri)
int choicemp; //variable que elige la opcion en el menu principal
string filenamemov = "dataMovies.dat";
string line;
do //menu principal
{
cout << "------ MOVIE DATABASE SYSTEM -------" << endl;
cout << "------------------------------------" << endl;//menu header
cout << "Select Your Choice: " << endl;
cout << "1. Edit Costumer Info " << endl;
cout << "2. Add Movie Record To A Costumer " << endl;
cout << "3. Create New Costumer " << endl;
cout << "4. Search Costumer Record " << endl;
cout << "5. Delete Costumer Record " << endl;
cout << "------------------------------------" << endl;
cout << "Please Enter Your Choice: ";
cin >> choicemp;
system("cls");
switch (choicemp)//opciones del menu principal
{
case 1://presenta la opcion 1
{
//EDIT COSTUMER INFO
system("pause");
system("cls");
break;
}
case 2://presenta la opcion 2
{
//ADD MOVIE RECORD TO A COSTUMER
system("pause");
system("cls");
break;
}
case 3://presenta la opcion 3 *FILE NO SE CREA VERIFICAR!!!
{
//cout << "--- CREATE NEW COSTUMER RECORD ---" << endl;
//cout << "----------------------------------" << endl;
ofstream newcostFile, movFile;
costumerInfo infoCost;
cout << "\nEnter New Costumer Name: ";
getline(cin, infoCost.name);
newcostFile.open(infoCost.name);
if (newcostFile.fail())
{
cout << "\nThe File Cannot Be Created Correctly." << endl;
system("pause");
exit(1);
}
cout << "\nAddress: ";
getline(cin, infoCost.addr);
cout << "\nCity: ";
getline(cin, infoCost.city);
cout << "\nState: ";
getline(cin, infoCost.state);
cout << "\nZIP Code: ";
cin >> infoCost.zip;
cout << "\nPhone Number: ";
getline(cin, infoCost.phoNum);
newcostFile << "Name\t" << infoCost.name << endl
<< "Address \t" << infoCost.addr << endl
<< "City \t" << infoCost.city << endl
<< "State \t" << infoCost.state << endl
<< "ZIP Code \t" << infoCost.zip << endl
<< "Phone Number \t" << infoCost.phoNum << endl;
movFile.open(infoCost.name + "Movies");
if (movFile.fail())
{
cout << "\nThe File Cannot Be Create Correctly.";
system("pause");
exit(1);
}
newcostFile.close();
movFile.close();
system("pause");
system("cls");
break;
}
case 4:
{
//SEARCH COSTUMER RECORD
system("pause");
system("cls");
break;
}
case 5:
{
//DELETE COSTUMER RECORD
system("pause");
system("cls");
break;
}
default://cierra el programa
{
return 0;
break;
}
}
} while (menupri != 6);
system("pause");
return 0;
}