FileDocCategorySizeDatePackage
Mountains.javaAPI DocExample721Wed Mar 06 14:46:52 GMT 2002myprojects.linktest

Mountains.java

package myprojects.linktest;



public class Mountains implements Comparable {
	private String name;
	private int height;
	
	public Mountains(String name, int height) {
		setDetails(name,height);
	}
	
	public void setDetails(String name, int height) {
		this.name = name;
		this.height = height;
	}
	
	public int getHeight() {
		return height;
	}
	
	public String getName() {
		return name;
	}
	
	public void displayDetails() {
		System.out.println("Mountain "+name+ " is "+height+" metres high");
	}
	
	public int compareTo(Object o) {
		Mountains m = (Mountains) o;
		if(m.height < height) {
			return -1;
		} else if (m.height == height) {
			return 0;
		}
		return 1;
	}
	
}