/******************************************************************** In this lab we will design two different ways to represent a transit system. We will then design methods for the system, such as finding all stations on a given route, or finding a route from one station to another. The goals are: experience how the way the data is represented affects the design of methods that process the data understand the distinction between information and its representation as classes of data recall and practice writing methods using the accumulator style - and understand the need for accumulators *******************************************************************/ /******************************************************************* Problem statement: The information about the city transit system allows the passengers to find out about the routes and stations and schdules. We are asked to design this computerized system. For each station we need to record the name, and its location. Each of the train routes has a name and a color. For each route segment between two stations, we need to know the origin and destination, the route that connects them, and the time it takes to travel from one station to another. The transit system record all this information. We impose two restrictions on the system as follows: 1. There are at most two routes that lead from any given station to another station. 2. It is impossible to travel through the same station twice in one trip. Here is a sample transit system: Sample big transit: A / \ / \ / \ / \ B C / \ / \ / \ / \ F G S E \ / \ /| / | / \ / | / | H K | N | / \ | / \ \ / \|/ \ \ / P T Z Blue: A -5- B -3- F -8- Z Red: A -3- C -4- S -5- K -3- Z Green: B -2- G -5- K -3- P Yellow: C -3- E -4- N -5- P White: G -4- H Black: N -3- T S -6- P You may want to draw a color picture, to better understand the available information. Here is another, simpler system we will work with at the beginning: Sample simple transit: B / \ / \ F G \ / \ | / \ | H K | / \ \ / \ \ / P Z Blue: B -3- F -8- Z Green: B -2- G -5- K -3- P Red: K -3- Z White: G -4- H ********************************************************************/ /******************************************************************* Here is another data definition for this system: OneStop is a structure Route route int minutes Station origin Station destination Station consists of String name Posn loc Route is a structure String name Color color Transit is a list of OneStop-s We give you the class definitions, mainly because the implementation of the 'same' method needed for comparisons and test cases is tedious. However, you need to complete the design of these classes by making examples of data that represent the simple transit system. Design these classes and make examples of data for the simple transit system. To simplify the equality comparison, add the following method to the class OneStep: String makeString(){ return "* ".concat(this.route.name).concat(" from: ") .concat(this.origin.name).concat(" to: ") .concat(this.destination.name).concat(" *"); and add a similar method to the classes that represent the transit. Compare any two lists of OneStop by comparing the resulting String-s. Finally, design the mehtod that produces a list of stations that follow after the given station in this transit on any of the routes. Notice, that while in the previous class hierarchy knowing which station we are at was sufficient to find all next stations, here we need to query the whole transit system. *******************************************************************/