For unlimited access to Study Guides, a Grade+ subscription is required.
9. Finally, you should write a program MontrealMaps which will suggest a path to go along the metro to get
from one place to another. The only required method for MontrealMaps is a main method but of course you
are allowed to write others.
Your program should do the following. For any library methods that you use, make sure that you are properly
importing things and handling any exceptions they may throw. (10 points)
• Using an appropriate library method, you should create a Subway System object. If this method fails to
initialize, you should print the message Error, not enough funding.
• Use a Scanner and print statements to read the current x and y position of the user.
• Use a Scanner and print statements to read the x and y position that the user wants to go to.
. Find the nearest Metro Station to both the start position of the user and his final destination.
• If the 2 metro stations have the same name (i.e. are the same metro station) then print It is fastest
to walk there.
• Otherwise, call the method findPath from the previous part to find a path from these 2 metro stations.
. If the method returns null, then print Sorry, there is no path on the metro, you'll
have to walk
• Otherwise, print the path using the metro using the method printPath defined in the MapUtilities
class in the appendix.
SUMMARY OF JAVA STANDARD LIBRARY METHODS POR SELECTED CLASSES
• String package java.lang) Methods
- public boolean gist and
e rs is stingeancoject
- puble boolean grease Sering another
before the Stripe with striert
Single weiter water
-publish tohy Casting de
age java.io) Methods
- publie Yiling path :
• Scanner (package java.ut 1) Method
double Double Sc
- le bon when :
Scanner tal de
- puble String Best Mus eethe
u s tepal
-pulle haalean haxtLine: Check the hea ther in left
p age java.io) Methods
pul vaid pri
- puli wid pride d
- pille vaid print
-pulle vaid printject o: Prints Object
-puli vaid printString : Prints String ..
vaid primi The theme line by writing the
tie id print in bool bl. Prise n value the
- public void platinabled Prints double ved and then
- public void printit Prints Ent value and then tomis the
- Pull vaid pri
l l be t
publie wild prin t ing with String in the terminates the line
• ArrayLiat package java.util) Methods
- public boolean Arraybettype was a new ArrayList