I'm trying to create a parking lot system where users can enter and exit a lot. This lot should be kept on a file(s). My code compiles but my data doesn't write to the actual file.
void SYSTEM::parkProcess()
{
CARD IDcard;
char lot;
int id;
string type;
cout<<"Enter Parking Lot: ";
cin>>lot;
cout<<"Enter ID #: ";
cin>>id;
cout<<"Enter type: ";
cin>>type;
IDcard.setIdNo(id);
IDcard.setType(type);
ofstream newOccupant;
if(AuthorizeEntry(IDcard,lot))
{
cout<<"Lot Accessed." <<endl;
if(lot == 'A')
ofstream newOccupant("lot_A.txt", ios::out);
if(lot == 'B')
ofstream newOccupant("lot_B.txt", ios::out);
if(lot == 'C')
ofstream newOccupant("lot_C.txt", ios::out);
if(lot == 'D')
ofstream newOccupant("lot_D.txt", ios::out);
if(lot == 'E')
ofstream newOccupant("lot_E.txt", ios::out);
if(!newOccupant)
cout << "Unable to create active lot file";
else
addToLot(newOccupant);
}
else
{
cout<<"You are not allowed to park in this parking lot." <<endl;
}
}
void SYSTEM::addToLot(ofstream &newOccupant)
{
int dd, mm, yy;
cout << "Enter the Current Date" << endl << "Day";
cin >> dd;
cout << "Month";
cin >> mm;
cout << "Year";
cin >> yy;
newOccupant << dd << mm << yy;
}