title: Java practice question with objects and inheritance, need advice (beginner)
body: <p>First thing, can someone check my code if it's going on the right side. I don't understand one thing, <code>add the toString()</code> method that prints the information about a ship, toString method only accepts String as a return, but all my variables are ints. So how am I supposed to return the information there?</p>
  <p>When I am trying to add an ArrayList in the Fleet class, I am getting <code>ArrayList cannot be resolved a type</code>.</p>
  <p>And the last part where it says in <code>main()</code>, is this supposed to be in the Ship class or the Fleet class?</p>
  <p>The question I'm working on.</p>
  <p>Define the class Ship containing side lengths, number of passengers, displacement, unique number ship, three versions of the overloaded constructor, a method to calculate the surface area (it should
  assumed to be rectangular in shape).</p>
  <p>Then define the classes:</p>
  <ul>
  <li>Destroyer inheriting from the Ship class and supplemented with information about the force of fire and the number of
  guns,</li>
  <li>Aircraft carrier inherits from Destroyer class and adds data about the number of aircraft it can carry.</li>
  <li>To both classes (Destroyer and Aircraft Carrier) add the toString() method that prints the relevant
  information about the ships.</li>
  </ul>
  <p>Finally, define a Fleet class containing:</p>
  <ul>
  <li>A list (ArrayList) with elements of type Ship, which will be filled dynamically by
  the addToFleet(Ship) method created for this purpose</li>
  <li>The fleetStrength() method which counts the firepower, number of passengers and guns in the fleet</li>
  <li>In main() create a Fleet type object and fill it with random data. Print information about
  ships (use toString() and fleetStrength()).</li>
  </ul>
  <pre class="lang-java prettyprint-override"><code>public class Ship {
      protected int id;
      protected int sideA;
      protected int sideB;
      protected int passengers;
      protected int displacement;
  
      public Ship() {};
      
      public Ship(int id, it sideA, int sideB, int passengers, int displacement) {
          this.id = id;
          this.sideA = sideA;
          this.sideB = sideB;
          this.passengers = passengers;
          this.displacement = displacement;
      }
      public int calculateSurfaceArea(){
          return this.sideA*this.sideB;
      }
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class Destroyer extends Ship {
      protected int force;
      protected int guns;
   
      Public Destroyer() {}
      
      Public Destroyer(int a, int b) {
          this.force = a;
          this.guns = b;
      }
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class AircraftCarrier extends Destroyer {
      protected int carriers;
      
      Public AirCraftCarrier() {}; 
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class Fleet extends Ship {   
      protected var shipList = new ArrayList&lt;Ship&gt;();
  }
  </code></pre>