J
John J
I've written the following code into a class to search for and display the
results of all races entered (The complete code is in a previous thread). I
wish to amend the code so as to display the best result only.
Can anyone suggest a simple amendment to the following that will result in
only the best result being displayed?
Thanks for any help
void Yacht::best_result (ostream& out) const
{
Entry* e =NULL;
out << "A search of races for this Yacht shows the following results:
" << endl;
if (nYEntries == 0)
{
out << "This Yacht has entered no races: " << endl;
}
else
{
bool found_a_result = false; // no result found yet
for (int i=0; i<nYEntries; i++)
{
e = yacht_entries;
if (e->getPlace() >= 1)
{
out << *e;
found_a_result = true; // a result has been found
}
}
if (!found_a_result) // if no result
{
out << "No results were found" << endl;
}
}
}
results of all races entered (The complete code is in a previous thread). I
wish to amend the code so as to display the best result only.
Can anyone suggest a simple amendment to the following that will result in
only the best result being displayed?
Thanks for any help
void Yacht::best_result (ostream& out) const
{
Entry* e =NULL;
out << "A search of races for this Yacht shows the following results:
" << endl;
if (nYEntries == 0)
{
out << "This Yacht has entered no races: " << endl;
}
else
{
bool found_a_result = false; // no result found yet
for (int i=0; i<nYEntries; i++)
{
e = yacht_entries;
if (e->getPlace() >= 1)
{
out << *e;
found_a_result = true; // a result has been found
}
}
if (!found_a_result) // if no result
{
out << "No results were found" << endl;
}
}
}