Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Human {
- class Program {
- static void Main(string[] args) {
- Forum flashback = new Forum();
- flashback.members.Add(new Spanish());
- flashback.members.Add(new Swedish());
- flashback.members.Add(new English());
- Console.WriteLine("Humans created: " + Human.objectsCreated);
- flashback.MakePeopleTalk();
- Console.ReadKey(true);
- }
- }
- public class Forum {
- public Forum() {
- members = new List<Human>();
- }
- public void MakePeopleTalk() {
- foreach(Human h in members) {
- h.Talk();
- }
- }
- public List<Human> members;
- }
- public interface INationalSong {
- string getNationalSongTitle();
- }
- public abstract class Human {
- public static int objectsCreated { get; private set; } = 0;
- public Human() { objectsCreated++; }
- public virtual void Talk() {
- Console.WriteLine("The human says: hi mi estas viro");
- }
- public abstract void sayHello();
- }
- public class Swedish : Human, INationalSong {
- public Swedish() { }
- public void sing() {
- Console.WriteLine("Nä, här i sverige sjunger man inte");
- }
- public override void Talk() {
- Console.WriteLine("The swede says: flashback forum är ju där man får lite vett om världen");
- }
- public override void sayHello() {
- Console.WriteLine("Tjänare Bengt");
- }
- string INationalSong.getNationalSongTitle() {
- return "Du gamla du fria";
- }
- }
- public class English : Human {
- public English() { }
- public override void sayHello() {
- Console.WriteLine("Good evening, sir");
- }
- public override void Talk() {
- Console.WriteLine("The englishman says: it's tea o'clock *slurp slurp*");
- }
- }
- public class Spanish : Human {
- public Spanish() { }
- public override void sayHello() {
- Console.WriteLine("Ni hao");
- }
- public override void Talk() {
- Console.WriteLine("The spaniard says: hola hola maldito burrito");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement