Error: Expected class, delegate, enum, interface, or struct - C#

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

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

Создал приложение winforms, добавил класс с реализацией методов, почему то куча ошибок типа "Expected class, delegate, enum, interface, or struct". скрин кинул в файл.
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using System.Text;
  6. namespace Holiday_event
  7. {
  8. class Party
  9. {
  10. const int food_per_person = 25;
  11. public double total_cost;
  12. public bool fancy,healthy;
  13. int number_of_person;
  14. public int Number_of_person
  15. {
  16. get
  17. {
  18. return number_of_person;
  19. }
  20. set
  21. {
  22. number_of_person = value;
  23. Get_cost(bool fancy, bool healthy);
  24. }
  25. }
  26. public double healthy_option(bool a)
  27. {
  28. if (number_of_person < 1) return 0;
  29. else if (a) return (food_per_person + 5) * number_of_person * 0.95;
  30. else return (food_per_person + 20) * number_of_person;
  31. }
  32. public double fancy_decoration (bool b)
  33. {
  34. if (number_of_person < 1) return 0;
  35. if (b) return 15 * number_of_person + 50;
  36. else return 7.5 * number_of_person + 30;
  37. }
  38. public void Get_cost(bool a, bool b)
  39. {
  40. this.total_cost = fancy_decoration(a) + healthy_option(b);
  41. }
  42. }
  43. }

Решение задачи: «Error: Expected class, delegate, enum, interface, or struct»

textual
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using System.Text;
  6.  
  7. namespace Holiday_event
  8. {
  9.     class Party
  10.     {
  11.         const int food_per_person = 25;
  12.         public double total_cost;
  13.         private int number_of_person;
  14.         public bool Fancy { get; set; }
  15.         public bool Healthy { get; set; }
  16.         public int Number_of_person
  17.         {
  18.             get
  19.             {
  20.                 return number_of_person;
  21.             }
  22.             set
  23.             {
  24.                 number_of_person = value;
  25.                 Get_cost(Fancy, Healthy);
  26.             }
  27.         }
  28.         public double healthy_option(bool a)
  29.         {
  30.             if (number_of_person < 1) return 0;
  31.             else if (a) return (food_per_person + 5) * number_of_person * 0.95;
  32.             else return (food_per_person + 20) * number_of_person;
  33.         }
  34.         public double fancy_decoration (bool b)
  35.         {
  36.             if (number_of_person < 1) return 0;
  37.             if (b) return 15 * number_of_person + 50;
  38.             else return 7.5 * number_of_person + 30;
  39.         }
  40.         public void Get_cost(bool a, bool b)
  41.         {
  42.             this.total_cost = fancy_decoration(a) + healthy_option(b);
  43.         }
  44.     }
  45. }

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


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

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

10   голосов , оценка 3.6 из 5

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

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

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