1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
//*************************************************************
void pickingOptions(char selection, ifstream& inRentalData, apartmentInfo addApartment[], int& cnt)
{
// variable
int num;
string phoneNumber;
string numDelete;
int locatedPhoneNum;
float rentAmount;
float status;
char yesNo;
bool inserted = false;
bool deletedPhoneNum = false;
bool goodPhone = false;
switch (selection)
{
case 'S':
// Display all the apartment information on file
displayRental(addApartment, cnt);
break;
case 'A':
//loop to keep adding apartments until user is done
cout << "---- The following 3 questions are for adding an apartment ----" << endl << endl;
while(!inserted)
{
// phone number prompt and validation
goodPhone = false;
phonePrompt (PHONE_PROMPT, phoneNumber, cnt, inserted);
phoneValidation (phoneNumber);
addApartment[cnt].phoneNum = phoneNumber;
// rent amount prompt and validation
rentAndStatusPrompt (RENT_PROMPT, rentAmount, cnt, inserted);
rentValidation (rentAmount);
addApartment[cnt].rent = rentAmount;
// rental status prompt and validation
rentAndStatusPrompt (STATUS_PROMPT, status, cnt, inserted);
statusValidation (status);
addApartment[cnt].rentalStatus = status;
// prompt user to continue or not
cout << "---- Do you wish to add more apartments to the list (Y/N)? ----" <<endl;
cin >> yesNo;
yesNo = toupper(yesNo);
if (yesNo == 'Y')
inserted = false;
else
inserted = true;
// add counter to array
cnt++;
}
break;
case 'D':
//display the availble phone numbers
displayPhoneNumber(addApartment, cnt);
//user prompt/read for phone number
numDelete = deletePhonePrompt();
//validate
phoneValidation(numDelete);
// find and delete phone number in the array
locatedPhoneNum = findAndDeleteNum(numDelete, addApartment, cnt, deletedPhoneNum);
//display message that file was deleted or messafge that file not found
displayDeleteMessage(numDelete, locatedPhoneNum, addApartment, cnt);
break;
}
return;
}
|