Topical Information

This project will help you show your mastery of arrays, classes, and libraries.

Program Information

Write a program to allow the user to calculate the distance between cities on a map.

Sounds pretty complicated, eh? Don't worry, we'll make a few simplifications here:

But in order to make the system useful, we'll have to add a few other features:

For those last two when you list the cities for them to choose, I'm assuming you'll do a numbered list and have them enter the position number of the city they are interested in. If you want to make it nicer, see the option below.


Hint: You should have at least 2 classes — possibly 3 (see the options below). One will be Pointfrom the examples. (And, yes, you must use it as is!) Another should be a City class almost exactly like:

    const size_t MAX_CITY_NAME = ???;
    class City
    {
        Point location;
        char name[MAX_CITY_NAME];
    public:
        double distance(const City & other) const
        {
            return location.distance(other.location);
        }
        Point get_location(void) const
        {
            return location;
        }
    // other methods and constructors here
    };

but with additions as noted. (But otherwise identical!)

Don't forget to separate all the details of city handling from the details of list management.

Hint: Each class should be in its own library. Other libraries may also be used for collections of useful functions.

This assignment is (Level 4).

Options