+1(805) 568 7317

java programming asap write a program called routerecommender javathat reads in a bu 5122041

JAVA PROGRAMMING ASAP Write a program called RouteRecommender.javathat reads in a bus network and one or more trip queries from theconsole ( and outputs a trip recommendation for eachquery. Your RouteRecommender class must implement theprovided Tester interface and also contain the main() method whereyour program starts running. This is because your programwill be tested via this interface. The interface contains a singlemethod:

public ArrayList compute( Scanner input );

This method must perform the required computation. Input

The compute() method takes a Scanner object, which contains theinput. The input is divided into two parts: a bus network portionand a query portion. The bus network part consists of one or morebus routes followed by a line with a single end. Each bus routebegins with the line:

route R F

where R is the route number and F denotes the frequency of thebusses on this route, and will be one of 10, 15, 20, or 30, meaningthe bus runs every 10, 15, 20, or 30 minutes. This line is followedby one or more lines specifying bus stops on the route. Each busstop is specied by a name and the time it takes the bus to arrivefrom the previous bus stop.


where S is a single word with no spaces, and T is an integer,denoting the time it takes for the bus to travel from the previousbus stop. For the rst bus stop in a route, the number isinterpreted as the number of minutes after the hour that the busarrives. A bus route is ended by a single line containing the endkey word. After all bus routes are done, a second line containingthe end keyword occurs. The second portion of the input consist ofone or more queries for route recommendations. Each query is atriple of the form

Orig Dest t

where Orig is where the rider will start and Dest is where therider is trying to get to. The third value, t, is an integer,between 0 and 60, indicating the time in minutes past the hour whenthe rider will arrive at the starting bus stop. The last line ofthe queries section contains the end keyword. Output

The method compute( Scanner input ) should return an ArrayList ofStrings denoting the route recommendations, one per query. Eachroute recommendation consists of two or more lines. The rst line ofa recommendation is of the form: At stop S take bus #B

where S is where rider is to board bus and B is the route number.For each stop where the rider needs to switch busses, output a lineof the form: At stop S switch to bus #B where S and B are the samebus stop and route number, just as before. The last line of therecommendation should be of the form: Get off at stop S where S isthe destination stop. Junit Test Class import static org.junit.jupiter.api.Assertions.*;import java.util.ArrayList;import java.util.Scanner;import org.junit.jupiter.api.Test;class RouteRecommenderTest { private static String testInput1 = “route 2 15n” + “A3 4n” + “B3 3n” + “C3 5n” + “D3 2n” + “endn” + “route 4 10n” + “B1 3n” + “B2 1n” + “B3 6n” + “B4 3n” + “endn” + “route 3 20n” + “D3 3n” + “D4 1n” + “C4 6n” + “B4 4n” + “A4 3n” + “endn” + “endn” + “A3 A4 1n” + “B1 C4 2n” + “endn” + “”; private static String [] testOutput1 = { “At stop A3 take bus #2”, “At stop B3 switch to bus #4”, “At stop B4 switch to bus #3”, “Get off at stop A4”, “At stop B1 take bus #4”, “At stop B3 switch to bus #2”, “At stop D3 switch to bus #3”, “Get off at stop C4” }; private static Scanner mkTest( String input ) { return new Scanner( input ); } private static ArrayList mkOutput( String [] output ) { ArrayList al = new ArrayList(); for( String s : output ) { al.add( s ); } return al; } private static boolean doTest( String input, String [] output ) { Tester t = new RouteRecommender(); ArrayList al = t.compute( mkTest( input ) ); System.out.println( “Input: ” ); System.out.println( input ); System.out.println( “Generated output” ); for( String s : al ) { System.out.println( s ); } System.out.println( “Expected output” ); for( String s : output ) { System.out.println( s ); } System.out.println( “—————————————————” ); return al != null && al.equals( mkOutput( output ) ); } @Test void test1() { assertTrue( doTest( testInput1, testOutput1 ), “Multiple queries” ); }} . . .

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon

Order Now