Question: Using C++, Java, or Python classes, attributes, and operations, develop an object-oriented program that would model the distance among cities. Your program must provide a

Using C++, Java, or Python classes, attributes, and operations, develop an object-oriented program that would model the distance among cities. Your program must provide a class to represent cities, i.e., City, and another one to model the concept of distance, Distance. To test your program, you will create a few objects from a file containing the following information. Paris, Berlin, 1000 km Paris, Vienna, 1200 km Berlin, Vienna, 681 km Please note that the class City shall not contain duplicates. Although the city Paris appears in two rows only one object belong to the class City will be created. You must provide a method called, getDistance that will return the distance between the source and target city if this information is available. It is up to you to decide the best place this method. If the distance between source and target cities is not available, e.g., Berlin, London, getDistance must return -1. However, the distance between Berlin and Paris must be returned even the data set only provided an entry from Paris to Berlin.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!