aim4.vehicle

## Class VehicleSpecDatabase

- java.lang.Object
- - aim4.vehicle.VehicleSpecDatabase

-     public class VehicleSpecDatabase
      extends Object

  The vehicle specification database.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getIdByName(String name)` Get the id of the vehicle specification.
    `static int` | `getIdOfVehicleSpec(VehicleSpec spec)` Get the id of the vehicle specification.
    `static int` | `getNumOfSpec()` Get the total number of vehicle specifications in the database
    `static VehicleSpec` | `getVehicleSpecById(int id)` Get the vehicle specification.
    `static VehicleSpec` | `getVehicleSpecByName(String name)` Get the vehicle specification.
    `static void` | `registerSpec(VehicleSpec spec)` Register a vehicle specification.
    `static boolean` | `replaceSpec(VehicleSpec spec)` Place an registered vehicle spec with a new one.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getNumOfSpec

          public static int getNumOfSpec()

      Get the total number of vehicle specifications in the database
      Returns:
        the total number of vehicle specifications.

    - #### registerSpec

          public static void registerSpec(VehicleSpec spec)

      Register a vehicle specification. It requires that the name of the given vehicle specification is not the same as the name of any registered vehicle specifications.
      Parameters:
        `spec` - the vehicle specification

    - #### replaceSpec

          public static boolean replaceSpec(VehicleSpec spec)

      Place an registered vehicle spec with a new one.
      Parameters:
        `spec` - the new spec
      Returns:
        true if there exists a spec whose name is the same as the new one; false if otherwise.

    - #### getIdOfVehicleSpec

          public static int getIdOfVehicleSpec(VehicleSpec spec)

      Get the id of the vehicle specification. It returns < 0 if the vehicle specification has not been registered.
      Parameters:
        `spec` - the vehicle specification
      Returns:
        the id of vehicle specification; -1 if the vehicle specification has not been registered.

    - #### getIdByName

          public static int getIdByName(String name)

      Get the id of the vehicle specification. It returns < 0 if the vehicle specification has not been registered.
      Parameters:
        `name` - the name of the vehicle specification
      Returns:
        the id of vehicle specification; -1 if the vehicle specification has not been registered.

    - #### getVehicleSpecById

          public static VehicleSpec getVehicleSpecById(int id)

      Get the vehicle specification. It returns null if the vehicle specification id does not exist.
      Parameters:
        `id` - the id of the vehicle specification
      Returns:
        the vehicle specification; null if the vehicle specification id does not exist.

    - #### getVehicleSpecByName

          public static VehicleSpec getVehicleSpecByName(String name)

      Get the vehicle specification. It returns null if the vehicle specification id does not exist.
      Parameters:
        `name` - the name of the vehicle specification
      Returns:
        the vehicle specification; null if the vehicle specification id does not exist.

Copyright © 2013. All rights reserved.