All pastes #493249 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-17 17:48 UTC
rendered paste body
import java.io.*;

public class BirdProgram
{
	public static void main(String[] args) throws IOException
	{
		try{
			BufferedReader br = new BufferedReader(new FileReader("birds.txt"));
			String input = br.readLine();
			Boolean find;
			BirdNode newNode = new BirdNode(input);
			BirdLinkedList list = new BirdLinkedList(newNode);
		
			while(input != null)
			{
				find = list.find(newNode);
				
				if (find == false)
				{
					list.insertFront(newNode);
				}
			
				input = br.readLine();			
			}
		
			System.out.println("This is the original list: ");
			System.out.println();
			list.print();
		
			//BirdLinkedList sort = new BirdLinkedList(newNode);
		
			list.ref = list.head;
			list.highest = list.head;
		
			BirdLinkedList sort = new BirdLinkedList(null); 
			while(list.head != null) 
			{ 
				BirdNode n = list.head; 
				BirdNode highest = n; 
				while(n != null) 
				{ 
					if(n.count > highest.count) 
					highest = n; 
					n = n.next; 
				} 
				sort.insertEnd(highest); 
				list.remove(highest); 
			} 


			System.out.println();
			System.out.println("Sorted List: ");
			System.out.println();
			sort.print();
			br.close();
			BufferedReader br2 = new BufferedReader(new FileReader("birds2.txt"));
			input = br2.readLine();
		
			while(input != null)
			{
				sort.remove(newNode);
				input = br2.readLine();
			}	
		
			System.out.println();
			System.out.println("Sorted list without rejected birds: ");
			System.out.println();
			sort.print();
		}
		catch(IOException e)
		{
			System.out.println(e.getMessage());
		}
	}
}