I have tried searching the forum (and google) and can't seem to come with anything that solves my problem. either that or i just really dont get it. My professor was to supply a class that creates an object of a class that I will create called PriorityQueue.

PriorityQueue to my understanding is to take the place of the LinkedList class as i was strictly instructed not to use the LinkedList class. What i am wondering is this, with an array i could use index's within my PriorityQueue class and wouldn't have to worry. but not without being able to use indexes, how am i supposed to keep track of all the names that can be entered by the user? After i enter more than 2 names, how is the program to keep track of any new names entered?

The first object should hold the first node for as long as the program runs. But after i take in a few more names from the user, how am i supposed to know what was ever in the second node? Since tempNode gets new data everytime a user enters a name, and we keep moving position up the list as we get names, but its really not even a list. im just changing the values of .data. Can anyone understand what I'm saying? Would an iterator be of use here or since i'm not using java's linked list class it wouldn't work?

I'm so confused right now. Most of the examples i see online are for classes that use either the java supplied linkedlist or create their own and do everything within that class.

My professor has supplied this amount of code to me already.

Code:

/**
StaffList.java
Provided by instructor for use in Project 6 - Priority Queue
*/

import java.io.*;
/**
Demonstrates use of PriorityQueue class in compiling an ordered list of staff.
*/

public class StaffList
{  
   public static void main(String[] args) throws IOException
   {
      PriorityQueue staff = new PriorityQueue();
            
      BufferedReader in =
         new BufferedReader (new InputStreamReader (System.in));

      System.out.print("Enter a name to add to the staff, . to quit: ");
      String name = in.readLine();

      while (!name.equals("."))
      {
         staff.insert(name); 
         System.out.println("The updated staff list:");
         System.out.println(staff);
         System.out.print("Enter a name to add to the staff, . to quit: ");
         name = in.readLine();
      }  
   }
}
I have coded this much, but its hardly anything at all.

Code:

import java.util.*;

public class PriorityQueue
{
	private class Node
	{
	     public Object data;
	     public Node next;
	}

	public PriorityQueue()
	{
	     first = null;
	}

	public boolean empty()
	{
	     return (newNode == null);
	}

	public void insert(Comparable obj)
	{
	   Node tempNode = new Node();
	   tempNode.next = newNode;
	   tempNode.data = obj;
	  //need to test if empty first
	   if (empty())
	   {
	       first = tempNode;
	   }
		
	   newNode = tempNode;

	}

	public String toString()
	{
                   //figure out the list before moving down it and printing
	   String returnStr = (String)newNode.data;
	   return (String)returnStr;
	}
	private Node newNode;
	private Node first;
	private Node position;
}