44 lines
1.0 KiB
Java
44 lines
1.0 KiB
Java
package Model;
|
|
|
|
public class Car implements IVehicle {
|
|
|
|
private String _brand;
|
|
private String _color;
|
|
|
|
public Car(String brand, String color) {
|
|
this._brand = brand;
|
|
this._color = color;
|
|
}
|
|
|
|
public String getBrand() {
|
|
return this._brand;
|
|
}
|
|
|
|
public void setBrand(String brand) throws IllegalArgumentException {
|
|
if (brand == null || brand.length() < 3) {
|
|
throw new IllegalArgumentException("Brand must be at least 3 characters long");
|
|
}
|
|
this._brand = brand;
|
|
}
|
|
|
|
public String getColor() {
|
|
return this._color;
|
|
}
|
|
|
|
public void setColor(String color) throws IllegalArgumentException {
|
|
if (color == null || color.length() < 3) {
|
|
throw new IllegalArgumentException("Color must be at least 3 characters long");
|
|
}
|
|
this._color = color;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Car{" +
|
|
"brand='" + _brand + '\'' +
|
|
", color='" + _color + '\'' +
|
|
'}';
|
|
}
|
|
|
|
}
|