canGo
Category: Token-Based File Processing
Author: Benson Limketkai
Book Chapter: 5.4
Problem: canGo
Write a static method canGo that accepts 3 parameters: a Scanner holding a sequence of strings representing sequential bus stops, a string representing a start location, and a string representing an end destination. The method should return true if the start location appears before the end location in the sequence of bus stops; otherwise, it should return false.
For example, suppose a Scanner variable named stops contained the following bus stops:
UVillage HUB UW-Medical MeanyHall UW
Here are some example calls to the method and their expected return results
+------------------------------------------+--------------+
| Call | Return Value |
+------------------------------------------+--------------+
| canGo(stops, "UVillage", "MeanyHall") | true |
+------------------------------------------+--------------+
| canGo(stops, "UW-Medical", "UW") | true |
+------------------------------------------+--------------+
| canGo(stops, "MeanyHall", "UVillage") | false |
+------------------------------------------+--------------+
| canGo(stops, "Earth", "UW-Medical") | false |
+------------------------------------------+--------------+