Question: PROBLEM #3 (35 points) There exist two clients (Client-1 and Client-2) and a GasPump class. The GasPump class supports the following operations: PayCash(int), PayCredit(int), PayDebit(int),

PROBLEM #3 (35 points) There exist two clients (Client-1 and Client-2) and

PROBLEM #3 (35 points) There exist two clients (Client-1 and Client-2) and a GasPump class. The GasPump class supports the following operations: PayCash(int), PayCredit(int), PayDebit(int), PumpGallon(int), and PumpLiter(int). Clients can pay for the gas by cash, credit or debit. After paying they can pump gas in gallons or litters. Client-1 invokes PayCash(int) and PumpGallon(int). Client-2 invokes PayDebit(int) and PumpLiter(int). The current design is shown below: Client-1 GetGas() GasPump PayCash(int ) Client-2 PayCredit(int) GetGas() PayDebit(int ) PumpGallon(int) PumpLiter(int) In a better design Clients should be shielded from different versions of paying for the gas, i.e., PayCash(int), PayCredit(int), PayDebit(int), and different ways of pumping the gas, i.e., PumpGallon(int) and PumpLiter(int). In the new design, Client-1 should invoke Pay(int) and PumpGas(int), where PayCash(int) and PumpGallon(int) are executed. Similarly, Client-2 should invoke Pay(int) and PumpGas(int), where PayDebit(int) and PumpLiter(int) are executed. Client-1 GasPump GetGas() Pay(int PumpGas(int ) Client-2 GetGas() Use the strategy pattern and the abstract factory design patterns to solve this problem. In your solution the Client classes should be completely de-coupled from the issue of invoking appropriate versions of Pay(int) and PumpGas(int). Notice that none of the classes (and operations) shown in the above class diagram should be modified. However, new operations/classes can be introduced. . Provide the class diagram and briefly describe the responsibility of each class and the functionality of each operation using pseudo-code. In your design, all components should be decoupled as much as possible. Provide a sequence diagram to show how Client-1 gets services PayCash(int) and PumpGallon(int) by invoking Pay(int) and PumpGas(int) on the GasPump

PROBLEM #3 (35 points) There exist two clients (Client-1 and Client-2) and a GasPump class. The Gas Pump class supports the following operations: Pay Cash(int), PayCredit(int), PayDebit(int), Pump Gallon(int), and PumpLiter(int). Clients can pay for the gas by cash, credit or debit. After paying they can pump gas in gallons or litters. Client-1 invokes PayCash(int) and PumpGallon(int). Client-2 invokes PayDebit(int) and pumpLiter(int). The current design is shown below: Client-1 GetGas() Client-2 GetGas() In a better design Clients should be shielded from different versions of paying for the gas, i.e., Pay Cash(int), PayCredit(int), PayDebit(int), and different ways of pumping the gas, i.e., PumpGallon(int) and PumpLiter(int). In the new design, Client-1 should invoke Pay(int) and Pump Gas(int), where PayCash(int) and Pump Gallon (int) are executed. Similarly, Client-2 should invoke Pay(int) and Pump Gas(int), where PayDebit(int) and PumpLiter(int) are executed. Client-1 GetGas() GasPump Pay Cash(int) PayCredit(int) PayDebit(int) PumpGallon(int) PumpLiter(int) Client-2 GetGas() GasPump Pay(int) PumpGas (int) Use the strategy pattern and the abstract factory design patterns to solve this problem. In your solution the Client classes should be completely de-coupled from the issue of invoking appropriate versions of Pay(int) and PumpGas (int). Notice that none of the classes (and operations) shown in the above class diagram should be modified. However, new operations/classes can be introduced. Provide the class diagram and briefly describe the responsibility of each class and the functionality of each operation using pseudo-code. In your design, all components should be decoupled as much as possible. Provide a sequence diagram to show how Client-1 gets services PayCash(int) and Pump Gallon(int) by invoking Pay(int) and Pump Gas(int) on the GasPump.

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 Programming Questions!