/*_____________________________________________________________*/ //ПЕРЕОПРЕДЕЛЕНИЕ МЕТОДОВ OBJECT (в одном классе) public override bool Equals(object obj) { if (obj.GetType() != GetType()) { return(false); } Tennis other = (Tennis)obj; return(Exp == other.Exp); }
static void Main(string[] args) { Tennis ten = new Tennis(); ten.ChooseRocket(Tennis.enumRocket.x); Gym gym = new Gym(); Playground[] arrPlaygrounds = { new Tennis(), new Basketball(), new Beams(10), new Bench(), new Mats() }; foreach (var i in arrPlaygrounds) { gym.Add(i); } gym.Show(); gym.Remove(2); gym.Remove(6);///f gym.Show(); /*________________________________________________________*/ СontrollerGym cg = new СontrollerGym(30000);///бюджет Console.WriteLine("Количество снарядов: | Цена (каждый 12 руб):"); cg.Add(new Shells(100)); cg.Add(new Shells(90)); cg.Add(new Shells(80)); cg.Add(new Shells(166)); cg.Add(new Shells(45)); cg.Show(); Console.WriteLine("_________________________________________________"); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nПосле сортировки:"); Console.ResetColor(); cg.Sort(); cg.Show(); Console.WriteLine("_________________________________________________"); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nВ диапазоне цены 500-1000:"); Console.ResetColor(); cg.СhoiceRange(500, 1000); cg.Show(); Console.ReadLine(); }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("\n\n********* Б Р У С Ь Я *********"); Console.ResetColor(); Playground brus = new Beams(10); brus.GetExp(); brus.DoExercise(); brus.DoExercise(); brus.Relax(10); brus.GetExp(); if (brus is Playground) { Console.WriteLine($"{brus} is Playground "); ///true } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("\n\n********* С К А М Е Й К А *********"); Console.ResetColor(); Playground skam = new Bench(); skam.DoExercise(); skam.Relax(30); if (skam is Beams) { Console.WriteLine($"{skam} is Beams "); ///false } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("\n\n********* М А Т Ы *********"); Console.ResetColor(); Playground mat = new Mats(); mat.DoExercise(); mat.Relax(2); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("\n\n********* Б А С К Е Т Б О Л *********"); Console.ResetColor(); Basketball bask = new Basketball(); IBacketBall bask_ball = bask; bask.Take_Invent(); bask.DoExercise(); bask.Play(); bask.Throw(); bask.Back_Invent(); bask.GetExp(); if (bask_ball as Beams != null) { Console.WriteLine($"{bask_ball} as Beams "); ///false } if (bask_ball as Playground != null) { Console.WriteLine($"{bask_ball} as Playground "); ///true } Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("\n\n********* Т Е Н Н И С *********"); Console.ResetColor(); Tennis ten = new Tennis(); ITennisBall ten_ball = ten; ten.DoExercise(); ///а.к. ten_ball.DoExercise(); ///интер. Console.WriteLine($"'ten': To string() - {ten.ToString()}"); ///тенис Console.WriteLine($" GetHashCode() - {ten.GetHashCode()} "); ///861 if (ten.Equals(ten_ball)) { Console.WriteLine(" Equal() to ten_ball"); ///true } else { Console.WriteLine(" Not Equal() to ten_ball"); } Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("\n\n********* МАССИВ ССЫЛОК НА ОБЪЕКТЫ КЛАССОВ *********"); Console.ResetColor(); Playground[] arrPl = { skam, mat, brus, bask, ten }; Printer printer = new Printer(); foreach (var i in arrPl) { printer.iAmPrinting(i); } ///скамейка, маты, брусья, баскетбол, теннис Console.ReadLine(); }