计算车站距离

阅读更多
public final class Demo {
	
	private static int[] miles = new int[5];
	private static String[] stations = {"S1","S2","S3","S4","S5","S6"};
	
	public static void main(String[] args)
	{
		Station s1 = new Station("S6", "S5", 5);
		Station s2 = new Station("S1", "S2", 2);
		Station s3 = new Station("S4", "S3", 3);
		Station s4 = new Station("S2", "S3", 6);
		Station s5 = new Station("S4", "S5", 10);
		Station[] s = {s1,s2,s3,s4,s5};
		getMiles(s);
	}

	public static void getMiles(Station[] s)
	{
	    for(int i=0; ia)
	    	{
	    		for(int j=0; ja:"+(a-1));
	    				break;
	    			}
		    	}
	    	}
	    	else
	    	{
	    		for(int j=0; jp:"+(p-1));
	    				break;
	    			}
		    	}
	    	}
	    }
	    for(int w=0; w 
  

 

public class Station {

	private String preStation;
	private String aftStation;
	private int distance;

	public Station(String preStation, String aftStation, int distance) {
		this.preStation = preStation;
		this.aftStation = aftStation;
		this.distance = distance;
	}

	public String getPreStation() {
		return preStation;
	}

	public void setPreStation(String preStation) {
		this.preStation = preStation;
	}

	public String getAftStation() {
		return aftStation;
	}

	public void setAftStation(String aftStation) {
		this.aftStation = aftStation;
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
	}

}

 

你可能感兴趣的:(计算车站距离)