subject

Write a program that takes two stations as input from the user and calculates a route between the two stations. Your program must read the transport information from data. txt and initialize each line. In your program you could think about presenting a line as an object of class Line which has the methods listed below, and TransitSystem which keeps track of the Lines and uses them to find the route. To simplify, assume trains only run in one direction and you can only transfer once. User input:
Enter two stations separated by commas: Green Park, Southgate
The output will be one of
There is not route between stations Green Park and Southgate
Take line Red from Green Park to Southgate
Take line Blue from Green Park, transfer to the Red line at XXX, and ride to Southgate
The input file with have the format
Line_name1 number_of_stations
Station1 station2 station3 …
Line_name2 number_of_stations
Station1 station2 station3 …
You should have three classes: Line, RouteFinder and Driver
Line will have public methods:
public void addStation(String station)
public boolean hasStation(String station)
public String findTransfer(Line otherLine)
public String getName()
public void setName(String n)
RouteFinder will have public methods:
public void readLines(String fileName)
public boolean hasRoute(String startStation, String endStation)
public void printRoute()
Driver will have the main method which instantiates the RouteFinder and reads the data file. It then asks the user for input and uses the other classes to find and print the route.
Classes may have any private methods and variables that you need to solve the problem.
Testing:
Write your own test data and include a test in your driver to use it.
What possible cases should you cover?
What to submit (in a single zip file):
Line. java
RouteFinder. java
Driver. java
testData. txt
Examples:
Suppose you had the following lines:
Red: SouthGate SODO Mercer Island Factoria === Issaquah
Green: Renton Factoria Bellevue Kirkland Bothell
Blue: Capital Hill UW Seattle Lynnwood Bothell Totem Lake
Console:
Enter two stations, separated by a comma: Renton, Issaquah
Take the Green Line from Renton, transfer to the Red Line at Factoria, and continue to Issaquah
Enter two stations, separated by a comma: UW Seattle, Bothell
Take the Blue Line from UW Seattle to Bothell
Enter two stations, separated by a comma: Capital Hill, Bellevue
There is no route between stations SODO and Bellevue
Hints:
The most difficult part of the program is HasRoute.
Start with the easy case of both the start and end being on the same line and solve that.
If you can’t find it on your line, how would you find a line that has the end station and also has a transfer?
Write out pseudocode for your logic before trying to code it.
Lines Simple txt:
Red 5
A B C D E
Blue 6
F G C H I J
Green 6
F K L M N O
Yellow 5
P Q L R S
Lines Local txt:
Red 6
SouthGate SODO Mercer Island Factoria Issaquah
Green 5
Renton Factoria Bellevue Kirkland Bothell
Blue 5
CapitalHill UWSeattle Lynnwood Bothell TotemLake

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:30
Data for which there is temporarily no room in ram is diverted to where on your computer? question 9 options: a) the paging file on the hard drive b) the system file on the hard drive c) the memory file on the hard drive d) the cpu cache
Answers: 2
question
Computers and Technology, 23.06.2019 09:20
How to print: number is equal to: 1 and it is odd number number is equal to: 2 and it is even number number is equal to: 3 and it is odd number number is equal to: 4 and it is even number in the console using java using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
You can apply several different worksheet themes from which tab?
Answers: 1
You know the right answer?
Write a program that takes two stations as input from the user and calculates a route between the tw...
Questions
question
History, 27.09.2019 00:30
question
Mathematics, 27.09.2019 00:30
question
Social Studies, 27.09.2019 00:30
question
English, 27.09.2019 00:30
Questions on the website: 13722360