コード例 #1
0
ファイル: Controller.cs プロジェクト: Swatarcommon/OOP-1sem-
        public static void FinalCoast(this Gift gifts)
        {
            float summ = 0;

            for (Int32 i = 0; i < gifts.List.Count; i++)
            {
                if (gifts.List[i] is Clock)
                {
                    Clock clock = new Clock();
                    clock = (Clock)gifts.List[i];
                    summ  = summ + clock.Price;
                }
                if (gifts.List[i] is Flowers)
                {
                    Flowers flower = new Flowers();
                    flower = (Flowers)gifts.List[i];
                    summ   = summ + flower.Price;
                }
                if (gifts.List[i] is Cake)
                {
                    Cake cake = new Cake();
                    cake = (Cake)gifts.List[i];
                    summ = summ + cake.Price;
                }
            }

            Console.WriteLine(summ);
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: Swatarcommon/OOP-1sem-
 public static void MinWeight(this Gift gifts)
 {
     Int32[] weight = new Int32[gifts.List.Count];
     for (Int32 i = 0; i < gifts.List.Count; i++)
     {
         if (gifts.List[i] is Clock)
         {
             Clock clock = new Clock();
             clock     = (Clock)gifts.List[i];
             weight[i] = clock.Weight;
         }
         if (gifts.List[i] is Flowers)
         {
             Flowers flower = new Flowers();
             flower    = (Flowers)gifts.List[i];
             weight[i] = flower.Weight;
         }
         if (gifts.List[i] is Cake)
         {
             Cake cake = new Cake();
             cake      = (Cake)gifts.List[i];
             weight[i] = cake.Weight;
         }
     }
     Console.WriteLine(weight.Min());
 }