1.

You Are Designing A Single Person Shooter Game Application. The Player Can Choose Between Multiple Guns. 1) Pistol With 5 Bullets 2) Shotgun With 100 Bullets 3) Grenade Launcher With 20 Grenades Each Gun Will Have Different Sound Effects And Graphics.pressing Ctrl+space Should Rotate Between Guns.which Design Pattern Should You Employ For This?

Answer»

Use Strategy Pattern.
Explanation: Each GUN having different performance and GRAPHICS.
So this can be accomodated in the algorithm.
Strategy pattern is best suited for shifting the guns/algorithms There will be a IGun INTERFACE implemented by 3 classes
Pistol :IGun
SHOTGUN :IGun
GrenadeLauncher :IGun

Use Strategy Pattern.
Explanation: Each gun having different performance and graphics.
So this can be accomodated in the algorithm.
Strategy pattern is best suited for shifting the guns/algorithms There will be a IGun interface implemented by 3 classes
Pistol :IGun
Shotgun :IGun
GrenadeLauncher :IGun



Discussion

No Comment Found