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;
- namespace AdapterExample
- {
- abstract class Flashlight
- {
- public abstract void Light();
- }
- abstract class Mobile
- {
- public abstract void Call(string person);
- }
- class Mobile2Flashlight : Flashlight
- {
- Mobile mobile;
- public Mobile2Flashlight(Mobile m)
- {
- mobile = m;
- }
- public override void Light()
- {
- mobile.Call(null);
- }
- }
- class iPhone : Mobile
- {
- public override void Call(string person)
- {
- Console.WriteLine("I called {0}!", person);
- }
- }
- class Lighter : Flashlight
- {
- public override void Light()
- {
- Console.WriteLine("I lighted with lighter");
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement