class Schedule:
    """Schedule class for managing and executing events in the simulation."""

    def __init__(self):
        """Initialize a Schedule."""
        self.events = []
        self.current_step = 0

    def add_event(self, step, event):
        """
        Add an event to the schedule.

        Args:
            step: Time step at which to execute the event
            event: Event to schedule
        """
        self.events.append({"step": step, "event": event})
        # Keep events sorted by step
        self.events.sort(key=lambda x: x["step"])

    def execute_next_event(self):
        """
        Execute the next event in the schedule.

        Returns:
            The executed event, or None if no events remain
        """
        if self.events:
            next_event = self.events.pop(0)
            self.current_step = next_event["step"]
            return next_event["event"]
        return None

    def get_events(self):
        """
        Get all remaining events.

        Returns:
            List of scheduled events
        """
        return self.events

    def get_current_step(self):
        """
        Get the current simulation step.

        Returns:
            Current step number
        """
        return self.current_step

    def __repr__(self):
        return f"Schedule(current_step={self.current_step}, events={len(self.events)})"