Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

LoadCallDB reads call records from an open ifstream (istream to be general) unti

ID: 3716671 • Letter: L

Question

LoadCallDB reads call records from an open ifstream (istream to be general) until there is no more data or an error occurs. This function uses a loop. On each iteration, it will read the three fields as strings, call the validate functions you wrote in Lab 1, and if the data passes validation and there is room left in the array, fill in the first unused Call record with the data you read. This function will return the count of records that failed validation or which would not fit in the array because there was no room left.

This is what I have so far:
void LoadCallDb(Call& call, istream& string)
{
string callTime;
string duration;
string e164;
while (f!fin.eof())
{
  fin >> callTime >> duration >> e164;
  if (callDb.numCalls < MAXCALLS)
  {
   if (IsValidDate && IsValidPhone && IsLocalPhone)
   {
    callTime......//Dont know what to do next
   }
  }
}
}

Explanation / Answer

void LoadCallDb(Call& call, istream& fin)
{
string callTime;
string duration;
string e164;
int failed = 0;
int i=0;
while (!fin.eof())
{
fin >> callTime >> duration >> e164;
if (callDb.numCalls < MAXCALLS)
{
if (IsValidDate && IsValidPhone && IsLocalPhone)
{
// find the first unused call record
while(callDb[i].isFree()) {
i ++;
}
// now insert the data
callDb[i].insert(callTime, duration, e164);
}
} else {
failed ++;
}
}
}

Please note that this answer might not be precise since you need to provide the overall imlementation to get a more precise result.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote