package com.google.research.bleth.simulator;

import java.util.Objects;

/** A location on board. */
public class Location {
    public final int row;
    public final int col;

    public Location(int row, int col) {
        this.row = row;
        this.col = col;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Location location = (Location) o;
        return row == location.row && col == location.col;
    }

    @Override
    public int hashCode() {
        return Objects.hash(row, col);
    }

    /**
     * Calculate and return the new location based on the current location and the given direction.
     * @param direction is the direction to move to it, one of the four directions: up, down, right and left.
     * @return new Location, differ from the original location in one step, according the given direction.
     */
    public Location moveInDirection(Direction direction) {
        return new Location(row + direction.getRowDelta(), col + direction.getColDelta());
    }
}

@@ -50,25 +50,39 @@
 ort 
-java.util.Objects
+com.google.auto.value.AutoValue
 ;%0A%0A/
@@ -108,22 +108,42 @@
 ard. */%0A
-public
+@AutoValue%0Apublic abstract
  class L
@@ -167,58 +167,12 @@
 lic 
-final int row;%0A    public final int col;%0A%0A    publ
+stat
 ic L
@@ -178,16 +178,23 @@
 Location
+ create
 (int row
@@ -218,452 +218,117 @@
     
-this.row = row;%0A        this.col = col;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) %7B%0A            return true;%0A        %7D%0A        if (o == null %7C%7C getClass() != o.getClass()) %7B%0A            return false;%0A        %7D%0A        Location location = (Location) o;%0A        return row == location.row && col == location.col;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hash(row,
+return new AutoValue_Location(row, col);%0A    %7D%0A%0A    public abstract int row();%0A    public abstract int
  col
+(
 );
-%0A    %7D
 %0A%0A  
@@ -732,28 +732,24 @@
  return 
-new 
 Location
 (row + d
@@ -740,20 +740,29 @@
 Location
+.create
 (row
+()
  + direc
@@ -784,16 +784,18 @@
 a(), col
+()
  + direc
@@ -822,9 +822,8 @@
 %0A    %7D%0A%7D
-%0A

Change Location to an autoValue class.