01: /**
02:    A country with a name and area.
03: */
04: public class Country implements Comparable
05: {
06:    /**
07:       Constructs a country.
08:       @param aName the name of the country
09:       @param anArea the area of the country
10:    */
11:    public Country(String aName, double anArea)
12:    {
13:       name = aName;
14:       area = anArea;
15:    }
16: 
17:    /**
18:       Gets the name of the country.
19:       @return the name
20:    */
21:    public String getName()
22:    {
23:       return name;
24:    }
25: 
26:    /**
27:       Gets the area of the country.
28:       @return the area
29:    */
30:    public double getArea()
31:    {
32:       return area;
33:    }
34: 
35: 
36:    /**
37:       Compares two countries by area.
38:       @param otherObject the other country
39:       @return a negative number if this country has a smaller
40:       area than otherCountry, 0 if the areas are the same, 
41:       a positive number otherwise
42:    */
43:    public int compareTo(Object otherObject)
44:    {
45:       Country other = (Country) otherObject;
46:       if (area < other.area) return -1;
47:       if (area > other.area) return 1;
48:       return 0;
49:    }
50: 
51:    private String name;
52:    private double area;
53: }