Question: ) The description below explains the Strategy Pattern: In Strategy pattern, a class behavior or its algorithm can be changed at run time. This type
) The description below explains the Strategy Pattern:
In Strategy pattern, a class behavior or its algorithm can be changed at run time.
This type of design pattern falls under the set of behavior patterns. Its Intent is:
Define a family of algorithms, encapsulate each one, and make them interchange- able. Strategy lets the algorithm vary independently from the clients that use it.
Capture the abstraction in an interface, bury implementation details in derived classes
You have the following operations:
add : a + b
subtract: a?b
divide: a/b,assumeaandbareNEVER0.
multiply : a ? b;
power: ab ,araisetothepowerofb. Ex. 24 =16.
We will make the following assumptions:
1 ALL operands are ints.
2 ALL return values are ints.
3 Classes do not need any data-fields
4 Classes do not need any Constructors
Implement a set of classes and an interface that adheres to the Strategy Pattern.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
