begin of worm class
This commit is contained in:
@@ -1,4 +1,58 @@
|
|||||||
|
|
||||||
public class Worm {
|
public class Worm {
|
||||||
|
|
||||||
|
// Location
|
||||||
|
private double coordX;
|
||||||
|
private double coordY;
|
||||||
|
|
||||||
|
// Orientation
|
||||||
|
private double orientation;
|
||||||
|
|
||||||
|
// shape
|
||||||
|
private double radius;
|
||||||
|
private double minRadius;
|
||||||
|
// mass
|
||||||
|
private double mass;
|
||||||
|
|
||||||
|
// points
|
||||||
|
private double points;
|
||||||
|
|
||||||
|
// name
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public Worm(double coordX, double coordY, double orientation, String name, double radius) throws IllegalArgumentException {
|
||||||
|
|
||||||
|
this.coordX = coordX;
|
||||||
|
this.coordY = coordY;
|
||||||
|
this.orientation = orientation;
|
||||||
|
this.radius = radius;
|
||||||
|
this.minRadius = 0.25;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Worm(double coordX, double coordY, double orientation, String name, double radius, double minRadius) throws IllegalArgumentException {
|
||||||
|
this.coordX = coordX;
|
||||||
|
this.coordY = coordY;
|
||||||
|
this.orientation = orientation;
|
||||||
|
this.radius = radius;
|
||||||
|
this.minRadius = minRadius;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidName (String name) {
|
||||||
|
|
||||||
|
if (name.length() < 2 || !Character.isUpperCase(name.charAt(0))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//char allowedCharacters[] = {'\'', '"', ' '};
|
||||||
|
Set<Character> allowedCharacters[] = new
|
||||||
|
for (int i = 0; i < name.length(); i++) {
|
||||||
|
if (!Character.isLetter(name.charAt(i))) {
|
||||||
|
if (!allowedCharacters.contains() name.charAt(i))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user