Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66

This commit is contained in:
Niels Gras
2024-06-03 15:32:34 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ public class ExerciseManager {
private static final String PROPERTY_NAME = "name"; private static final String PROPERTY_NAME = "name";
// The delimiter used to separate the paths of the sensors. // The delimiter used to separate the paths of the sensors.
public static final String PATH_DELIMITER = ";"; public static final String PATH_DELIMITER = ":";
public static final int SENSOR_COUNT = 2; public static final int SENSOR_COUNT = 2;
@@ -96,6 +96,7 @@ public class ExerciseManager {
// Ensure all required properties are present // Ensure all required properties are present
for (String property : REQUIRED_PROPERTIES) { for (String property : REQUIRED_PROPERTIES) {
if (!content.has(property)) { if (!content.has(property)) {
System.out.println("Missing property: " + property);
return null; return null;
} }
} }
@@ -103,10 +104,13 @@ public class ExerciseManager {
// Path data is split into two parts, due to the left and right hand. // Path data is split into two parts, due to the left and right hand.
// If one wants to add support for more sensors, one will have to adjust the Exercise // If one wants to add support for more sensors, one will have to adjust the Exercise
// class to support more paths. // class to support more paths.
System.out.println(content.get(PROPERTY_PATH).getAsString());
String[] leftRightData = content.get(PROPERTY_PATH).getAsString().split(PATH_DELIMITER); String[] leftRightData = content.get(PROPERTY_PATH).getAsString().split(PATH_DELIMITER);
if (leftRightData.length != SENSOR_COUNT) if (leftRightData.length != SENSOR_COUNT) {
System.out.println("Invalid path data.");
return null; return null;
}
return new Exercise( return new Exercise(
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsString()), EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsString()),

View File

@@ -13,8 +13,10 @@ public class GesturePath {
* @param vectors The vectors that make up the path. * @param vectors The vectors that make up the path.
*/ */
public GesturePath(Vector3f[] vectors) { public GesturePath(Vector3f[] vectors) {
if (vectors.length < 2) if (vectors.length < 2) {
throw new IllegalArgumentException("A path must have at least two points."); this.segments = new PathSegment[0];
return;
}
this.segments = new PathSegment[vectors.length - 1]; this.segments = new PathSegment[vectors.length - 1];
for (int i = 0; i < vectors.length - 1; i++) for (int i = 0; i < vectors.length - 1; i++)
@@ -98,7 +100,7 @@ public class GesturePath {
// Check if the input string contains a valid amount of bytes (12 bytes per vector) // Check if the input string contains a valid amount of bytes (12 bytes per vector)
if (input.length() % 12 != 0) { if (input.length() % 12 != 0) {
throw new IllegalArgumentException("Invalid input string length"); throw new IllegalArgumentException("Invalid input string length (" + input.length() + " bytes provided - must be a multiple of 12)");
} }
Vector3f[] vectors = new Vector3f[input.length() / 12]; Vector3f[] vectors = new Vector3f[input.length() / 12];