EECE 230 Final Problem 3, Fall 2013

American University of Beirut · Introduction to Programming · 1 page · Prof. Hassan Artail

All EECE 230 files
EECE 230 Final Problem 3, Fall 2013, page 1

Stuck on a question? A tutor can walk you through it.

More EECE 230 files

Show the text of this final exam
Problem 3 (44%, An airline con, information j ing Humber of ; destin, distances, Below is Panny has ci @ in the world . te wuety jy de. ich j " On Cities, and th NONE. txt. "This ec hao Mights. It keeps this id then the ng eg weed by the an example file Imes of roe city, fe These cities with the Sonne Epa Jeddah 610 Basra 600 | Istanbul $50 | Berlin 725 Madrid 450 Rome 560 ‘(Copenhagen 870 Create a class Air — Char Lip : 4ineDestinationa that has the following attributes (3 pts) *SOurceCi tyName: Beirut in the above example int numberOfDest ination e n = j i > har **destinationcit, yNames: names of the destination cities, for example the listed destination cities above ~ ant *distances: array of integers to store the distances for the destination cities ties: for example; 7 in the above example The class has the following member fimctions (10 pts): — Default constructor: initializes the attributes NULL or 0 — void setSourceCi ty(char* city): sets the source city =- void setupDestinations (int Numcit ies): allocates memor ¥ lor the pointers to the destination cities, and for the array of distances — void addcityAndDist (char* city, int dist): it adds the city and its distance in the destinationCityNames and the distances arrays. - int getDistance(char * city): rctums the distance to a given destination city. If the passed city name is not found in the list of destination cities. return -1. Write a main program to: —- Define the following variables and object (1 pt): o char City[16] // stores a city name read from the file (source or destination) o int value.// stores a numeric value read from the file © AirlineDestinations Flights // object of the defined class — Read from the destinations. ixt file to set the corresponding data in the Flights object. (Hint, you read one-line at a time from the file, and store the read data into the corresponding object's data members) (10 pts) — Ask the user to enter the names of 3 destination cities (to make up an itinerary) (3 pts) - Display the total distance corresponding to this itinerary (6 pts)