/**
 * Represents a generic user interface component that can respond to click actions.
 * Inspired from https://www.codecademy.com/article/understanding-polymorphism-in-python
 * 
 * @author Hyrum D. Carroll
 * @author Gemini 3.6 Flash
 * @version 1.0
 */
class UIElement{
    /**
     * Triggers the element's primary click action.
     * 
     * @return A message describing the result of the click action.
     */
    public String click(){
        return "Element clicked";
    }

}

/**
 * Represents a clickable button UI element.
 * @author Hyrum D. Carroll
 * @author Gemini 3.6 Flash
 * @version 1.0
 */
class Button extends UIElement{
    /**
     * {@inheritDoc}
     */
    @Override
    public String click(){
        return "Button clicked";
    }
}

/**
 * Represents a selectable checkbox UI element.
 * @author Hyrum D. Carroll
 * @author Gemini 3.6 Flash
 * @version 1.0
 */
class Checkbox extends UIElement{
    /**
     * {@inheritDoc}
     */
    @Override
    public String click(){
        return "Checkbox toggled";
    }
}

/**
 * Driver class demonstrating GUI polymorphism.
 * @author Hyrum D. Carroll
 * @author Gemini 3.6 Flash
 * @version 1.0
 */
public class GUIPolymorphismExample{
    /**
     * Handles click events for any polymorphic UI element.
     * 
     * @param element The UI element being clicked.
     */
    public static void handleClick(UIElement element){
        System.out.println(element.click());
    }

    /**
     * Entry point for the GUI polymorphism application.
     * 
     * @param args Command-line arguments (unused).
     */
    public static void main(String[] args){
        UIElement button = new Button();
        UIElement checkbox = new Checkbox();

        // Polymorphic method calls
        handleClick(button);   // Output: Button clicked
        handleClick(checkbox); // Output: Checkbox toggled
    }
}