Created
November 5, 2012 05:23
-
-
Save anirudhjoshi/4015495 to your computer and use it in GitHub Desktop.
Employee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Employee implements Comparable { | |
private String id; | |
private String name; | |
public Employee(String id, String name){ | |
setId(id); | |
setName(name); | |
} | |
public String getId(){ | |
return id; | |
} | |
public String getName(){ | |
return name; | |
} | |
public void setId(String id){ | |
this.id = id; | |
} | |
public void setName(String name){ | |
this.name = name; | |
} | |
@Override | |
public String toString(){ | |
return "ID: " + id + " NAME: " + name; | |
} | |
@Override | |
public int compareTo(Object o){ | |
Employee c = (Employee) o; | |
Integer a = Integer.parseInt(id); | |
Integer b = Integer.parseInt(c.id); | |
return a.compareTo(b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment