title: Location class that keeps track of x and y
body: <p>Im doing an excercise for school where I need to write a program that keeps track of the x, y position of say a figure within a grid. </p>
  
  <ul>
  <li>up() moves figure up.</li>
  <li>down() moves figure down.</li>
  <li>left() moves figure left.</li>
  <li>right() moves figure right.</li>
  </ul>
  
  <p>This is what I have so far and the problem is that i just get 0,0 when running the program.</p>
  
  <p>Im not that good at programming, so sorry if its really bad.</p>
  
  <pre><code>package øving_1;
  
  public class Location {
  
  
      private int xAkse;
      private int yAkse;
  
  
      public Location(){
          xAkse = 0;
          yAkse = 0;      
      }
  
      public void right(int i){
          xAkse++;
      }
  
      private void left(int i){
          xAkse--;
  
      }
  
      private void up(int i){
          yAkse--;
  
      }
  
      private void down(int i){
          yAkse++;
      }
      public int getPosition(){
          return xAkse;
      }
      public int getPosition2(){
          return yAkse;
      }
  
  
      public static void main(String[] args) {
  
          Location location = new Location();
          location.right(0);
          location.left(0);
          location.up(0);
          location.down(0);
  
          System.out.print("Posisjonen til x, y er: ");
          System.out.print(location.getPosition() + ", " + location.getPosition2());
  
  
      }
  
  }
  </code></pre>