-
Notifications
You must be signed in to change notification settings - Fork 0
/
City.cs
38 lines (32 loc) · 1.02 KB
/
City.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab4CSharp
{
class City
{
public string Name { get; private set; } // Название города
private List<Theatre> Theatres; // Кинотеатры
public City(string Name)
{
this.Name = Name;
Theatres = new List<Theatre>();
}
public override string ToString() // Переопределённая ф-ция toString
{
string TmpTheatres = "";
foreach (Theatre obj in Theatres)
{
TmpTheatres += obj.Name + ", ";
}
return $"Город: {this.Name}\nКинотеатры ({Theatres.Count} шт.): {TmpTheatres}";
}
public City AddTheatre (Theatre Theatre) // Добавить кинотеатр в город
{
this.Theatres.Add(Theatre);
return this; // Для чейнинга
}
}
}