Reference no: EM13347898
Design and implement a set of classes and interfaces and use them to evaluate the RTA's resource requirements.
Your program must meet the subsequent guidelines:
- You must use at least one abstract class, with appropriate final and abstract methods, and at least one interface; you may wish to have several abstract classes and interfaces. You must have at least one abstract method and one final method in at least one class.
- You may not represent the route type (bus, urban rail or commuter rail) or the right of way type (shared or dedicated) as a data member.
- Each subclass must inherit its data and methods from a superclass or an interface to the maximum extent possible. Override superclass methods as needed.
- Each subclass must not contain data that is not relevant. For example, the Red Line may not have stops or additional vehicles, and the 77 bus may not have stations, staff per train, vehicles per train, or staff per station. A subclass must not have any data marked "na" in the table above. You may not set "na" variables equal to one in a subclass that does not use them; they must not be present.
- If a route type has a certain data member, your design must require that it be present. For example, your design must require all shared ROW routes to have a number of stops. All urban rail and commuter rail routes must have a number of stations, staff/station and staff/train. o An interface cannot force an implementing class to have a data member, but if the interface has a method getX(), the implementing method will need to either have a data member X or compute X. This meets the requirement of the problem set.
- You may use protected access for data members to be inherited by subclasses, except that any data member managed by a final method must be private.
- Data members and methods must be defined in the highest level of the inheritance tree possible. For example, the data members that exist for all routes must be defined in a Route class, not in BusRoute, UrbanRailRoute or CommuterRail classes. o All of your methods will be very simple; they should all be just one line.
- You must write classes or subclasses for the combinations of Route and ROW listed at the in the table above. You should not write any other combination of Route and ROW. o You do not need to have a class for bus routes just on dedicated ROW o You do not need to have a class for urban rail routes just on shared ROW
- You must write a class RouteTest with only a main() method to test your software. In main(), write code to:
- Create objects for five routes: bus 77, Silver Line/Airport, Red Line, Green Line B and Lowell Line
- Compute and output (System.out.println) the number of vehicles and staff required for each route, including the number of engines for commuter rail routes. You will have fractional values, which is fine.
- Output the number of stops and/or stations for each route.
- Compute and output the total number of vehicles for bus routes, for urban rail routes and for commuter rail routes. (This will be three totals) You must use the instanceOf keyword in your loop to determine what kind of vehicle is used on a route, since all routes have the
same getVehicle() method. Include commuter rail engines, using getEngine().
- Compute and output the total staff across all routes.