Error: Expected class, delegate, enum, interface, or struct - C#
Формулировка задачи:
Создал приложение winforms, добавил класс с реализацией методов, почему то куча ошибок типа "Expected class, delegate, enum, interface, or struct". скрин кинул в файл.
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using System.Text;
- namespace Holiday_event
- {
- class Party
- {
- const int food_per_person = 25;
- public double total_cost;
- public bool fancy,healthy;
- int number_of_person;
- public int Number_of_person
- {
- get
- {
- return number_of_person;
- }
- set
- {
- number_of_person = value;
- Get_cost(bool fancy, bool healthy);
- }
- }
- public double healthy_option(bool a)
- {
- if (number_of_person < 1) return 0;
- else if (a) return (food_per_person + 5) * number_of_person * 0.95;
- else return (food_per_person + 20) * number_of_person;
- }
- public double fancy_decoration (bool b)
- {
- if (number_of_person < 1) return 0;
- if (b) return 15 * number_of_person + 50;
- else return 7.5 * number_of_person + 30;
- }
- public void Get_cost(bool a, bool b)
- {
- this.total_cost = fancy_decoration(a) + healthy_option(b);
- }
- }
- }
Решение задачи: «Error: Expected class, delegate, enum, interface, or struct»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using System.Text;
- namespace Holiday_event
- {
- class Party
- {
- const int food_per_person = 25;
- public double total_cost;
- private int number_of_person;
- public bool Fancy { get; set; }
- public bool Healthy { get; set; }
- public int Number_of_person
- {
- get
- {
- return number_of_person;
- }
- set
- {
- number_of_person = value;
- Get_cost(Fancy, Healthy);
- }
- }
- public double healthy_option(bool a)
- {
- if (number_of_person < 1) return 0;
- else if (a) return (food_per_person + 5) * number_of_person * 0.95;
- else return (food_per_person + 20) * number_of_person;
- }
- public double fancy_decoration (bool b)
- {
- if (number_of_person < 1) return 0;
- if (b) return 15 * number_of_person + 50;
- else return 7.5 * number_of_person + 30;
- }
- public void Get_cost(bool a, bool b)
- {
- this.total_cost = fancy_decoration(a) + healthy_option(b);
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д