コード例 #1
0
 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);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: firefly114/oop
        static void Main(string[] args)
        {
            Lumberjack la = new Lumberjack("zdarovaa");
            Oak        T  = new Oak(10, 300, 50, la);

            la.CuttingDown();
            T.Print();
            Console.WriteLine("{0} площа поперечного перерізу\n", T.crossSectionSquare());

            Log l = new Log(4, 100, "oak", 80, 300, 40);

            try{
                List <Log> logs = T.CutDown <Log>(l);
                for (int i = 0; i < logs.Count; i++)
                {
                    logs[i].Print();
                }
            } catch (HeightLogException e) {
                Console.WriteLine("{0}", e);
                int height = 2 * e.LogLength;
                Console.WriteLine("Height of tree must be {0} meters high or more", height);
            }

            Plank   p   = new Plank(l.Length, 20, 10);
            Parquet par = new Parquet(Colors.Brown, p.Length, p.Width, p.Thickness);

            Console.WriteLine("{0}", par.Color);
            par.Dyeing(Colors.Beige);
            Console.WriteLine("{0}", par.Color);
            Console.WriteLine("{0}", par.Burning());
        }
コード例 #3
0
 public Oak(int diameter, int age, int height, Lumberjack lumberjack)
 {
     this.Genus      = "oak";
     this.Diameter   = diameter;
     this.Age        = age;
     this.HeightTree = height;
     lumberjack.LumberjackCuttingDownEvent += new CuttingHandle(this.Cut);
 }