package duixiang;
class Station
{
private int number;
private String name;
private int couser=100;
private Station(){}
private static Station s=new Station();//
public static Station getInstense()//此处声明为static是为了让该方法可以以类名.函数名的形式被调用而不必在建立对象
{
return s;
}
public int lestCouser()
{
couser--;
return couser;
}
public void getMessage(int number,String name)
{
this.number=number;
this.name=name;
}
public void show()
{
System.out.println(number+"..."+name+"..."+couser);
}
}
public class Single {
public static void main(String [] args)
{
Station s1=Station.getInstense();
s1.lestCouser();
s1.getMessage(5, "cs");
s1.show();
Station s2=Station.getInstense();
s2.getMessage(1, "wh");
s2.lestCouser();
s2.show();
}
}
package duixiang;class Station{ private int number; private String name; private int couser=100; private Station(){} private static Station s=new Station();// public static Station getInste