Created
June 28, 2017 02:25
-
-
Save JohnBaek/100566bbe346dc0c1d31f9d3c4da40b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<ISayHello> speakers = new List<ISayHello>(); | |
ISayHello normalSpeaker = new NormalSpeaker(); | |
ISayHello crazySpeaker = new CrazySpeaker(); | |
speakers.Add(normalSpeaker); | |
speakers.Add(crazySpeaker); | |
speakers.ForEach(s => s.SayOutLoud()); | |
Console.ReadKey(); | |
} | |
} | |
public class NormalSpeaker : ISayHello | |
{ | |
public void SayOutLoud() | |
{ | |
Console.WriteLine("Normarl Speaker"); | |
} | |
} | |
public class CrazySpeaker : ISayHello | |
{ | |
public void SayOutLoud() | |
{ | |
Console.WriteLine("Fuck!"); | |
} | |
} | |
public interface ISayHello | |
{ | |
void SayOutLoud(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment