mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2026-10-06 05:22:13 +02:00
added contents
This commit is contained in:
47
Projekte/common/src/main/java/pp/util/FloatPoint.java
Normal file
47
Projekte/common/src/main/java/pp/util/FloatPoint.java
Normal file
@@ -0,0 +1,47 @@
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.util;
|
||||
|
||||
/**
|
||||
* A trivial implementation of points in the plane with float coordinates.
|
||||
*
|
||||
* @param x x-coordinate
|
||||
* @param y y-coordinate
|
||||
*/
|
||||
public record FloatPoint(float x, float y) implements Position {
|
||||
public static final FloatPoint ZERO = new FloatPoint(0f, 0f);
|
||||
|
||||
/**
|
||||
* Create a new FloatPoint object for the given position.
|
||||
*
|
||||
* @param p a position
|
||||
*/
|
||||
public FloatPoint(Position p) {
|
||||
this(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate.
|
||||
*/
|
||||
@Override
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate.
|
||||
*/
|
||||
@Override
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public static Position p(float x, float y) {
|
||||
return new FloatPoint(x, y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user