Question: I am writing a java project about find station using name the code can pass the test about itself but it can't pass the main

I am writing a java project about find station using name

the code can pass the test about itself but it can't pass the main test.and always have the exception I don't know why.

  • TrainStation leftTerminus : the terminal station on the left

  • TrainStation rightTerminus : the terminal station on the right

  • get name means get the name of the station

  • get tight means get the right staiton

  • thank you!I am writing a java project about find station using name thecode can pass the test about itself but it can't pass themain test.and always have the exception I don't know why. TrainStation leftTerminus

public TrainStation findstation(String name) : this method take as input the name of a station, and searches through the line to return the TrainStation of this name. All station names are unique. Iterate over the line until you find a station of the right name. If the station is not found, throw a StationNotFoundException // You can modify the header to this method to handle an exception. You cannot public TrainStation findStation(String name) { TrainStation medium=this. leftTerminus; while (!medium.equals(this.rightTerminus)) { if (medium.getName().equals (name)) { return medium; medium=medium.getRight(); if (name.equals(this.rightTerminus.getName())){ return this.rightTerminus; }else { throw new StationNotFoundException (name); Exception in thread "main" StationNotFoundException [Scarlet]|| at TrainLine. findStation (TrainLine.java:184) at TrainNetwork.travel(TrainNetwork.java:47) at tester.main(tester.java:175) public TrainStation findstation(String name) : this method take as input the name of a station, and searches through the line to return the TrainStation of this name. All station names are unique. Iterate over the line until you find a station of the right name. If the station is not found, throw a StationNotFoundException // You can modify the header to this method to handle an exception. You cannot public TrainStation findStation(String name) { TrainStation medium=this. leftTerminus; while (!medium.equals(this.rightTerminus)) { if (medium.getName().equals (name)) { return medium; medium=medium.getRight(); if (name.equals(this.rightTerminus.getName())){ return this.rightTerminus; }else { throw new StationNotFoundException (name); Exception in thread "main" StationNotFoundException [Scarlet]|| at TrainLine. findStation (TrainLine.java:184) at TrainNetwork.travel(TrainNetwork.java:47) at tester.main(tester.java:175)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!