Question: 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

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!