Skip to content
Snippets Groups Projects
Vertex.java 1.18 KiB
Newer Older
  • Learn to ignore specific revisions
  • istkabra's avatar
    istkabra committed
    package MainClasses;
    
    
    istkabra's avatar
    istkabra committed
    // Helper class representing a single amino acid
    
    istkabra's avatar
    istkabra committed
    public class Vertex {
        public int x;
        public int y;
        public int outgoingDirection;
    
        public boolean isStretched; // Meaning it has room for connections
    
    istkabra's avatar
    istkabra committed
    
    
        public Vertex(int x, int y, int outgoingDirection) {
    
    istkabra's avatar
    istkabra committed
            this.x = x;
            this.y = y;
            this.outgoingDirection = outgoingDirection;
    
    istkabra's avatar
    istkabra committed
        }
    
        public boolean equalsPosition(Vertex vertex) {
            return x == vertex.x && y == vertex.y;
        }
    
        public boolean neighbouringPosition(Vertex vertex) {
    
            int neighbourDistance = 1;
            if (isStretched) {
                neighbourDistance *= 2;
            }
    
            if (x == vertex.x && y == vertex.y + neighbourDistance) {
    
    istkabra's avatar
    istkabra committed
                return true; // South
            }
    
            else if (x == vertex.x && y == vertex.y -neighbourDistance) {
    
    istkabra's avatar
    istkabra committed
                return true; // North
            }
    
            else if (x == vertex.x + neighbourDistance && y == vertex.y) {
    
    istkabra's avatar
    istkabra committed
                return true; // West
            }
    
            else if (x == vertex.x - neighbourDistance && y == vertex.y) {
    
    istkabra's avatar
    istkabra committed
                return true; // East
            }
            else {
                return false;
            }
        }
    }