sorting linked list

qaz

Joined
May 25, 2011
Messages
2
Reaction score
0
hello guys i wanna help

i have small Problem in my progamme

plzzzzz help me

i want make sorting for linked list
and i dont how can i do it

in Java


this my main class
Code:
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") ;
                }
}

Code:
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) {


{
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top