Results 1 to 10 of 10
  1. #1
    fatmig is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default spiral recursion

    first part does a spiral
    second part is in recursion but its not workin
    can anyone help


    // variables used for ends of lines
    int x1 = 0;
    int y1 = 0;
    int x2 = 0;
    int y2 = 0;;

    int offset = 5;

    // set initial starting values for line
    x1 = 200; // find center of width
    y1 = 100; // find center of height

    // set initial endpoints for line
    x2 = x1 + 100;
    y2 = y1;

    // in a loop draw line and change endpoints
    for( int i=0; i<=20; i++) {
    myCanvas.drawLine(x1,y1,x2,y2);
    x1+=offset;
    y2+=offset;
    myCanvas.wait(15);
    }*/

    //This is the recursive method for the draw2 exercise
    //recursiveDraw2(200,300,100,100,5,20);



    }//end method draw2()

    /** Uncomment the method and insert the correct parameters...*/

    //Recursive method for draw2 exercise
    void recursiveDraw2(int x1,int y1,int x2,int y2,int offset,int i){

    if (i==0){
    myCanvas.drawLine(x1,y1,x2,y2);
    myCanvas.wait(15);
    }


    else {

    //Draw line correspondent to actual iteration
    myCanvas.drawLine(x1,y1,x2,y2);
    myCanvas.wait(15);

    //Draw the next line in a recursive way
    recursiveDraw2(x1,y1+offset,x2,y2+offset,offset,i-1);

    }
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    [max smart]
    Ahh the old "dump your homework and expect someone else to fix it" trick
    [/max smart]

  3. #3
    fatmig is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    Aaaahhh yes the good ol typical member that has nothing else to do but ...

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    But what? I'm dying of suspense.

    We will help you but ask specific questions, tell us what you think is wrong, and wrap your code in code tags please.

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Ahh yes the stupid n00b who thinks that making snide remarks about those that they are asking for help will work!

  6. #6
    fatmig is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    Ah yes ...indeed yes

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Oh boy, war inc.

  8. #8
    fatmig is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    It's okay I was looking for ideas. Junky your the man !

  9. #9
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    If it is ideas you want then here's one: provide more information.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

Similar Threads

  1. recursion and tail-recursion differences
    By OptimusPrime in forum New To Java
    Replies: 2
    Last Post: 12-28-2009, 07:26 PM
  2. Spiral Array Order Number
    By rendra in forum Advanced Java
    Replies: 14
    Last Post: 11-20-2009, 04:20 AM
  3. Recursion
    By Mika in forum New To Java
    Replies: 5
    Last Post: 01-04-2009, 02:13 AM
  4. How to create a Hypnosis Spiral in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 09:46 PM
  5. Recursion
    By Zosden in forum Algorithms
    Replies: 4
    Last Post: 05-05-2008, 06:49 AM

Posting Permissions

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