Bay Jhon
Hectopat
- Katılım
- 10 Kasım 2018
- Mesajlar
- 80
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InterfacesDemo.
{
class Program.
{
static void Main(string[] args)
{
IWorker[] worker = new IWorker[3];
worker[0] = new Yonetici(); worker[1] = new Isci(); worker[2] = new Robot();
for (int i = 0; i <= 3; ++i)
{
Console.WriteLine(worker[I]);
worker[I].Work();
Console.WriteLine("Çalış!");
Console.ReadLine();
}
IEat[] eats = new IEat[2];
eats[0] = new Yonetici(); eats[1] = new Isci();
for (int j = 0; j <= 2; ++j)
{
Console.WriteLine(eats[j]);
eats[j].Eat();
Console.WriteLine("Yemek Zamanı !");
}
IGtSalary[] gtSalaries = new IGtSalary[2];
gtSalaries[0] = new Yonetici(); gtSalaries[1] = new Isci();
for (int k = 0; k <= 2; ++k)
{
Console.WriteLine(gtSalaries[k]);
gtSalaries[k].GetSalary();
Console.WriteLine("Maaş Al !");
}
interface IWorker.
{
void Work();
}
interface IEat.
{
void Eat();
}
interface IGtSalary.
{
void GetSalary();
}
class Yonetici : IWorker, IEat, IGtSalary.
{
public void Eat()
{
Console.WriteLine("Yemek Ye !");
}
public void GetSalary()
{
Console.WriteLine("Maaş Al !");
}
public void Work()
{
Console.WriteLine("Çalış !");
}
}
class Isci : IWorker, IEat, IGtSalary.
{
public void Eat()
{
Console.WriteLine("Yemek Ye !");
}
public void GetSalary()
{
Console.WriteLine("Maaş Al !");
}
public void Work()
{
Console.WriteLine("Çalış !");
}
}
class Robot : IWorker.
{
public void Work()
{
Console.WriteLine("Çalış !");
}
}
}
}
Arkadaşlar yardımcı olur musunuz? Bekleniyor hatası veriyor, sorunu bulamadım.
Dosya Ekleri
Son düzenleyen: Moderatör: