ת הכוכב הבסיסי באמצע ציירתי כבר באמצעות פונקציה ... DRAWSNOWFLAKE שפועלת טוב!
עכשיו אני אמור לכתוב פונקציה רקורסיבית כדי לצייר את המעגלים מסביב- DrawCircle
הנה החתימה
public static void drawCircle(int x, int y, int radius, int size, int depth )
והנה הפרטים על הפרמטרים שהיא מקבלת
(
x,y) is the center of the circle
o radius is the radius of the circle
o size is the lengths of the lines of the snowflakes in the circle
o depth is the number of times left to call the method recursively
והנה כמה הגבלות שנתנו:
Each circle has a radius which is larger than the previous circle’s radius by
3*size. (size is the size of the snowflake of the previous circle).
Each circle has snowflakes which are 2 times smaller in size than the previous
snowflake.
Each time drawCircle is called another circle of snowflakes is added around the
center
.
ולבסוף זה הקוד שכתבתי אני לDrawCircle(משהו בו לא טוב כנראה רק קשה לי להבין מה ולמה
public static void drawCircle(int x, int y, int radius, int size, int depth ){
if (depth!=0){
for (int i = 0; i<6; i++) {
int endX = x + (int)(size*Math.cos(2*Math.PI/6*i));
int endY = y - (int)(size*Math.sin(2*Math.PI/6*i ));
drawSnowflake(endX,endY,size/3,4);
drawCircle(x,y,radius/3,size/2,depth-1);
}
}
התמונות של מה שיוצא לי:
של הקוד הנוכחי
ושל אותו הקוד בשינוי של במקום /3 /2 *3 *2
ערן עכשיו אתה רואה שבסך הכל עשיתי מה שאמרת רק שאי אפשר היה לקרוא את זה כי הכל היה הפוך
אני מעריך את העזרה שלכם , אם יש שאלות נוספות שיעזרו לכם לעזור לי אל תתביישו
תודה