76 lines
2.0 KiB
Java
76 lines
2.0 KiB
Java
|
|
|
|
public class HitResponse {
|
|
/**
|
|
* Speichert den typ der HitResponse.
|
|
*/
|
|
private HitResponseType type;
|
|
/**
|
|
* Speicher den Punkt wofür die HitResponse gilt.
|
|
*/
|
|
private Point point;
|
|
|
|
/**
|
|
* Erstellt eine neue HitResponse und setzt den Punkt und typ.
|
|
* @param type der HitResponse.
|
|
* @param point für den die HitResponse gilt.
|
|
* @author Peer Ole Wachtel.
|
|
*/
|
|
public HitResponse(HitResponseType type, Point point) {
|
|
this.type = type;
|
|
this.point = point;
|
|
}
|
|
|
|
/**
|
|
*Erstellt eine neue HitResponse und setzt den Punkt und typ.
|
|
* @param typeIndex der HitResponse.
|
|
* @param point für den die HitResponse gilt.
|
|
* @throws IllegalArgumentException wenn der übergebene int nicht auf ein typ referenziert werden kann.
|
|
* @author Peer Ole Wachtel.
|
|
*/
|
|
public HitResponse (int typeIndex, Point point) {
|
|
if (typeIndex >= 0 && typeIndex < HitResponseType.values().length) {
|
|
this.type = HitResponseType.values()[typeIndex];
|
|
this.point = point;
|
|
} else {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
|
|
public HitResponseType getHitResponse() {
|
|
return this.type;
|
|
}
|
|
|
|
public Point getPoint() {
|
|
return this.point;
|
|
}
|
|
|
|
/**
|
|
* Setter für den type
|
|
* @param type auf den die HitResponse gesetzt werden soll.
|
|
* @author Peer Ole Wachtel
|
|
*/
|
|
public void setType(HitResponseType type) {
|
|
this.type = type;
|
|
}
|
|
|
|
/**
|
|
* Gibt den passenden string nach Netzwerkstandard für eine HitResponse zurück.
|
|
* @return den passenden string nach Netzwerkstandard für eine HitResponse.
|
|
* @author Peer Ole Wachtel.
|
|
*/
|
|
@Override
|
|
public String toString() {
|
|
return this.getPoint().toString() + " " + this.type.ordinal();
|
|
}
|
|
|
|
/**
|
|
* Getter für den typ der HitResponse.
|
|
* @return den typ der HitRespnse.
|
|
* @author Peer Ole Wachtel.
|
|
*/
|
|
public HitResponseType getType() {
|
|
return type;
|
|
}
|
|
}
|