Question: PROBLEM #2 (60 points) The GasPump class (component) supports the following operations: change. How the system notifies the registered user component about the out-of-range

PROBLEM #2 (60 points) The GasPump class (component) supports the following operations:

PROBLEM #2 (60 points) The GasPump class (component) supports the following operations: change. How the system notifies the registered user component about the out-of-range stock price change. Activate (float a, b) PayCredit(float limit) PayCash(float c) Regular() Super() StartPump() PumpGallon() StopPump() Receipt() TurnOff() The GasPump is a state-based component that is used to control a simple gas pump. Users can pay by cash or a credit card. The gas pump disposes two types of gasoline: Regular and Super. The price of gasoline is provided when the gas pump is activated. A simplified EFSM model for the GasPump component is shown in Figure 1. Design the system using the State design pattern. Provide two solutions: de-centralized version of the State pattern centralized version of the State pattern // the gas pump is activated where a represents the price of Regular gas // and b represents the price of Super gas // pay for gas by a credit card where limit represents the available credit on // the credit card // pay for gas by cash, where c represents prepaid cash // Regular gas is selected Notice that the components in your design should be de-coupled as much as possible. In addition, components should have high cohesion. T Activate(a,b)/ Rprice=a; Sprice=b; // Super gas is selected // start pumping gas For each solution: a. Provide a class diagram for the system. For each class list all operations with parameters and specify them using pseudo-code. In addition, for each class provide its attributes and data structures. Make the necessary assumptions for your design. Start price=a: G=0; // one gallon of gas is disposed // stop pumping gas // Receipt is printed // the gas pump is turned off b. Provide a sequence diagram for the following operation sequence: Activate (5.5,7), PayCredit(110), Super(), StartPump(), PumpGallon(), StopPump(), Receipt() T14 TurnOff() Exit When the EFSM model is "executed" on this sequence of operations, the following sequence of transitions is traversed/executed: T, T3, T6, T7, T9, T11, T13 S5 T PayCredit(limit) [limit 0]/w=1; T11 StopPump()/ total=G*price; Tg PumpGallon()/G=G+1 T12 PumpGallon()[cash =price*(G+1)]/ G=G+1; T5 Regular()/ price = Rprice; T7 StartPump()[w==1] T8 StartPump() [w==0]/ cash-cash 1.1, S T6 Super()/ price = Sprice;

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!