Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 public void assignDriver(string driver)
 {
     theRobot.reactToHuman(driver);
 }
Ejemplo n.º 4
0
 public void assignDriver(string d)
 {
     enemyRobot.reactToHuman(d);
 }