I've got a big list of start and end DateTimes to calculate the user's Zodiac sign.
If the User's Birthday is between this date, the application spits out the relevant star sign.
I'm trying to cut my code down to that I can make it so that the Developer (me) can input additional Star Signs without having to specify a name and dates.
So for example:
(If UserBD >= DateStart && UserBD <= DateFinish)
{
Console.WriteLine(“Your star sign is {0}”, StarSign);
}
At the moment I have the following:
DateTime AquariusStart = new DateTime(userBD.Year, 01, 20);
DateTime AquariusEnd = new DateTime(userBD.Year, 02, 18);
DateTime PiscesStart = new DateTime(userBD.Year, 02, 19);
DateTime PiscesEnd = new DateTime(userBD.Year, 03, 20);
if (userBD >= AquariusStart && userBD <= AquariusEnd)
{
Console.WriteLine("Your Star Sign is Aquarius!");
}
else if (userBD >= PiscesStart && userBD <= PiscesEnd)
{
Console.WriteLine("Your Star Sign is Pisces!");
}
etc etc
What would I need to add in order to be able to make the code 'dynamic'?
Thanks in advance! :)
Aucun commentaire:
Enregistrer un commentaire