· 5 years ago · Oct 18, 2019, 10:30 AM
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5
6namespace demo
7{
8 public class Employees
9 {
10 public string name;
11 public DateTime birth;
12 public int salary;
13 public Department palata;
14
15 public string Name
16 {
17 get
18 {
19 return name;
20 }
21 set
22 {
23 name = value;
24 }
25 }
26
27 public DateTime Birth
28 {
29 get
30 {
31 return birth;
32 }
33 set
34 {
35 birth = value;
36 }
37 }
38 public int Salary
39 {
40 get
41 {
42 return salary;
43 }
44 set
45 {
46 salary = value;
47 }
48 }
49
50 public Department Palata
51 {
52 get
53 {
54 return palata;
55 }
56 set
57 {
58 palata = value;
59 }
60 }
61
62 public Employees ( string name, DateTime birth, int salary, Department palata)
63 {
64 Name = name;
65 Birth = birth;
66 Salary = salary;
67 Palata = palata;
68 }
69 }
70
71
72
73
74 public class Department
75 {
76 public string NameOfDepartment { get; set; }
77 public string Adress {get; set;}
78 public int totalYearlyPayment;
79
80 public int TotalYearlyPayment
81 {
82 get
83 {
84 int sum = 0;
85 int itog = 0;
86
87 foreach(Employees el in AllEmployees)
88 {
89 sum += el.Salary;
90 itog = sum * 12;
91 }
92
93 return itog;
94 }
95
96 }
97 public List <Employees> AllEmployees = new List <Employees>();
98
99
100
101 public Department ( string name, string adress)
102 {
103 NameOfDepartment = name;
104 Adress = adress;
105 }
106
107
108
109 }
110 public class App
111 {
112 public static void Main(string[] args)
113 {
114 string birthKatya = "21/09/2000";
115
116 DateTime birthKatyaa = Convert.ToDateTime(birthKatya);
117 string birthAnton = "30/04/1999";
118 DateTime birthAntonn = Convert.ToDateTime(birthAnton);
119 string birthAlisa = "10/01/2000";
120 DateTime birthAlisaa = Convert.ToDateTime(birthAlisa);
121 string birthOlya = "17/11/1945";
122 DateTime birthOlyaa = Convert.ToDateTime(birthOlya);
123
124 Department palata1 = new Department ( "palata1", "Goncharnaya");
125 Department palata2 = new Department ( "palata2", "Tverskaya");
126
127 Employees eKatya = new Employees ("Katya", birthKatyaa, 2000, palata1);
128 Employees eAnton = new Employees ("Anton", birthAlisaa, 1, palata1);
129 Employees eOlya = new Employees ("olya", birthOlyaa, 10, palata2);
130 Employees eAlisa = new Employees ("Alisa", birthAlisaa, 50, palata2);
131
132 palata1.AllEmployees.Add(eKatya);
133 palata1.AllEmployees.Add(eAnton);
134 palata2.AllEmployees.Add(eOlya);
135 palata2.AllEmployees.Add(eAlisa);
136
137
138 Console.WriteLine(palata1.TotalYearlyPayment);
139 Console.WriteLine(palata2.TotalYearlyPayment);
140 Console.WriteLine(palata2.Adress);
141 Console.WriteLine("jdncijdf");
142
143
144
145 }
146 }
147}