sorting linked list

Discussion in 'Java' started by qaz, May 25, 2011.

  1. qaz

    qaz

    Joined:
    May 25, 2011
    Messages:
    2
    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) {
    
    
    {
    }
     
    qaz, May 25, 2011
    #1
    1. Advertising

  2. qaz

    qaz

    Joined:
    May 25, 2011
    Messages:
    2
    plzzzzz guys help me:argh:
     
    qaz, May 26, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    492
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    488
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    526
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    685
    John Carson
    Oct 2, 2006
  5. jawdoc
    Replies:
    9
    Views:
    778
    Chris Thomasson
    Mar 10, 2008
Loading...

Share This Page