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 ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dog dog = new Dog();
- Cat cat = new Cat();
- Trainer gosho = new Trainer(dog);
- gosho.Make();
- Trainer penio = new Trainer(cat);
- penio.Make();
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- interface ITrick
- {
- string MakeTrick();
- }
- interface INoise
- {
- string MakeNoice();
- }
- interface IAnimal:ITrick,INoise
- {
- void Perform();
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Dog:IAnimal
- {
- public string MakeNoice()
- {
- return "jaf!";
- }
- public string MakeTrick()
- {
- return "backflip";
- }
- public void Perform()
- {
- Console.WriteLine( MakeNoice());
- Console.WriteLine( MakeTrick());
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Cat:IAnimal
- {
- public string MakeNoice()
- {
- return "MEW!";
- }
- public string MakeTrick()
- {
- return "nqq pa";
- }
- public void Perform()
- {
- Console.WriteLine(MakeNoice());
- Console.WriteLine(MakeTrick());
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Trainer
- {
- private IAnimal entity;
- public Trainer(IAnimal animal)
- {
- entity = animal;
- }
- public void Make()
- {
- entity.Perform();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement