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, 23.06.2019 00:00
What season was better from fortnite?
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Now you’re on your own. include a short summary of this section with plots in your lab report. write a matlab script file to do steps (a) through (d) below. include a listing of the script file with your report. 1 the soundsc(xx,fs) function requires two arguments: the first one (xx) contains the vector of data to be played, the second argument (fs) is the sampling rate for playing the samples. in addition, soundsc(xx,fs) does automatic scaling and then calls sound(xx,fs) to actually play the signal. mcclellan, schafer, and yoder, dsp first, 2e, isbn 0-13-065562-7. prentice hall, upper saddle river, nj 07458. c 2015 pearson education, inc. 4 mcclellan, schafer and yoder, signal processing first. prentice hall, upper saddle river, new jersey, 2003. c 2003 prentice hall. (a) generate a time vector (tt) to cover a range of t that will exhibit approximately two cycles of the 4000 hz sinusoids defined in the next part, part (b). use a definition for tt similar to part 2.2(d). if we use t to denote the period of the sinusoids, define the starting time of the vector tt to be equal to t , and the ending time as ct . then the two cycles will include t d 0. finally, make sure that you have at least 25 samples per period of the sinusoidal wave. in other words, when you use the colon operator to define the time vector, make the increment small enough to generate 25 samples per period. (b) generate two 4000 hz sinusoids with arbitrary amplitude and time-shift. x1.t / d a1 cos.2
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
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
Questions on the website: 13722359