-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrvni7.cs
86 lines (85 loc) · 2.08 KB
/
Prvni7.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Prvni7;
class Person
{
public int age;
public Person() { }
public Person(int vek)
{
age = vek;
}
public virtual void writeInfo()
{ //
Console.Write($"věk: {age}"); //
} //
}
class Employee : Person
{
public int salary;
public Employee(int vek, int plat)
: base(vek)
{
salary = plat;
}
public override void writeInfo()
{ //
base.writeInfo(); //pokud neuvedeme base., pak rekurzivní volání sebe sama, přeteče zásobník
Console.Write($", salary: {salary}"); //
}
}
class Student : Person
{
public int scholarship;
public Student(int vek, int stipendium)
: base(vek)
{ //
scholarship = stipendium; //
}
public override void writeInfo()
{
base.writeInfo(); //pokud neuvedeme base., pak rekurze
Console.WriteLine($", scholarship: {scholarship}");//
}
}
class Accountant : Employee
{
public Accountant(int vek, int plat)
: base(vek, plat)
{ //
}
public override void writeInfo()
{
base.writeInfo(); //
Console.WriteLine(); //
}
}
class Teacher : Employee
{
public int teachingTime;
public Teacher(int vek, int plat, int uvazek)
: base(vek, plat)
{ //
teachingTime = uvazek; //
}
public override void writeInfo()
{
base.writeInfo(); //
Console.WriteLine($", počet úvazkových hodin: {teachingTime}");
}
}
class Prvni7
{
public static void Mainx()
{
Student s1 = new Student(20, 1000);
s1.writeInfo();
Accountant e1 = new Accountant(30, 12000);
e1.writeInfo();
Teacher u1 = new Teacher(40, 20000, 22);
u1.writeInfo();
}
}