Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2: [BusRouteSearchEngine Mini-Project] Create a RouteManager class. This class will store instances of the BusRoute class, and support generating a list of potential itineraries. It

Q2: [BusRouteSearchEngine Mini-Project] Create a RouteManager class. This class will store instances of the BusRoute class, and support generating a list of potential itineraries. It should contain one constructor, two instance variables (an array of BusRoutes, and something that counts the number of bus routes in the system), and four methods (addBusRoute, increaseSize, findItineraries, shrinkItineraries). [25 points] default constructor: will set up the instances variables with zero bus routes. addBusRoute(...): Adds a bus route to the bus routes array. Uses the increaseSize() method if the array is full. increaseSize(): Doubles the size of the bus routes array, while keeping whatever is already there. Make this a private method. findItineraries(...): Searches the bus routes based on source bus station, destination bus station, and departure time, to find 1-bus route and 2-bus route itineraries meeting those criteria. When searching for 2-bus route itineraries, checks that the bus routes have a connecting city, and that the first arrives in time for the second. Your method should create an array of potential itineraries that can be returned. (If it helps, you may assume that this method will never find more than 100 itineraries.) Use the shrinkItineraries() method to "clean up" up the potential itineraries array; see below. Hint: use loops to search for all the bus routes in the bus routes variable, check if they meet the criteria, and then create a new Itinerary object if the criteria is met. shrinkItineraries(...). Takes an array of itineraries, where some of the later indices are unused (null), and returns a new array of itineraries where there are no empty indices. Make this a private method.

image text in transcribed

Route Manager bus Routes BusRouteD busRoute Count int RouteManager0 addBusRoute(new BusRoute BusRoute) void increasesize() void findltineraries(src BusStation, est BusStation, idealDeparture Time) ItineraryD) shrinktineraries(itineraries Itineral ItineraryD) Sample output from RouteManagerTest: output Hwo58 run) variables Action Items $10.00 8:20AM San Diego reyhound 136 6:50PM 6:16AM San Diego (SAIl San Francisco BoltBus 201 BUILD SUCCESSFUL total time Submission Process: Please name your files (and classes) as "ltineraryjava and "RouteManager.java" Route Manager bus Routes BusRouteD busRoute Count int RouteManager0 addBusRoute(new BusRoute BusRoute) void increasesize() void findltineraries(src BusStation, est BusStation, idealDeparture Time) ItineraryD) shrinktineraries(itineraries Itineral ItineraryD) Sample output from RouteManagerTest: output Hwo58 run) variables Action Items $10.00 8:20AM San Diego reyhound 136 6:50PM 6:16AM San Diego (SAIl San Francisco BoltBus 201 BUILD SUCCESSFUL total time Submission Process: Please name your files (and classes) as "ltineraryjava and "RouteManager.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Are the rules readily available?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago