USING JAVA, Create a GUIDisplay class that implements the DisplayMethod interfac
ID: 3775219 • Letter: U
Question
USING JAVA, Create a GUIDisplay class that implements the DisplayMethod interface and uses JOptionPane.showMessageDialog(null,String) to print the information contained in a financial card (debit or credit). Print the name, balance, type of card, and apr.
/**
* DisplayMethod encapsulates the display() behavior in a Strategy Pattern.
*
*
*/
public interface DisplayMethod
{
/**
* The display() method displays the information contained in a financial card account
*
* @param acard a reference to a financial card account that should be displayed
*/
void display(AbstractCardAccount acard);
}
Explanation / Answer
GUIDisplay.java
import javax.swing.JOptionPane;
public class GUIDisplay implements DisplayMethod{
public void display(AbstractCardAccount acard) {
DebitCardAccount d = (DebitCardAccount)acard;
JOptionPane.showMessageDialog(null,"Name: "+acard.getName()+" Balance: "+acard.getBalance()+" Typpe of card: "+d.getIssuer()+" Apr: "+acard.getAPR());
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.