Skip to content
Snippets Groups Projects
Coordinate.java 2.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • Guyslain's avatar
    Guyslain committed
    package datastruct;
    
    import java.util.ArrayList;
    import java.util.List;
    
    
    /**
     * Represents a 2D integer coordinate used to specify positions in a grid.
     */
    
    Guyslain's avatar
    Guyslain committed
    public record Coordinate(int x, int y) {
    
    
        /**
         * Creates a new {@link Coordinate} instance with the given {@code x} and {@code y} values.
         *
         * @param x The x-coordinate value.
         * @param y The y-coordinate value.
         * @return A new {@link Coordinate} instance.
         */
    
    Guyslain's avatar
    Guyslain committed
        public static Coordinate of(int x, int y) {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: compléter ce fabriquant
            return null;
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns the {@link Coordinate} to the left of this one.
         *
         * @return The left adjacent {@link Coordinate}.
         */
    
    Guyslain's avatar
    Guyslain committed
        public Coordinate left() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return null;
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns the {@link Coordinate} to the right of this one.
         *
         * @return The right adjacent {@link Coordinate}.
         */
    
    Guyslain's avatar
    Guyslain committed
        public Coordinate right() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return null;
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns the {@link Coordinate} above this one.
         *
         * @return The above adjacent {@link Coordinate}.
         */
    
    Guyslain's avatar
    Guyslain committed
        public Coordinate above() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return null;
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns the {@link Coordinate} below this one.
         *
         * @return The below adjacent {@link Coordinate}.
         */
    
    Guyslain's avatar
    Guyslain committed
        public Coordinate below() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return null;
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns a list of orthogonal (adjacent in horizontal or vertical direction) neighbors.
         *
         * @return A list of orthogonal neighboring {@link Coordinate}s.
         */
    
    Guyslain's avatar
    Guyslain committed
        public List<Coordinate> orthogonalNeighbours() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return List.of();
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns a list of diagonal (adjacent in diagonal direction) neighbors.
         *
         * @return A list of diagonal neighboring {@link Coordinate}s.
         */
    
    Guyslain's avatar
    Guyslain committed
        public List<Coordinate> diagonalNeighbours() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return List.of();
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        /**
         * Computes and returns a list of all orthogonal and diagonal neighbors.
         *
         * @return A list of all neighboring {@link Coordinate}s.
         */
    
    Guyslain's avatar
    Guyslain committed
        public List<Coordinate> orthodiagonalNeighbours() {
    
    Guyslain's avatar
    Guyslain committed
            // TODO: à compléter
            return List.of();
    
    Guyslain's avatar
    Guyslain committed
        }
    
    
        @Override
        public String toString() {
            return "(" + this.x + "," + this.y + ")";
        }
    }