<span class="Apple-style-span" style="white-space: pre-wrap; ">Hello. My apologies if I am asking this in the wrong mailing list (this being a Java question). But since I encountered this concept in HtDP, I thought of asking around here. (See Chapter 21 of HtDP).
See I have a function
private int getSaturdays(int x, int fordays){
int Weeks = getWeeks(x, fordays);
int SaturdayCounter = 0;
int i = 1;
while(i <= hartalWeeks){
if(getSaturdayIndex(i) % x == 0){
SaturdayCounter++;
i++;
}
else{
i++;
}
}
return SaturdayCounter;
}
and another one
private int getSundays(int x, int fordays){
int Weeks = getWeeks(x, fordays);
int SundaysCounter = 0;
int i = 1;
while(i <= hartalWeeks){
if(getSundayIndex(i) % x == 0){
SundayCounter++;
i++;
}
else{
i++;
}
}
return SundayCounter;
}
As obvious, they do the same process, their sole difference being a function call (the one in the if line). Now, if I were to do this in Scheme, I'll just add another argument to my function which will be called in the if line (as in Chapter 21). However, I do not know how to do this in Java.</span><div>
<span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></div><div><span class="Apple-style-span" style="white-space: pre-wrap;">I know how to sort in Java using the Comparator interface and all that OO stuff. I thought of using that style here but then I was wondering if I could do this without OO. Is it possible?<br clear="all">
</span><br></div><div>Thanks in advance,<br>-- <br>Chad Estioco<br>BS Computer Science (ongoing)<br>University of the Philippines-Diliman<br>==============================<br><a href="http://www.geocities.com/lokisky_walker">http://www.geocities.com/lokisky_walker</a><br>
</div>