Files
School/Anul 2/Semestrul 1/Metode avansate de programare/Lab 2/Model/Motorcycle.java
T
2024-08-31 12:07:21 +03:00

44 lines
1.1 KiB
Java

package Model;
public class Motorcycle implements IVehicle{
private String _brand;
private String _color;
public Motorcycle(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 "Motorcycle{" +
"brand='" + _brand + '\'' +
", color='" + _color + '\'' +
'}';
}
}