public static void CountTechnic(LAB o)// количество каждого вида техники { List <object> userInterface = o.get(); int comp = 0, pad = 0, print = 0; for (int i = 0; i < userInterface.Count; i++) { if (userInterface[i] is Computer) { comp++; } if (userInterface[i] is Pad) { pad++; } if (userInterface[i] is Print) { print++; } } Console.WriteLine("количество Computer: " + comp); Console.WriteLine("количество Pad: " + pad); Console.WriteLine("количество Printer: " + print); Console.WriteLine("всего: " + userInterface.Count); }
public void printTechnic(LAB o) { List <object> userInterface = o.get(); for (int i = 0; i < userInterface.Count; i++) { if (userInterface[i] is Computer) { Computer myComp; object obj = userInterface[i]; myComp = (Computer)obj; Console.WriteLine("Computer \n" + myComp); } if (userInterface[i] is Pad) { Pad myPad; object obj = userInterface[i]; myPad = (Pad)obj; Console.WriteLine("Pad \n" + myPad); } if (userInterface[i] is Print) { Print myPrint; object obj = userInterface[i]; myPrint = (Print)obj; Console.WriteLine("Print \n" + myPrint); } } }
public static void printAge(LAB S)///Найти технику старше заданного срока службы, больше 2 { List <object> userInterface = S.get(); for (int i = 0; i < userInterface.Count; i++) { if (userInterface[i] is Computer) { Computer myComp; object obj = userInterface[i]; myComp = (Computer)obj; if (myComp.price >= 2) { Console.WriteLine("Computer Age: " + myComp.age); } else { Console.WriteLine("Computer<2"); } } if (userInterface[i] is Pad) { Pad myPad; object obj = userInterface[i]; myPad = (Pad)obj; if (myPad.age >= 2) { Console.WriteLine("Pad Age: " + myPad.age); } else { Console.WriteLine("Pad<2"); } } if (userInterface[i] is Print) { Print myPrint; object obj = userInterface[i]; myPrint = (Print)obj; if (myPrint.age >= 2) { Console.WriteLine(" Print Age: " + myPrint.age); } else { Console.WriteLine(" Print<2"); } } } }
public static void SortTechnic(LAB S)///Вывести список техникив порядке убывания цены. { List <object> userInterface = S.get(); int CompPrice = 0, PadPrice = 0, PrintPrice = 0; for (int i = 0; i < userInterface.Count; i++) { if (userInterface[i] is Computer) { Computer myComp; object obj = userInterface[i]; myComp = (Computer)obj; CompPrice = myComp.price; } if (userInterface[i] is Pad) { Pad myPad; object obj = userInterface[i]; myPad = (Pad)obj; PadPrice = myPad.price; } if (userInterface[i] is Print) { Print myPrint; object obj = userInterface[i]; myPrint = (Print)obj; PrintPrice = myPrint.price; } } object[] myArr = new object[3]; myArr[0] = CompPrice; myArr[1] = PadPrice; myArr[2] = PrintPrice; Array.Sort(myArr); Array.Reverse(myArr); foreach (int t in myArr) { Console.WriteLine(t); } Console.WriteLine("-------------"); }