Created
October 5, 2012 13:21
-
-
Save tgk/3839774 to your computer and use it in GitHub Desktop.
Boilerplate example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class Car { | |
private int maxSpeed; | |
private Wheel[] wheels; | |
public Car(int maxSpeed, Wheel[] wheels) { | |
this.maxSpeed = maxSpeed; | |
this.wheels = wheels; | |
} | |
public int getMaxSpeed() { | |
return maxSpeed; | |
} | |
public void setMaxSpeed(int maxSpeed) { | |
this.maxSpeed = maxSpeed; | |
} | |
public Wheel[] getWheels() { | |
return wheels; | |
} | |
public void setWheels(Wheel[] wheels) { | |
this.wheels = wheels; | |
} | |
@Override | |
public int hashCode() { | |
final int prime = 31; | |
int result = 1; | |
result = prime * result + maxSpeed; | |
result = prime * result + Arrays.hashCode(wheels); | |
return result; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (this == obj) | |
return true; | |
if (obj == null) | |
return false; | |
if (getClass() != obj.getClass()) | |
return false; | |
Car other = (Car) obj; | |
if (maxSpeed != other.maxSpeed) | |
return false; | |
if (!Arrays.equals(wheels, other.wheels)) | |
return false; | |
return true; | |
} | |
@Override | |
public String toString() { | |
return "Car [maxSpeed=" + maxSpeed + ", wheels=" | |
+ Arrays.toString(wheels) + "]"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment