import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.DecimalFormat; import java.util.*; /** * A wrapper class for JPanel creates a list of option */ public class OptionPanel extends JPanel implements ActionListener { private JToggleButton[] buttons; private Option[] options; private EggShop eggShop; /** * update the price whenever an option changes */ public void actionPerformed(ActionEvent e) { //COMPLETE ME! } /** * Create a new OptionPanel * @param eggShop the window to which this panel is added * @param options an array of Options to be displayed * @param title the title for the panel * @param group if this is true, then the panel will contain a * group of radio buttons. if false, then it will contain check boxes. */ OptionPanel(EggShop eggShop, Option[] options, String title, Boolean group) { super(); this.eggShop = eggShop; this.options = options; this.buttons = new JToggleButton[options.length]; ButtonGroup buttonGroup = new ButtonGroup(); this.setBorder(BorderFactory.createTitledBorder(title)); setLayout(new GridLayout(0,1)); //Convert the array of Options to an array of Buttons //(either JRadioButton or JCheckBox). Don't forget to add the buttons // to the ButtonGroup if they should have only one selected at a time! //COMPLETE ME! // Uncomment this once you've completed above - // it will set the first radio button to be selected by default /* if (group && options.length > 0) { buttons[0].setSelected(true); } */ } /** * Get the total price of all the options selected * @returns total price */ public double getPrice() { //COMPLETE ME! return 0.0; } }