Results 1 to 3 of 3

Thread: Question about this method.

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    Question about this method.

    Code:
    Here's a simple example:
    
    class Bird {  
        int xPos, yPos;  
      
        double fly ( int x, int y ) {  
            double distance = Math.sqrt( x*x + y*y );  
            flap( distance );  
            xPos = x;  
            yPos = y;  
            return distance;  
        }  
        ...  
    }
    Can someone explain what this part:
    flap( distance );
    does, or what is happening with it? How is it being used? Is it a method inside the fly method?

    Also:
    Code:
    class Bird {  
        int xPos, yPos;  
        int xNest, yNest;  
        ...  
        double flyToNest( ) {  
            int xPos = xNest;  
            int yPos = yNest:  
            return ( fly( xPos, yPos ) );  
        }  
        ...  
    }
    How is the return statement working here?
    return ( fly( xPos, yPos ) );
    I know these are examples, but they are confusing me as it seems they are leaving things out. Whats being left out?
    Thanks in advance for clearing it up.
    Last edited by gjon; Dec 9th, 2005 at 08:33 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width