Question: 3. Next, use the Strategy design pattern (shown below) to replace the field g with a reference to a strategy object (as outlined below). This

 3. Next, use the Strategy design pattern (shown below) to replacethe field g with a reference to a strategy object (as outlined

3. Next, use the Strategy design pattern (shown below) to replace the field g with a reference to a strategy object (as outlined below). This will allow different kinds of gravity models to be associated with a Pendulum instance dynamically. Context interface Strategy +execute0 ConcreteStrategyA +exeaute0 ConcreteS trat egyB +exeaute Name the strategy interface GravityModel, with a single method public double getGravitationalField O; Assume that objects implementing GravityModel will be initialized with all state required to produce the gravitational field value under their specific model, and that this occurs before being assigned to a pendulum. In other words, the pendulums will just use the model assigned to it via the GravityModel interface. Adjust the pendulum constructors so that a GravityModel is assigned on initialization, and add a new method that will allow the GravityMode1 to be changed dynamically Define one concrete strategy called GravityConstant. This class simply receives a constant value for g in its constructor

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!