asked 24.9k views
0 votes
Write the InputTowns() function in the SmallCities class. Within InputTowns(), use cin to read each entry number until -999 is read from input. If the entry number is not equal to -999, use the Town object's ReadDetails() to read the town's name and tour from input and append the Town object to vector townList.

Ex: If the input is:
1 Hanna Y
2 Natrona N
3 Asaph N
-999
then the output is:
Town: Hanna, Tour: Y
Town: Natrona, Tour: N
Town: Asaph, Tour: N

asked
User Shantel
by
8.7k points

1 Answer

2 votes

Final answer:

The InputTowns() function in the SmallCities class reads entry numbers and, for each entry, uses the ReadDetails() method of the Town class to read the town's details and append it to the vector townList, until the sentinel value -999 is read.

Step-by-step explanation:

The student is tasked to write the InputTowns() function as part of the SmallCities class in a programming context. This function utilizes the cin object to continuously read numbers representing entries of towns until the sentinel value of -999 is encountered. When a valid entry number is read, which is any number not equal to -999, the corresponding Town object's method ReadDetails() is called. This method reads further details of the town, presumably the name and whether it offers a tour, and then the Town object is appended to the vector townList. The function does not provide actual output, but based on the example input and the expected format, the output would list the details of each town. However, generating this output would be the role of another function, presumably one that iterates over townList and prints the details.

answered
User Zalogatomek
by
7.9k points