package abstractFactory;
public abstract class Truck extends Car {
private int maxLoad;
private boolean trailer;
int doorNum, int wheelNum,
int seetNum, int maxSpeed,
int maxLoad, boolean trailer) {
super(number, doorNum, wheelNum, seetNum, maxSpeed);
this.maxLoad = maxLoad;
this.trailer = trailer;
}
public int getMaxLoad() {
return maxLoad;
}
public void setMaxLoad(int maxLoad) {
this.maxLoad = maxLoad;
}
public boolean isTrailer() {
return trailer;
}
public void setTrailer(boolean trailer) {
this.trailer = trailer;
}
// equals/hashCode/toString >>
public boolean equals
(Object o
) { if (!(o instanceof Car)) {
return false;
}
if (!(o instanceof Truck)) {
return o.equals(this);
}
Truck other = (Truck) o;
return (super.equals(o) &&
other.trailer == trailer &&
other.maxLoad == maxLoad);
}
public int hashCode() {
int res = super.hashCode();
res = res * 37 + (trailer ? 1 : 0);
res = res * 37 + maxLoad;
return res;
}
String res =
super.
toString();
res += ", trailer=" + trailer;
res += ", maxLoad=" + maxLoad;
return res;
}
}