-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKod12_Interfaces.cs
More file actions
53 lines (46 loc) · 1.37 KB
/
Kod12_Interfaces.cs
File metadata and controls
53 lines (46 loc) · 1.37 KB
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
using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
/*Задача 12:Интерфейс + реализация
Создай интерфейс IRepairable с методом Repair().
Создай класс Phone и класс Laptop, реализующие этот интерфейс.
В Main создай список объектов, которые реализуют IRepairable, и вызови Repair() у каждого.*/
namespace testing
{
interface IRepairable
{
void Repair();
}
class Phone : IRepairable
{
public void Repair()
{
Console.WriteLine("Меня починить просто");
}
}
class Laptop : IRepairable
{
public void Repair()
{
Console.WriteLine("Меня починить сложнее");
}
}
class IPhone : IRepairable
{
public void Repair()
{
Console.WriteLine("Меня починить сложнее и дороже");
}
}
internal class Program
{
static void Main(string[] args)
{
IRepairable[] devices = new IRepairable[] { new Phone(), new Laptop(), new IPhone() };
foreach (var device in devices)
{
device.Repair();
}
}
}
}