How rishabhrao076/gaspumpmda works
Project type and purpose
• This is a Java-based, console‐driven simulation of two gas pumps (GP1 and GP2) built using Model‐Driven Architecture with an Extended Finite State Machine (MDA‑EFSM).
• It demonstrates three design patterns: Abstract Factory (to build pump families), State (to model EFSM states), and Strategy (to implement each EFSM action).
File structure
• Top‑level:
• Main.java: driver/UI
• src/edu/iit/project/inputprocessor: GP1.java, GP2.java (pump facades)
• src/edu/iit/project/mda: MDAEFSM.java, State hierarchy
• src/edu/iit/project/factories: AbstractFactory + GP1Factory, GP2Factory
• src/edu/iit/project/datastore: DataStore, DS1, DS2
• src/edu/iit/project/strategies: one package per action, each with a base + “1”/“2” implementation
Main components
a. Presentation / UI Layer
• Main (console menu)
• InputProcessor GP1 / GP2 (invokes pump operations)
b. Pump Engine Layer
• MDAEFSM (Context of State pattern)
• State subclasses (S0–S6, Start)
• OP (Output Processor) holding Strategy references
• Strategy objects (StorePrice, PayMessage, DisplayMenu, … each has “1”/“2” variants)
c. Creation Layer
• AbstractFactory (abstract)
• GP1Factory / GP2Factory (concrete) create DataStore + Strategy instances for OP
d. Data Layer
• DataStore (abstract)
• DS1, DS2 (pump‐specific state variables)
Relationships & interactions
• Main → InputProcessor (selects GP1 or GP2)
• InputProcessor → MDAEFSM (calls Activate, StartPump, Pump, etc.)
• MDAEFSM holds current State; events (Activate, Pump, StopPump…) delegate to State objects.
• Each State uses OP to invoke a Strategy (e.g., State.S5 → OP.pum.pumpGas())
• OP strategies read/write through DataStore.
• AbstractFactory wires up:
InputProcessor
↳ AP factory.getDataStore()
↳ factory.StorePrices(), factory.PayMsg(), …
↳ OP configured with strategy instances (setDataStore on each)
Architectural patterns & principles
• State Pattern: MDAEFSM+State subclasses model EFSM transitions and guard actions
• Strategy Pattern: OP decouples “meta‐actions” (store cash, display menu…) into interchangeable behavior objects
• Abstract Factory Pattern: isolates creation of pump‐specific DataStore + strategies, enabling GP1 vs GP2 variants
Final advice
• Dynamic flow: optionally add a sequence overlay showing a sample scenario (Activate → PayCash → StartPump → Pump x N → StopPump).
This structure will clearly represent how the console UI drives pump-specific input processors, how both pumps share an EFSM engine, how operations are dispatched via State + OP + Strategy, and how factories assemble pump‐specific behaviors.