title: How to return count for every class's count and not of every class's instance count
body: <p>I've got:</p>
  
  <ul>
  <li><strong>interface</strong> - ISpacecraft</li>
  <li><strong>abstract class</strong> - Spacecraft (implements the interface above)</li>
  <li><strong>Classes</strong> - 4 Kind of ships (derived children of Spacecraft)</li>
  </ul>
  
  <p>Task: Return the count of every ship, if I have 2 cargoShips, then return 2.</p>
  
  <p>Problem: When I iterate through the ArrayList It prints '2' twice, because I have 2 cargoShips.</p>
  
  <p><strong>Expected output:</strong> 2,1,1,2</p>
  
  <p><strong>Current output:</strong> 2,2,1,1,2,2</p>
  
  <p><strong>Question:</strong> How can I iterate through the number of types of ships, instead of all instances of them?</p>
  
  <p>Note: I can't change the signature of 'printInstanceNumberPerClass'.</p>
  
  <p>Code:</p>
  
  <p><strong>StarFleetManagerTester</strong></p>
  
  <pre><code>public static void printInstanceNumberPerClass (ArrayList&lt;ISpacecraft&gt; fleet) 
  {
      ArrayList&lt;ISpacecraft&gt; objects = new ArrayList&lt;&gt;(fleet);
      ArrayList&lt;Integer&gt; cnt = new ArrayList&lt;Integer&gt;();
  
      for(ISpacecraft obj : objects)
      {
          cnt.add(obj.getCount());
      }
      for(ISpacecraft obj : objects)
          System.out.println(obj.getCount() +"  "+obj.getName());
  }
  </code></pre>
  
  <p><strong>Spacecraft</strong></p>
  
  <pre><code>protected static int countCruiser;
  </code></pre>
  
  <p><strong>ISpacecraft</strong></p>
  
  <pre><code>int getCount();
  </code></pre>
  
  <p><strong>cargoShip, ReserarchShip, etc..</strong></p>
  
  <pre><code>private static int count
  @Override
      public int getCount() {
          return this.count;
      }
  </code></pre>