Reputation: 101
how can i store this displayPriceMessage method with argumetnt in variable
//method of displayPriceMethod
public void displayPriceMessage(String name, String msg, boolean cream, boolean coke)
{
priceamoutntxt.setText("\n Name: "+Ename.getText().toString()+"\n total : "+priceamoutntxt.getText()+"\n Add Ice-Cream ?"+ cream +"\n Add Coca-Cola ?"+coke+"\n than you ");
}
// displayPriceMessage argumetnt
displayPriceMessage("ename","",isIceCream, cocaCola);
Upvotes: 0
Views: 58
Reputation: 5729
You can do this in FP. Perhaps you would need a custom Functional Interface.
DisplayPriceMessage displayPriceMessage = this::displayPriceMessage;
public void displayPriceMessage(String name, String msg, boolean cream, boolean coke)
{
priceamoutntxt.setText("\n Name: "+Ename.getText().toString()+"\n total : "+priceamoutntxt.getText()+"\n Add Ice-Cream ?"+ cream +"\n Add Coca-Cola ?"+coke+"\n than you ");
}
Create a functional interface having an abstract method of similar signature as that of displayPriceMessage
@FunctionalInterface
interface DisplayPriceMessage {
void displayPriceMessage(String name, String msg, boolean cream, boolean coke);
}
Upvotes: 1