static void Main(string[] args) { var samsungS8 = new SamsungS8(); var andoidCharger = new AndoidCharger(); andoidCharger.Charge(samsungS8); var iphoneX = new IPhoneX(); var iphoneCharger = new IPhoneCharger(); iphoneCharger.Charge(iphoneX); // Adapter var adapter = new AndroidToIphoneAdapter(samsungS8); iphoneCharger.Charge(adapter); var tank = new EnemyTank(); Attack(tank); var enemyRobot = new EnemyRobot(); var enemyRobotAdapter = new EnemyRobotAdapter(enemyRobot); Attack(enemyRobotAdapter); // Not the best... ILocomotion car = new FordFigo(); var speed = car.Speed(); var speedAdpater = new SpeedAdapter(car); speedAdpater.Speed(); }
private static void Main(string[] args) { //IBattery battery = new SamsungBattery(); //MobilePhone phone = new AsusPhone(battery); //phone.TryReplaceBattery(); //Console.WriteLine(" "); //phone = new IPhoneX(battery); //phone.TryReplaceBattery(); IBattery battery = _dIContainer.Resolve <ISamsungBattery>(); MobilePhone phone = new AsusPhone(battery); phone.TryReplaceBattery(); Console.WriteLine(" "); phone = new IPhoneX(battery); phone.TryReplaceBattery(); }