abstract class Vehicle
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Vehicle(java.lang.String vin,
java.lang.String make,
java.lang.String model,
double price,
int mileage,
int year)
The constructor for the vehicle class
|
Modifier and Type | Method and Description |
---|---|
(package private) java.lang.String |
getMake() |
(package private) java.lang.String |
getModel() |
double |
getPrice()
Allows retrieving the price of the car object.
|
java.lang.String |
getVin()
Allows retrieving the VIN number of a vehicle.
|
(package private) int |
getYear() |
java.lang.String |
toString()
This overrides toString to give a nicely formatted Vehicle
output.
|
static boolean |
validateMake(java.lang.String make)
This method validates the manufacturer, by ensuring that the
make parameter is a non-empty string.
|
static boolean |
validateModel(java.lang.String model)
This method validates the model by ensuring that it's not an empty string.
|
static boolean |
validatePrice(double price)
This validation function only checks for a price that is
non-negative.
|
static boolean |
validateVin(java.lang.String vin)
This method validates the VIN, by checking that the length of the VIN
is between 1 and 17 inclusive.
|
static boolean |
validateYear(int year)
The validation function for the year checks to make sure the year
is at least 1886 (The car was invented in 1886) and at most one year in
the future (since car dealerships sell next year's models this year).
|
Vehicle(java.lang.String vin, java.lang.String make, java.lang.String model, double price, int mileage, int year)
vin
- The VIN of the new vehiclemake
- The manufacturer of the new vehiclemodel
- The model of the new vehicleprice
- The price of the new vehiclemileage
- The mileage of the new vehicleyear
- The year of the new vehiclepublic static boolean validateVin(java.lang.String vin)
vin
- A string representing the VIN number of the vehiclepublic static boolean validateMake(java.lang.String make)
make
- The manufacturer to be validatedpublic static boolean validateModel(java.lang.String model)
model
- The model to be validatedpublic static boolean validateYear(int year)
year
- The year to be validatedpublic static boolean validatePrice(double price)
price
- The price to be validatedpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getVin()
java.lang.String getMake()
java.lang.String getModel()
public double getPrice()
int getYear()