Question: Imagine that we are developing a war game. The enemies in the game are actually some machines like car, tank, plane, etc. The abilities of

 Imagine that we are developing a war game. The enemies in

Imagine that we are developing a war game. The enemies in the game are actually some machines like car, tank, plane, etc. The abilities of the enemies are defined in IEnemy interface. Using this interface, we have already coded the Enemy Tank class. A friend who knows about our game project but is unaware of the IEnemy interface has wanted to contribute our project, and has sent us the codes of EnemyRobot class. The class works perfectly and we definitely want to include it in our game because we don't want to hurt the feelings of the friend. Unfortunately, however, its interface is incompatible with our subsystem. Besides, we don't want to convert its source code because for any small future change by the friend will have to be converted again and again. This takes too much and unnecessary effort! Then, we come up with a solution! Why don't we adapt EnemyRobot using Adapter Design Pattern? This is a perfect idea! Let's do it! Now, you are expected to adapt EnemyRobot class into our subsystem. 1. First, draw UML class diagram of your design. 2. Then, code your design in an object oriented programming language like C#, Java, etc. Don't forget to include some client code to show how you use the EnemyRobot class. > IEnemy EnemyRobot UseWeapon() Move(). GetEnemyName() : String +Punch() +Walk) +RobotName(): String

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!