Advertisement
TArtem

sfsdfsd

Feb 26th, 2021
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using Newtonsoft.Json;
  5.  
  6. namespace lab6
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Lion lion1 = new Lion();
  13.             Tiger tiger1 = new Tiger();
  14.             NewClass newClass1 = new NewClass();
  15.             Croc croc1 = new Croc();
  16.             Parrot parrot1 = new Parrot();
  17.             parrot1.IsPredator = false;
  18.             parrot1.YearOfBirth = 1993;
  19.             Owl owl1 = new Owl();
  20.             owl1.IsPredator = true;
  21.             owl1.YearOfBirth = 2013;
  22.  
  23.             Console.WriteLine("Croc can{0} be converted to object", (croc1 is Object) ? "" : "not");
  24.             Console.WriteLine("Croc can{0} be converted to ValueType", (croc1 is ValueType) ? "" : "not"); //is - проверка на конвертацию
  25.  
  26.             Mammals mammal1 = new Mammals();
  27.             Lion pLion = mammal1 as Lion;
  28.             Console.WriteLine("Mammals to Lion conversion is {0} completed", (pLion != null) ? "" : "not"); //as - конвертация
  29.  
  30.             Mammals pTiger = tiger1 as Mammals;
  31.             Console.WriteLine("Tiger to mammals conversion is {0} completed", (pTiger != null) ? "" : "not"); //as - конвертация
  32.             Console.WriteLine(pTiger); //после переопределения ToString выводит info
  33.  
  34.             Console.WriteLine(lion1.ToString());
  35.  
  36.             Print print1 = new Print();
  37.             Mammals[] mammalsArr = new Mammals[] { lion1, tiger1 };
  38.             foreach (var s in mammalsArr)
  39.             {
  40.                 print1.IAmPrinting(s);
  41.                 Console.WriteLine();
  42.             }
  43.  
  44.             NewClass new1 = new NewClass();
  45.             ((IAnimal)new1).a_method();
  46.             new1.a_method();
  47.  
  48.  
  49.             //Новая лаба
  50.             Smth struct1;
  51.             struct1.smth = "Smth";
  52.             Console.WriteLine(struct1.smth);
  53.             Smth.Month month1 = Smth.Month.January;
  54.             Console.Write(month1 + " ");
  55.             Console.WriteLine((int)month1);
  56.  
  57.  
  58.             Zoo zoo1 = new Zoo();
  59.             tiger1.YearOfBirth = 2001;
  60.             zoo1.Add(tiger1);
  61.             zoo1.Add(lion1);
  62.             zoo1.Add(owl1);
  63.             zoo1.Add(parrot1);
  64.             zoo1.ShowList();
  65.             zoo1.Remove(tiger1);
  66.  
  67.             ZooController yearCmp = new ZooController();
  68.             zoo1.ZooGS.Sort(yearCmp);
  69.             Console.WriteLine("After sorting");
  70.             zoo1.ShowList();
  71.         }
  72.     }
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement