Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:20, alcantar28eduin
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
image
Computers and Technology, 22.06.2019 20:00, ksanchez2100
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, aesthetickait
How do you take a green screen out of the video while editing?
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, hargunk329
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
Do you know the correct answer?
Write a program that takes two stations as input from the user and calculates a route between the tw...

Questions in other subjects:

Konu
Mathematics, 01.10.2019 15:10
Konu
Social Studies, 01.10.2019 15:10