Работа return - C#

Узнай цену своей работы

Формулировка задачи:

Объясните, пожалуйста, как в данных примерах работает return.
Листинг программы
  1. class Figure
  2. {
  3. /////////////
  4. public virtual bool Check(int x, int y)
  5. {
  6. return (x == y);
  7. }
  8. /////////////
  9. public bool BorderCheck(int Width, int Height)
  10. {
  11. if (this.x < 0)
  12. this.x = 0;
  13. if (this.y < 0)
  14. this.y = 0;
  15. if (this.x + this.Width > Width)
  16. this.x = Width - this.Width - 1;
  17. if (this.y + this.Height > Height)
  18. this.y = Height - this.Height - 1;
  19. return (this.x < 0 || this.x + this.Width > Width || this.y < 0 || this.y + this.Height > Height);
  20. }
  21. ////////
  22. }
  23. class Ellipse : Figure
  24. {
  25. /////
  26. public override bool Check(int x, int y)
  27. {
  28. float dx = this.x - x + this.Width / 2;
  29. float dy = this.y - y + this.Height / 2;
  30. return (dx * dx + dy * dy <= (Width * Width) / 4);
  31. }
  32. //////
  33. }
  34. class Rectangle: Figure
  35. {
  36. ////
  37. public override bool Check(int x, int y)
  38. {
  39. return (x > this.x && x < this.x + Width && y > this.y && y < this.y + Height);
  40. }
  41. /////
  42. }

Решение задачи: «Работа return»

textual
Листинг программы
  1.         private void Form1_MouseClick(object sender, MouseEventArgs e)
  2.         {
  3.                    
  4.             for (int i = 0; i < list.GetLength(); i++)
  5.             {
  6.                 if (list[i].Check(e.X - 20, e.Y - 20))
  7.                 {
  8.  
  9.                     if (!list[i].mark)
  10.                         list[i].mark = true;
  11.                     else
  12.                         list[i].mark = false;
  13.                    
  14.                     Invalidate();
  15.                     return;
  16.                 }
  17.             }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

12   голосов , оценка 3.75 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут