School Commit Init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package Model;
|
||||
|
||||
public class Bicycle implements IVehicle {
|
||||
|
||||
private String _brand;
|
||||
private String _color;
|
||||
|
||||
public Bicycle(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 "Bicycle{" +
|
||||
"brand='" + _brand + '\'' +
|
||||
", color='" + _color + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package Model;
|
||||
|
||||
public interface IVehicle {
|
||||
String getBrand();
|
||||
void setBrand(String brand) throws IllegalArgumentException;
|
||||
String getColor();
|
||||
void setColor(String color) throws IllegalArgumentException;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user