package abstractFactory;
public abstract class Car {
public final static int LEFT = 0; // side
public final static int RIGHT = 1; // side
public final static int FRONT = 2; // position
public final static int BACK = 3; // position
public final static int RED = 0;
public final static int BLUE = 1;
public final static int WHITE = 2;
public final static int METALLIC = 3;
private int doorNum;
private int wheelNum;
private int seatNum;
private int maxSpeed;
private int engine = -1;
private int color;
public Car
(String number,
int doorNum,
int wheelNum,
int seetNum,
int maxSpeed
) { super();
this.number = number;
this.doorNum = doorNum;
this.wheelNum = wheelNum;
this.seatNum = seetNum;
this.maxSpeed = maxSpeed;
this.color = Car.WHITE;
}
public int getDoorNum() {
return doorNum;
}
public void setDoorNum(int doorNum) {
this.doorNum = doorNum;
}
public int getMaxSpeed() {
return maxSpeed;
}
public void setMaxSpeed(int maxSpeed) {
this.maxSpeed = maxSpeed;
}
public int getSeatNum() {
return seatNum;
}
public void setSeatNum(int seetNum) {
this.seatNum = seetNum;
}
public int getWheelNum() {
return wheelNum;
}
public void setWheelNum(int wheelNum) {
this.wheelNum = wheelNum;
}
return number;
}
public void setNumber
(String number
) { this.number = number;
}
// equals/hashCode/toString >>
res += getClass().getName() + "@" + hashCode() + " : ";
res += "number=" + number + ", ";
res += "doorNum=" + doorNum + ", ";
res += "wheelNum=" + wheelNum + ", ";
res += "seatNum=" + seatNum + ", ";
res += "maxSpeed=" + maxSpeed + ", ";
res += "enginePosition=" + engine + ", ";
res += "color=" + color + "";
return res;
}
public int hashCode() {
int result = 17;
result = 37 * result + number.hashCode();
result = 37 * result + doorNum;
result = 37 * result + wheelNum;
result = 37 * result + maxSpeed;
result = 37 * result + seatNum;
result = 37 * result + engine;
result = 37 * result + color;
return result;
}
public boolean equals
(Object o
) { if (!(o instanceof Car)) return false;
Car other = (Car) o;
return (other.number == number &&
other.doorNum == doorNum &&
other.maxSpeed == maxSpeed &&
other.seatNum == seatNum &&
other.wheelNum == wheelNum &&
other.engine == engine &&
other.color == color);
}
public void InstallEngine(int position) {
if (position < 0) return;
engine = position;
}
public void setColor(int color) {
this.color = color;
}
try {
return super.clone();
throw new Error(getClass
().
getName() +
" clone error!");
}
}
}