In a user interface, a "radio button group" is a group of buttons in which exactly one button may be selected at a time. (If you press one button, the other button that is currently selected "pops up" like buttons on an old-fashioned radio.)
Your task is to implement a class that models this behavior. The class represents a group of buttons; the number of buttons is specified at construction. The class tracks which button is selected.
We've provided a code skeleton in RadioButtonGroup.java. Implement all methods that have been provided. Add class attributes and helper methods as needed, but do not change any of the provided method signatures.
Your implementation should raise RuntimeException
on invalid input, as
specified in the methods' JavaDoc comments.
Feel free to add a main()
method to test the logic, if you wish.