protected virtual void OnWorkStart(WorkEventArgs e) { EventHandler <WorkEventArgs> handler = WorkStart; if (handler != null) { handler(this, e); } }
public override void DoJob(object sender, WorkEventArgs e) { if (CurrentSeason == Seasons.Summer) { Eat(); } if (e.Danger) { Console.WriteLine("too lazy. again. even to write in uppercase"); } Console.WriteLine("Job's done, just cause i'm doing nothing"); }
public override void DoJob(object sender, WorkEventArgs e) { if (CurrentSeason == Seasons.Summer) { ProduceBee(); } if (e.Danger) { LookForEnemies(); } Eat(); Console.WriteLine("Quuens' job is done!"); }
public override void DoJob(object sender, WorkEventArgs e) { if (MyHive != null) { MyHive.StoredHoney += CollectHoney(); } if (e.Danger) { LookForEnemies(); } Eat(); Console.WriteLine("Simple worker's work has been done"); }
static void Main(string[] args) { Hive hive1 = new Hive(); Console.WriteLine("Life of hive1 has started"); for (int i = 0; i < 10; i++) { hive1.Tick(); Console.WriteLine(hive1.BeesAmount); HiveUtils.CheckIfSuccessul(hive1); Console.ReadKey(); } Console.WriteLine("Life of hive1 has ended"); Queen directQueen = new Queen(); Hive hive2 = new Hive(directQueen); Console.WriteLine("Life of hive2 has started"); for (int i = 0; i < 10; i++) { hive2.Tick(); Console.WriteLine(hive2.BeesAmount); HiveUtils.CheckIfSuccessul(hive2); Console.ReadKey(); } Console.WriteLine("Life of hive2 has ended"); var arg = new WorkEventArgs(true); Worker w = new Worker(); try { w.DoJob(null, arg); } catch (HiveNotFoundException <HiveNotFoundExceptionArgs> e) { Console.WriteLine(e.Message); } Console.ReadKey(); }
public void Tick() { CurrentCycle++; if (CurrentCycle % 6 == 0) { mainQueen.SetSeason(Seasons.Winter); } else if (CurrentCycle % 6 == 3) { mainQueen.SetSeason(Seasons.Summer); } Console.WriteLine("\n\nOne more cycle has started"); Console.WriteLine("Honey at start = {0}", StoredHoney); Random r = new Random(); WorkEventArgs e = new WorkEventArgs(r.Next(10) > 7); OnWorkStart(e); Console.WriteLine("Honey at end = {0}", StoredHoney); Console.WriteLine("One more cycle has ended\n\n"); }
public abstract void DoJob(object sender, WorkEventArgs e);