Results 1 to 10 of 10
Thread: spiral recursion
- 04-06-2011, 04:40 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
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);
}
}
- 04-06-2011, 04:47 AM #2
[max smart]
Ahh the old "dump your homework and expect someone else to fix it" trick
[/max smart]
- 04-06-2011, 04:58 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
Aaaahhh yes the good ol typical member that has nothing else to do but ...
- 04-06-2011, 05:03 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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.
- 04-06-2011, 05:04 AM #5
Ahh yes the stupid n00b who thinks that making snide remarks about those that they are asking for help will work!
- 04-06-2011, 05:10 AM #6
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
Ah yes ...indeed yes
- 04-06-2011, 05:11 AM #7
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Oh boy, war inc.
- 04-06-2011, 05:13 AM #8
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
It's okay I was looking for ideas. Junky your the man !
- 04-06-2011, 05:23 AM #9
If it is ideas you want then here's one: provide more information.
- 04-06-2011, 06:45 AM #10
Similar Threads
-
recursion and tail-recursion differences
By OptimusPrime in forum New To JavaReplies: 2Last Post: 12-28-2009, 06:26 PM -
Spiral Array Order Number
By rendra in forum Advanced JavaReplies: 14Last Post: 11-20-2009, 03:20 AM -
Recursion
By Mika in forum New To JavaReplies: 5Last Post: 01-04-2009, 01:13 AM -
How to create a Hypnosis Spiral in Java
By Java Tip in forum java.awtReplies: 0Last Post: 06-21-2008, 08:46 PM -
Recursion
By Zosden in forum AlgorithmsReplies: 4Last Post: 05-05-2008, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks