Exemplo n.º 1
0
        static void Main(string[] args)
        {
            EnemyTank rx7Tank = new EnemyTank();
		
		    EnemyRobot fredTheRobot = new EnemyRobot();
		
		    EnemyAttacker robotAdapter = new EnemyRobotAdapter(fredTheRobot);
		
		    Console.WriteLine("The Robot");
		
		    fredTheRobot.ReactToHuman("Paul");
		    fredTheRobot.WalkForward();
		    fredTheRobot.SmashWithHands();
		    Console.WriteLine();
		
		    Console.WriteLine("The Enemy Tank");
		
		    rx7Tank.AssignDriver("Frank");
		    rx7Tank.DriveForward();
		    rx7Tank.FireWeapon();
            Console.WriteLine();
		
		    Console.WriteLine("The Robot with Adapter");
		
		    robotAdapter.AssignDriver("Mark");
		    robotAdapter.DriveForward();
		    robotAdapter.FireWeapon();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            EnemyTank rx7Tank = new EnemyTank();

            EnemyRobot fredTheRobot = new EnemyRobot();

            EnemyAttacker robotAdapter = new EnemyRobotAdapter(fredTheRobot);

            Console.WriteLine("The Robot");

            fredTheRobot.ReactToHuman("Paul");
            fredTheRobot.WalkForward();
            fredTheRobot.SmashWithHand();

            Console.WriteLine("The Enemy Tank");

            rx7Tank.AssignDriver("Frank");
            rx7Tank.DriveForward();
            rx7Tank.FireWeapon();

            Console.WriteLine("The Robot with Adapter");

            robotAdapter.AssignDriver("Mark");
            robotAdapter.DriveForward();
            robotAdapter.FireWeapon();

            Console.ReadKey();
        }
        void OnEnable()
        {
            Debug.Log ("------------------");
            Debug.Log ("ADAPTER DESIGN PATTERN");

            IEnemyAttacker tank = new EnemyTank();

            EnemyRobot fredTheRobot = new EnemyRobot();
            IEnemyAttacker adapter = new EnemyRobotAdaper(fredTheRobot);

            fredTheRobot.ReactToHuman("Hans");
            fredTheRobot.WalkForward();

            tank.AssignDriver("Frank");
            tank.DriveForward();
            tank.FireWeapon();

            adapter.AssignDriver("Mark");
            adapter.DriveForward();
            adapter.FireWeapon();
        }
        void OnEnable()
        {
            Debug.Log("------------------");
            Debug.Log("ADAPTER DESIGN PATTERN");

            IEnemyAttacker tank = new EnemyTank();

            EnemyRobot     fredTheRobot = new EnemyRobot();
            IEnemyAttacker adapter      = new EnemyRobotAdaper(fredTheRobot);

            fredTheRobot.ReactToHuman("Hans");
            fredTheRobot.WalkForward();

            tank.AssignDriver("Frank");
            tank.DriveForward();
            tank.FireWeapon();

            adapter.AssignDriver("Mark");
            adapter.DriveForward();
            adapter.FireWeapon();
        }
 public EnemyRobotAdaper(EnemyRobot robot)
 {
     this.robot = robot;
 }
Exemplo n.º 6
0
	    public EnemyRobotAdapter(EnemyRobot newRobot)
        {
		    this.theRobot = newRobot;
	    }
 public EnemyRobotAdaper(EnemyRobot robot)
 {
     this.robot = robot;
 }