ibr ahma
Posts: 1
Nickname: qaz
Registered: May, 2011
|
|
sorting linked list
|
Posted: May 26, 2011 7:29 AM
|
|
|
Advertisement
|
hello guys i wanna help
i have small Problem in my progamme
plzzzzz help me
i want make sorting for linked list
in Java
this my main class
import java.util.*; public class Hospital { public static void main(String[] args) { LinkedList <Patient_Records> list = new LinkedList <Patient_Records>(); AddList(list); printList(list); Collections.sort(list); } public static void AddList(LinkedList<Patient_Records> list) { list.add(new Patient_Records("Dr.Saad Kalid","Sunday","Ibrahim","Ahmed",109876543));
list.add(new Patient_Records("Bader","Al-Subei","Dr.Aziz Nasser","Monday",123456789));
list.add(new Patient_Records("Yasser","Al-Harthi","Dr.Hassn Hamad","Friday",1298733456)); } public static void printList(LinkedList<Patient_Records> list) { for (Patient_Records e : list) { System.out.println(e.toString() + "\n") ; } }
}
====================== public class Patient_Records extends Hospital_Records implements Comparable {
private String Dr_Name; private String Appoitments;
public Patient_Records(String Dr_Name,String Appoitments, String Patient_fName,String Patient_LName, int recID) { super(Patient_fName,Patient_LName,recID); this.Dr_Name = Dr_Name; this.Appoitments = Appoitments; }
public void setDr_Name(String DrName) { Dr_Name = DrName; }
public void setAppoitments(String Appiot) { Appoitments = Appiot; }
public String getDr_Name() { return Dr_Name; }
public String getAppoitment() { return Appoitments; }
public String toString() { return (super.toString() + "Doctor Name: " + getDr_Name() + "\nAppoitment on : " + getAppoitment()); } public int compareTo(Object o) {
// { }
|
|