I gotta do some homework about creating a farm. And i have to describe each events within the hours and the days (from 6 A.M to 22 P.M, from Monday to Saturday ). I'm trying to use a switch based on a enum like this :
// this is the hour's enum (day and night).
[Flags]
enum Horaire
{
Journee = 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21,
Nuit = 22 | 23 | 0 | 1 | 2 | 3 | 4 | 5,
}
In my program.cs, i would like to do a while loop such as :
While(Journee!=Nuit)
switch(Journee)
case 6: // for 6.am
Farmer.DoAction();
case 12 : // for 12.pm
Farmer.Eat();
and so on until it will reach the night.
Is there an easier way to do this loop without an enum and a switch ?
Thank you.
2 | 4is the same as 6, for example? Why do you want to use an enum for this at all? Why not just use a single condition?