I'm working on a vending machine project, and i tried to split it into UI and BL layers, But I'm getting into problem. For example I have this function for paying in coins, which derives from an abstract class:
public override void Pay(decimal amount)
{
while (currentCoins < amount)
{
// Print instructions
// Get input
if (Valid)
{
// logic
}
else
{
// Print error
}
}
}
So the problem is that i dont have access to the UI inside the BL, but i need continuous communication with the UI. I thought of making function for each payment method in the UI, but it violates OCP...
I'm looking for an elegant solution ideas that won't break SOLID principles.
Is there any desgin pattern or something that can solve my problem? (strategy pattern?) I would appreciate any guidance / idea.
Thanks :)