package abstractFactory.americanFleet;
import abstractFactory.Car;
import abstractFactory.Truck;
public class GeneralMotorsTruck
extends Truck
implements Cloneable { private boolean diesel;
public GeneralMotorsTruck
(String number,
int wheelNum, boolean trailer, boolean diesel) {
super(number, 2, wheelNum, 3, 160, 15000, trailer);
this.diesel = diesel;
}
public boolean isDiesel() {
return diesel;
}
//equals/hashCode/toString >>
public boolean equals
(Object o
) { if (!(o instanceof Car)) {
return false;
}
if (!(o instanceof GeneralMotorsTruck)) {
return o.equals(this);
}
GeneralMotorsTruck other = (GeneralMotorsTruck) o;
return (super.equals(o) &&
other.diesel == diesel);
}
public int hashCode() {
int res = super.hashCode();
res = res * 37 + (diesel ? 1 : 0);
return res;
}
String res =
super.
toString();
res += ", diesel=" + diesel;
return res;
}
}