-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMagazine.cs
98 lines (90 loc) · 2.55 KB
/
Magazine.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab2v2
{
public class Magazine : List<Article>
{
private string namezh;
private Frequency frequencyzh;
private System.DateTime datezh;
private int tzh;
private Article[] stats = new Article[1];
public Magazine(string NameZh, Frequency FrequencyZh, DateTime DateZh, int TZh)
{
namezh = NameZh;
frequencyzh = FrequencyZh;
datezh = DateZh;
tzh = TZh;
}
public Magazine()
{
namezh = "Новости";
frequencyzh = Frequency.Monthly;
datezh = new DateTime(2013, 12, 2);
tzh = 1000;
stats[0] = new Article();
}
public string NameZh
{
get
{
return namezh;
}
}
public Frequency FrequencyZh
{
get
{
return frequencyzh;
}
}
public DateTime DateZh
{
get
{
return datezh;
}
}
public int TZh
{
get
{
return tzh;
}
}
private int _addedArticleCount;
public void AddArticle(Article a)
{
stats[_addedArticleCount] = a;
_addedArticleCount++;
if (_addedArticleCount == stats.Length)
{
Array.Resize(ref stats, _addedArticleCount + 1);
}
}
public string Write(params Article[] article)
{
string result = "";
for ( int i = 0; i < stats.Length; i++)
{
if (stats[i] != null)
{
result += stats[i].ToString() + Environment.NewLine+ Environment.NewLine; ;
}
}
return result;
}
public override string ToString()
{
return $"Название журнала: {namezh}{Environment.NewLine}" +
$"Периодичность выхода журнала: {frequencyzh}{Environment.NewLine}" +
$"Дата выхода журнла: {datezh}{Environment.NewLine}" +
$"Тираж журнала {tzh}{Environment.NewLine}" +
$"Статьи:{Environment.NewLine} " +
$"{Write()}";
}
}
}