Write a class called Counter that keeps track of how often you see items.
The Counter class will store a list of lists such that each element of the list is an [item, count] pair (where the items are stored in sorted order). For example, the following list of lists counts how often the letters a-f were seen:
[['a', 5], ['b', 6], ['c', 1], ['d', 8], ['f', 2]]
Note that 'e' was never seen so it does not appear in the list.
The Counter class should have a constructor that takes no arguments and initializes the LoL to be empty.It should also support the following methods:
[['a', 6], ['b', 6], ['c', 1], ['d', 8], ['f', 2]]And if we called add('e')
[['a', 6], ['b', 6], ['c', 1], ['d', 8], ['e', 1], ['f', 2]]
You will almost certainly want to write two other methods to help:
When you're all done, write some tests to make sure that it works!