public static void main(String[] args) {
    Vehicle car = new Vehicle("Tom");
    car.name = "Car";
    car.speed = 80;
    car.orientation = 0;

    Vehicle bicycle = new Vehicle("Jim");
    bicycle.name = "Bicycle";
    bicycle.speed = 10;
    bicycle.orientation = 45;

    Vehicle bike = new Vehicle("Smith");
    bike.name = "Bike";
    bike.speed = 50;
    bike.orientation = 60;

    System.out.println(
        "["
            + car.name
            + "] ID: "
            + car.ID
            + ", Speed: "
            + car.speed
            + "km/h, Orientation: "
            + car.orientation
            + "degree, Owner's Name: "
            + car.ownerName);
    System.out.println(
        "["
            + bicycle.name
            + "] ID: "
            + bicycle.ID
            + ", Speed: "
            + bicycle.speed
            + "km/h, Orientation: "
            + bicycle.orientation
            + "degree, Owner's Name: "
            + bicycle.ownerName);
    System.out.println(
        "["
            + bike.name
            + "] ID: "
            + bike.ID
            + ", Speed: "
            + bike.speed
            + "km/h, Orientation: "
            + bike.orientation
            + "degree, Owner's Name: "
            + bike.ownerName);
  }
Exemple #2
0
 public String vehicle() {
   return vehicle.name();
 }