Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a class write a java code usig this information is an object representing a metro station with one or more letters indicating its name

create a class write a java code usig this information "is an object representing a metro station with one or more letters indicating its name. For example "A", "BA", "ZTR", etc. Each station has only one link to its next station. (This object should act like a node.) In addition to its name and the link, each station has a number showing its distance (in miles) to the next station."

The problem i am having is what should i write in ToString method

public class Station implements Comparable {

public int length;

private String name;

public Station() {

this.length = 2;

}

public Station(int len , String name) {

this.length = len;

this.name = name;

}

public String getName() {

return name;

}

@Override

public String toString() {

String dashes = " ";

for (int i = 0; i < this.length; i++) {

dashes += "-";

}

return dashes;

}

}

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions