static void Main(string[] args) { // now the attacker is EnemyTank EnemyTank enemyTank = new EnemyTank(); Console.WriteLine("Enemy tank in Basic action\n--------------------------------------"); enemyTank.assignDriver("Tom"); enemyTank.driveForward(); enemyTank.fireWeapon(); // Enemy Robot basic functionality EnemyRobot enemyRobot = new EnemyRobot(); Console.WriteLine("\n\nEnemy robot in Basic action\n--------------------------------------"); enemyRobot.reactToHuman("Tom"); enemyRobot.walkForward(); enemyRobot.smashWithHands(); // Use adapter to change the functionality Enemy Robot EnemyRobotAttackerAdapter enemyRobotAttackerAdapter = new EnemyRobotAttackerAdapter(enemyRobot); Console.WriteLine("\n\nEnemy robot in action\n--------------------------------------"); enemyRobotAttackerAdapter.assignDriver("Tom"); enemyRobotAttackerAdapter.driveForward(); enemyRobotAttackerAdapter.fireWeapon(); Console.ReadKey(); }
public void AdapterTesting() { EnemyTank xkf = new EnemyTank(); EnemyRobot robin = new EnemyRobot(); IEnemyAtacker robotAdapter = new EnemyRobotAdapter(robin); Console.WriteLine("The robot"); robin.reactToHuman("Benny"); robin.walkForward(); robin.smashWithHands(); Console.WriteLine("The tank"); xkf.assignDriver("Hood"); xkf.driveForward(); xkf.fireWapon(); Console.WriteLine("The robot with adapter"); robotAdapter.assignDriver("Batman"); robotAdapter.driveForward(); robotAdapter.fireWapon(); Console.ReadLine(); }
public void driveForward() { theRobot.walkForward(); }
public void driveForward() { enemyRobot.walkForward(); }