Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!image text in transcribedimage text in transcribedimage text in transcribed

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

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

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions