Java search at a queue made of nodes

i need to make a program with 4 functions, "register, consult, delete and show all". I need to do it using the queue example, but using nodes. i've made 3 functions but i'm stuck at consult.

I need to check if a name is on the queue and return all his information. if that name is not found, i need to return that message "Not found".

i've done this part of code until here, then i stuck

//consult code

public void Consultar(){ String nameSearch;

   if (queueEmpty()){
       JOptionPane.showMessageDialog(null, "There are no clients on the queue");
   }
   else {
       nameSearch = JOptionPane.showInputDialog("enter the name you want to search");



         if (firstNode.equals(nameSearch)){



         }

         else {
            firstNode = firstNode.nextClient;   
         }

   }

}

PS: i can't use, arrays, arraylist, queue codes("LinkedList,..."). I can only use nodes to compare.

I'm glad if anyone can help me.

Thanks

Answers


public void consultar() { 

    if (queueEmpty()){
        JOptionPane.showMessageDialog(null, "There are no clients on the queue");
    }
    else {
        String nameSearch = JOptionPane.showInputDialog("enter the name you want to search");
        Node firstNode = this.getFirstNode(); // any method getting the root of your queue
        while(firstNode != null) {
               if (firstNode.equals(nameSearch)){
                   JOptionPane.showMessageDialog(null, firstNode.getAllClientData()); //method giving all client information
               }
               else {
                   firstNode = firstNode.nextClient;   
               }
        }
        JOptionPane.showMessageDialog(null, "Not Found");
}

Need Your Help

JPA and JSF Datatable Optimization

jsf optimization jpa datatable

I need to display a large table with about 1300 roles at one time. (I know I should use a data scroll but my users want to see the whole table at one time.) The table displays 4 columns. Two of those

Problem with BOOST_CHECK_CLOSE_FRACTION

c++ boost boost-test

I'm using the Boost::Test library, and I am trying to check if an actual percent value is close to the expected value: