public void Cut(Lumberjack l, CuttingDownEventArgs cdargs) { if (this.HeightTree > 0) { if (cdargs.length > this.HeightTree) { Console.WriteLine("{0} height is lower than inputed log length | {1}", this.Genus, cdargs.length); return; } for (int i = 0; i < cdargs.number; i++) { if (this.HeightTree - cdargs.length < 0) { Console.WriteLine("{0} can't be cut down anymore, {1} meters left", this.Genus, this.HeightTree); break; } this.HeightTree -= cdargs.length; Console.WriteLine("Lumberjack {0} is cutting down a {1}, {2} meters left", l.name, this.Genus, this.HeightTree); } } else { Console.WriteLine("{0} height <= 0, so it cant be cutted down", l.name, this.Genus); } }
public void CuttingDown() { int length; int num; CuttingDownEventArgs cdargs; try { Console.Write("Enter length of log: "); length = Int32.Parse(Console.ReadLine()); Console.Write("Enter number of logs: "); num = Int32.Parse(Console.ReadLine()); cdargs = new CuttingDownEventArgs(length, num); }catch { cdargs = new CuttingDownEventArgs(); } if (LumberjackCuttingDownEvent != null) { LumberjackCuttingDownEvent((Lumberjack)this, cdargs); } }