1. Project Specification

Design, implement and test a Java program for the operation management of a public transport company consisting of three classes: Station, TransportLine and TransportSystem. As an example, WashingtonDCMetro could be an object of type TransportSystem, GL (i.e. Green Line) could be an object of type TransportLine while Anacostia could be an object of type Station.

Class Station defines the station name, line ID (such as GL), the distance (in meters) to the next stop, a constructor with arguments and get / set type methods.
Class TransportLine defines as instance variables the line ID (String) and an ArrrayList which stores the stations of the transport line (objects instances of class Station). Class TransportLine also defines a constructor with one argument (line ID) which builds a TransportLine object having an empty array list of stations. The TransportLine class has the following methods: addStation - adds a station to the transport line, removes a station specified by name, getLineID, getLength, toString - returns the string representation of the TransportLine object.

Class TransportSystem contains an ArrayList which stores the transport lines of the transport system. It also defines a default constructor which builds a transport system object empty of transport lines. The TransportSystem class has the following methods: addLine - adds a transport line, removeLine – removes a transport line specified by ID, getLineLength – returns the length of the transport line specified by ID, getLengthAllLines, getLongestLine, getTransferStationsMax – returns the name(s) of the transfer station(s) which interconnect(s) the largest number of transport lines, getTransferLinesForStation - returns the IDs of the transport lines interconnected by the specified transfer station name, toString - returns the string representation of the TransportSystem object.
An additional class Test will be defined as a driver for testing the program. The driver program should build an initial TransportSystem object populated with values taken from an input file (see the Example section).
After building the TransportSystem object, in a loop, the program should invite the user to select (for execution) one of the following operations: (1) display the string representation of the transport system; (2) addLine; (3) removeLine; (4) getLineLength; (5) getLengthAllLines; (6) getLongestLine; (7) getTransferStationMax; (8) getTransferLinesForStation and (0) exit the loop and the program. As a result of each operation execution, relevant information will be displayed to the user. For example, as a result of executing getTransferStationMax, the name(s) of the transfer station(s) which connect(s) the largest number of lines should be shown to the console.
If an operation requires additional information, the user will be prompted to enter it.

Additional classes and methods could be defined if necessary.
1. The input file (a simple .txt file) should be generated by the students using a simple text editor such as Notepad.
2. You may assume that there are no errors in the input file structure.

2. Example
The text file WashingtonDCMetro.txt posted below (in this week activities page) is an example of input data file. It includes a simplified view of the Washington DC Metro System (the distances between the stations are not actually reflecting the reality).
The input file is organized on transport lines (see the text file WashingtonDCMetro.txt). The input file example contains the description of three transport lines: Red Line, Orange Line and Green Line. A transport line is identified in the data file by the keyword TransportLine followed by the transport line ID. The stations of each transport line are described on the following text file lines (one station per text file line). Each station description specifies the station name (for example Shady Grove), the coma separator and the distance (in meters) to the next station (in the example, 2100 is the distance from Shady Grove station to the next station, i.e. the Rockville station).

3. Submission Requirements
1. All .java source files and the input file.
2. A document file including relevant screenshots showing program execution as a result of test cases.
3. A document file describing your solution which should include the following elements: (3.1) a short problem analysis, (3.2) main design decisions, (3.3) assumptions, (3.4) short description of classes, (3.5) user interface, (3.6) test plan, (3.7) error handling, (3.8) lessons learned and (3.9) possible future developments. The size of the document should be of 3 pages, single spaced, font size 12.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public static void main(String[] args) {
       TransportSystem transportSystem = new TransportSystem();
       if (readFile(transportSystem, "WashingtonDCMetro.txt")) {
            int selection = -1;
            String line;
            String lineID;
            String name;
            double distance;
            Scanner keyboard = new Scanner(;
            int t = 0;
            while (selection != 0) {               
                System.out.println("Enter your selection");
                System.out.println("(1) display the string representation of the transport system; \n"
                        + "(2) addLine; \n"
                        + "(3) removeLine; \n"
                        + "(4) getLineLength; \n"
                        + "(5) getLengthAllLines; \n"
                        + "(6) getLongestLine; \n"
                        + "(7) getTransferStationMax; \n"
                        + "(8) getTransferLinesForStation \n"
                        + "(0) exit");
                selection = keyboard.nextInt();
                   case 1:
                        System.out.println(transportSystem.toString() + "\n");
                   case 2:
                        System.out.print("Enter LineID: ");
                        lineID =;                        
                        TransportLine transportLine = new TransportLine(lineID);...

By purchasing this solution you'll be able to access the following files:

50% discount

$60.00 $30.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats