# widget.py
#
# ICS 33 Spring 2026
# Code Example
#
# A class that briefly demonstrates the use of static methods.


class Widget:

    # This class attribute will store the number of widgets.  We'll update
    # it as it changes.
    _count = 0


    def __init__(self, id):
        # Suppose that each widget has an ID associated with it.  Since
        # that ID is specific to each widget, we'd need to store it in
        # an object attribute.
        self._id = id

        # The act of initializing a new Widget object is what causes the
        # number of widgets to change, so this is the place to update it.
        Widget._count += 1


    # id is not a static method, because it's a question we ask an individual
    # Widget object, rather than one we ask of the entire class.
    def id(self):
        return self._id


    # widget_count is a static method because it's a question we ask the
    # class as a whole, rather than one we ask a particular object of
    # this class.
    @staticmethod
    def widget_count():
        return Widget._count
