import java.awt.*;
import javax.swing.*;
public class Christmas
{
public static String ChristmasRecursion(int day,int tempDay,int lastDay)
{
int giftDay=tempDay;
int secondDay=day;
String result="";
String[] dayLyrics = new String[]
{"first","second","third","fourth","fifth","sixth","seventh","eigth","nineth","tenth","eleventh","twelfth"};
String [] gifts=new String[]
{"","a partirige in a pear tree!\n\n","turtle doves\n", "french hens\n" , "calling birds\n", "golden rings\n" ,"geese a-laying\n","swans a-swimming\n"
,"maids a-milking\n","ladies dancing\n","lords a-leaping\n","pipers piping\n","drummers drumming\n" };
String myTrue="my true love gave to me\n ";
if ((day==11)|| (day==lastDay))
{
result+=( "On the "+dayLyrics[day]+" day of christmas "+myTrue+ "\n");
//gifts[day]);
while (tempDay!=0)
{
if ((tempDay==1)&&(secondDay!=0))
{
result+="And ";
}
if (day!=0)
{
result+=((day+1)+ " ");
}
result+=gifts[tempDay]+"\n";
tempDay--;
day--;
}
tempDay=giftDay;
day=secondDay;
result+="\n\n\n\n\n\n\n";
}
else
{
result+=( "\n\n\nOn the "+dayLyrics[day]+" day of christmas "+myTrue+ "\n");
while (tempDay!=0)
{
if ((tempDay==1)&&(secondDay!=0))
{
result+="And ";
}
if(day!=0)
{
result+=((day+1)+" ");
}
result+=gifts[tempDay]+"\n";
tempDay--;
day--;
}
tempDay=giftDay;
day=secondDay;
result+=ChristmasRecursion((day+1),(tempDay+1),lastDay);
}
return result;
}
} |