|
-
Help! Problem with this class
I need to make a program using at first an OrderedList (already defined with succes) and then a list of names with a priority number...
The problem is that I must define a type of object (Paziente) with two values (a String as a name and an int as a pririty value), but i must make this type working as a Comparable ( i MUST use Comparable objects)...
this is the class Paziente I tried to make:
public class Paziente implements Comparable{
private String nome; //name
private int prio; //priority
public Paziente(String k, int i) {
nome=k;
prio=i;
}
public int compareTo(Paziente x){
if (this.prio>x.prio) return 1;
if (this.prio<x.prio) return -1;
else {int comp=this.nome.compareTo(x.nome);
if (comp>0) return 1;
if (comp<0) return -1;
else return 0;
}
}
}
can u tell me where i'm doing wrong? Thx in advantage
Elio
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks