Designing a class according to its purpose

  1. Problem description:

    Write a program that reads in N integers between 1 and K and prints number of times that each number appeared in the input. The sequence is terminated by 0.

    Example: if the numbers entered are 1, 2, 3, 1, 1, 1, 2, 2, 1, 0   then the program prints:

         1: 5 times
         2: 3 times
         3: 1 times
    

  2. Can you discover an object or objects in this problem description ?

    Can you discern a well-defined function or functions for some object to perform ?

  3. The object: click here

  4. How to design the class after discerning its function:

    1. Determine what the objects of the class can do (interface design): click here

    2. Determine what the instance variables are needed to perform the methods: click here

    3. Write the methods (implementation): click here

    4. TEST !!! click here