static void Main(string[] args) { Base a1 = new Hero(); a1.Move(); IAction a2 = new Hero(); a2.Move(); Hero a3 = new Hero(); a3.Move(); Console.WriteLine(); Printer Epson = new Printer("Epson", "L355", 15); Console.WriteLine(Epson.ToString()); Scaner HP = new Scaner("HP", "ScanJet", 1080); Console.WriteLine(HP.ToString()); Computer Intel = new Computer("Epson", "L355", 8); Console.WriteLine(Intel.ToString()); Tablet Huawei = new Tablet("Huawei", "MediaPad", 10); Console.WriteLine(Huawei.ToString()); Console.WriteLine(); Epson.CanRun(); Epson.CanPrint(); HP.CanRun(); HP.CanScan(); Intel.CanRun(); Intel.CanShow(); Huawei.CanRun(); Huawei.CanShow(); Huawei.CanTap(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Technics[] tech = new Technics[] { Epson, HP, Intel, Huawei }; foreach (Technics elem in tech) { Console.WriteLine(elem.ToString()); Console.WriteLine("Is product: " + (elem is Product)); Console.WriteLine("Is technics: " + (elem is Technics)); Console.WriteLine("Is printer: " + (elem is Printer)); Console.WriteLine("Is scaner: " + (elem is Scaner)); Console.WriteLine("Is computer: " + (elem is Computer)); Console.WriteLine("Is tablet: " + (elem is Tablet)); Console.WriteLine(); } }
static void Main(string[] args) { try { TransportAgency Agent = new TransportAgency(); Printer Print = new Printer(); Train poezd1 = new Train(123, 8578947, 89); poezd1.toString(); Train poezd2 = new Train(678, 8745683, 100); Train poezd3 = new Train(987, 098009, 85); Train poezd4 = new Train(897, 8575, 80); Vagon vagon1 = new Vagon(123, 2354, 89, 6); vagon1.toString(); Express express1 = new Express(124, 9465464, 89, 100); express1.toString(); Car car1 = new Car(456, 34534, 90, "Volvo", 10); car1.toString(); Car car2 = new Car(897, 65646, 80, "Opel", 5); car1.toString(); Engine engine1 = new Engine(456, 2343, 45, "Volvo", 10, 100); engine1.toString(); Console.WriteLine(); Transport[] arr = new Transport[2]; arr[0] = vagon1; arr[1] = car1; Print.IAmPrinting(arr[0]); Print.IAmPrinting(arr[1]); Console.WriteLine(); Part party = new Part(); party.part2(); party.part1(); Console.WriteLine(); Console.WriteLine(car1 is Transport); Console.WriteLine(car1 is Int32); Transport obj1 = express1 as Transport; if (obj1 != null) { Console.WriteLine("Преобразование удалось"); } else { throw new Errors("Это фиаско, братан"); } int en = (int)Enum.e; Console.WriteLine("enum " + en); Console.WriteLine(); Agent.Add(poezd1); Agent.Add(car1); Agent.Add(express1); Agent.Add(vagon1); Agent.Add(engine1); Agent.Stoimoct(); Agent.FindSpeed(); Console.WriteLine(); Car[] ar = new Car[2]; ar[0] = car1; ar[1] = car2; Array.Sort(ar); foreach (Car p in ar) { p.toString(); } int[] aa = null; Debug.Assert(aa != null, "Что-то не так"); Structura struct1 = new Structura { }; struct1.name = "new"; struct1.size = 3; Console.WriteLine(struct1.size); CollectionType <double> i = new CollectionType <double>(); i.array = new List <double>() { 1, 3, 5 }; Console.WriteLine("Массив 1:\n"); i.View(i); Console.WriteLine("В массив1 добавим 5:\n"); i.Add(i, 5); Console.WriteLine("Массив1:\n"); i.View(i); Console.WriteLine("Из массива 1 удалим 1:\n"); i.Del(i, 1); Console.WriteLine("Массив 1:\n"); i.View(i); Console.WriteLine(); Console.WriteLine(); CollectionType <Train> k = new CollectionType <Train>(); k.array = new List <Train>(4) { poezd1, poezd2, poezd3 }; Console.WriteLine("Массив2:\n"); k.View(k); Console.WriteLine("В массив2 добавим еще поезд:\n"); k.Add(k, poezd4); Console.WriteLine("Массив2:\n"); k.View(k); for (int l = 0; l < 4; l++) { k[l].toString(); } Console.WriteLine("Из массива 2 удалим поезд:\n"); k.Del(k, poezd4); Console.WriteLine("Массив 2:\n"); k.View(k); for (int l = 0; l < 4; l++) { k[l].toString(); } Console.WriteLine(); Console.WriteLine(); } catch (Error e) { Console.WriteLine("Используется Error"); } catch (Errorin e) { Console.WriteLine("Используется Errorin"); } catch (Errors e) { Console.WriteLine("Используется Errors"); } catch (Exception e) { Console.WriteLine("Используется Exception"); } finally { Console.WriteLine("The end"); } }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Aviation aviation = new Aviation(); Cargo cargo = new Cargo(); Military military = new Military(); Pasanger pasanger = new Pasanger(); Ty134 ty134 = new Ty134(); Boing boing = new Boing(); cargo.addInfo(); Console.WriteLine('\n'); military.addInfo(); Console.WriteLine('\n'); pasanger.addInfo(); Console.WriteLine('\n'); Console.ForegroundColor = ConsoleColor.Magenta; aviation.Type(); cargo.Type(); military.Type(); pasanger.Type(); ty134.Type(); boing.Type(); Console.WriteLine('\n'); Console.ForegroundColor = ConsoleColor.White; bool fly = pasanger is Aviation; if (fly) { Aviation confOne = (Aviation)pasanger; confOne.Type(); } Console.ForegroundColor = ConsoleColor.Red; ITransport confTwo = military as ITransport; ITrans confThree = cargo as ITrans; if (confTwo != null) { confTwo.Info(); } if (confThree != null) { confThree.Info("fsfe"); } Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(cargo.ToString()); Console.ForegroundColor = ConsoleColor.Green; Transport obj = pasanger as Transport;//можно ли преобразовать Console.WriteLine(obj.GetType()); Console.ForegroundColor = ConsoleColor.Yellow; if (military is Transport)//преднадлежит { Console.WriteLine(true + "\n"); } Console.ForegroundColor = ConsoleColor.Magenta; Transport[] mas = { cargo, military, pasanger }; foreach (Transport x in mas) { Console.WriteLine(Printer.iAmPrinting(x)); } Console.ReadKey(); }