The Artima Developer Community
Sponsored Link

Java Answers Forum
sorting linked list

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
ibr ahma

Posts: 1
Nickname: qaz
Registered: May, 2011

sorting linked list Posted: May 26, 2011 7:29 AM
Reply to this message Reply
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) {

//
{
}

Topic: Java Previous Topic   Next Topic Topic: some mp3 work only on one pc

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use