-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson_37.cs
123 lines (108 loc) · 2.4 KB
/
lesson_37.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
public virtual void Display()
{
Console.WriteLine(Name);
}
}
class Employee : Person
{
public string Company { get; set; }
public Employee(string name, string company) : base(name)
{
Company = company;
}
}
static void Main(string[] args)
{
Person p1 = new Person("Bill");
p1.Display(); // вызов метода Display из класса Person
Employee p2 = new Employee("Tom", "Microsoft");
p2.Display(); // вызов метода Display из класса Person
Console.ReadKey();
}
class Employee : Person
{
public string Company { get; set; }
public Employee(string name, string company)
: base(name)
{
Company = company;
}
public override void Display()
{
Console.WriteLine($"{Name} работает в {Company}");
}
}
static void Main(string[] args)
{
Person p1 = new Person("Bill");
p1.Display(); // вызов метода Display из класса Person
Employee p2 = new Employee("Tom", "Microsoft");
p2.Display(); // вызов метода Display из класса Employee
Console.ReadKey();
}
class Credit
{
public virtual decimal Sum { get; set; }
}
class LongCredit : Credit
{
private decimal sum;
public override decimal Sum
{
get
{
return sum;
}
set
{
if (value > 1000)
{
sum = value;
}
}
}
}
class Program
{
static void Main(string[] args)
{
LongCredit credit = new LongCredit { Sum = 6000 };
credit.Sum = 490;
Console.WriteLine(credit.Sum);
Console.ReadKey();
}
}
class Employee : Person
{
public string Company { get; set; }
public Employee(string name, string company)
: base(name)
{
Company = company;
}
public override void Display()
{
base.Display();
Console.WriteLine($"работает в {Company}");
}
}
class Employee : Person
{
public string Company { get; set; }
public Employee(string name, string company)
: base(name)
{
Company = company;
}
public override sealed void Display()
{
Console.WriteLine($"{Name} работает в {Company}");
}
}