title: Auto increment ID between classes - JAVA
body: <p>A hypothetical garage is storing Vehicles (Cars and Bikes).</p>
  
  <p>I am wanting an auto-incrementing id system but I'm not entirely sure how to set it up properly. Please see my code below...</p>
  
  <p><strong>Vehicle</strong></p>
  
  <pre><code>public class Vehicle {
      String make;
      String model;
      int year;
      int id;
      double bill;
  }
  </code></pre>
  
  <p><strong>Car (extends Vehicle)</strong></p>
  
  <pre><code>public class Car extends Vehicle {
  private int noDoors;
  public Car(String make, String model, int year, int noDoors) {
      this.id = id++;
      this.noDoors = noDoors;
      this.make = make;
      this.model = model;
      this.year = year;
  }
  </code></pre>
  
  <p>}</p>