class ModeCounter()
Class to keep track of the mode in a list of numbers.
Attributes:
frequency_dictionary
- A dictionary where keys are numbers and values are their frequencywinning_frequency
- The highest frequency among all numbers.winner
- The number with the highest frequency.
def __init__()
Initializes frequency dictionary and sets winning_frequency to 0
def add_number(number)
Adds a number to the frequecny dictionary and update the mode.
Arguments:
number
- The number to be added.
def update(number)
Updates the current mode if the frequency of the number is higher than the current modes frequency.
args: number: The number to be checked against the current mode.
def get()
Returns the winner
Returns:
The number with the highest frequency.