using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bridge
{
public interface Tank
{
void shut();
void fangpao();
void run();
}
public class T30 : Tank
{
public void shut()
{
Console.WriteLine("T30 shunt");
}
public void fangpao()
{
Console.WriteLine("T30 fangpao");
}
public void run()
{
Console.WriteLine("T30 run");
}
} public class T40 : Tank
{
public void shut()
{
Console.WriteLine("T40 shunt");
}
public void fangpao()
{
Console.WriteLine("T40 fangpao");
}
public void run()
{
Console.WriteLine("T40 run");
}
}
public abstract class TankAdapter
{
public Tank TankHelper;
public abstract void Doshut();
public abstract void Dofangpao();
public abstract void Dorun();
}
public class MobileTan : TankAdapter
{
public override void Doshut() { Console.WriteLine("mobile"); TankHelper.shut(); }
public override void Dofangpao() { TankHelper.fangpao(); }
public override void Dorun() { TankHelper.run(); } } public class PcTank : TankAdapter {
public override void Doshut() { Console.WriteLine("pc tank"); TankHelper.shut(); }
public override void Dofangpao() { TankHelper.fangpao(); }
public override void Dorun() { TankHelper.run(); } }
public class Program { static void Main(string[] args) { TankAdapter tank = new PcTank(); tank.TankHelper = new T40(); tank.Dofangpao(); tank.Dorun(); tank.Doshut(); Console.WriteLine("\n\n----------------------"); TankAdapter tank1 = new MobileTan(); tank1.TankHelper = new T30(); tank1.Dofangpao(); tank1.Dorun(); tank1.Doshut(); Console.ReadKey(); } } }