Results 1 to 2 of 2

Thread: Queuing Nodes

  1. #1
    m4773rz is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default Queuing Nodes

    I am trying to make a basic program for an Air traffic controller to land planes as the come in using nodes but i cant get the nodes to order properly as when i add a new one in it deletes the first node.

    here is my code for the ordering of the nodes.

    Java Code:
    public void addPlane (PlaneNode planeIn) {
    
        if (start == null) {
            
            start = planeIn;
            end = planeIn;
            planeIn.setNext(null);
            planeIn.setPrevious(null);
            end = start;
            System.out.println("Thank you the plane has been added");
            System.out.println(planeIn.toString());
           } else {
    //        if(end == start ){
    //        // get the lastNode in queue
    //        PlaneNode currentFirst = new PlaneNode ();
    //        currentFirst = this.getEnd();
    //        currentFirst.setNext(planeIn);
    //        planeIn.setPrevious(currentFirst);
    //        planeIn.setNext(null);
    //        end = planeIn;
    //        System.out.println(currentFirst.toString());
    //        System.out.println(planeIn.toString());
    //        System.out.println("Thank you the plane has been added1");
    //             } else {
    //          
           // if already nodes in queue
           // get the lastNode in queue
            PlaneNode currentLast = this.getEnd();
             //  current update 
            currentLast.setNext(planeIn);    
            // new plane update
            planeIn.setPrevious(currentLast);
            planeIn.setNext(null);
    
            // update queue's last value to point to new plane 
            this.end = planeIn;
            System.out.println("Thank you the plane has been added2");
            }
    }
    The add planeIn PlaneNode works fine. Any help would be great. Thanks
    Matt
    Last edited by Norm; 01-04-2012 at 11:02 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Queuing Nodes

    Could you provide some print out that shows what is happening?
    What is the code you posted supposed to do?

    How can it be tested? Can you provide a small class with a main method that calls the posted method and shows the problem?

Similar Threads

  1. Inserting Nodes
    By myst in forum New To Java
    Replies: 2
    Last Post: 07-12-2010, 04:26 PM
  2. Problem with Nodes - need help!
    By Smithy in forum New To Java
    Replies: 3
    Last Post: 03-20-2010, 03:47 PM
  3. nodes
    By Dr Gonzo in forum New To Java
    Replies: 1
    Last Post: 12-08-2008, 04:22 PM
  4. nodes in java
    By ahsan in forum New To Java
    Replies: 0
    Last Post: 12-26-2007, 03:09 PM
  5. Queuing Bulk Web request For Later Execution
    By kathiravan in forum Web Frameworks
    Replies: 0
    Last Post: 10-31-2007, 11:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •