package 单例模式;
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
public class Country implements Comparable<Country>
{
int jin;
int yin;
int tong;
String name;
public int compareTo(Country o) {
// TODO Auto-generated method stub
if(this.jin<o.jin)
{
return 1;
}
else if(this.jin>o.jin )
{
return -1;
}
else
{
if(this.yin<o.yin)
{
return 1;
}
else if(this.yin>o.yin)
{
return -1;
}
else
{
if(this.tong<o.tong)
{
return 1;
}
else if(this.tong>o.tong)
{
return -1;
}
else
{
return this.name.compareTo(o.name );
}
}
}
}
public Country(int jin, int yin, int tong, String name) {
super();
this.jin = jin;
this.yin = yin;
this.tong = tong;
this.name = name;
}
public static void main(String[] args) {
ArrayList<Country> array=new ArrayList<Country>();
Country c[]=new Country[4];
c[0]=new Country(32,23,10,"China");
c[1]=new Country(32,23,10,"Coo");
c[2]=new Country(20,13,23,"Jpan");
c[3]=new Country(20,12,34,"lisi");
Arrays.sort(c);
for(int i=0;i<4;i++)
{
System.out.println(c[i].name +"--"+c[i].jin+"--"+c[i].tong+"--"+c[i].tong);
}
}
}