title: How do I print original point coordinates if I translate a point outside of a certain square?
body: <p>I'm trying to print the coordinates of a translated point. If the point is translated outside of the 10, -10 range on both the x and y axes, then the original point should be returned and not the translated one. So, for p1 (5,4), if I were to translate it by (7,8), it should return (5,4). I'm having trouble figuring out how exactly to tell Java to print the original point in this case. Do I need to include a Boolean of some sort? Here's what I have so far. (The code is written in German, but "verschiebe" means translate.) Any help would be greatly appreciated! Thanks y'all in advance :)</p>
  
  <pre><code>public class Punkt2 {
  private int x;
  private int y;
  
  public void setX (int i) {
      x = i;
  }
  public void setY (int i) {
      y = i;
  }
  public void verschiebe(int deltaX, int deltaY){
      x = x + deltaX;
      y = y + deltaY;
  }
  
  public int getX(){
      return x;
  }
  
  public int getY(){
      return y;
  }
  
  
  public static void main (String[] args){
      Punkt p1 = new Punkt();
      p1.setX(5); p1.setY(4);
      Punkt p2 = new Punkt();
      p2.setX(2);p2.setY(1);
  
      p1.verschiebe(7,8);
      if (p1.getX() &gt; 10 || p1.getY() &gt; 10 || p1.getX() &lt; -10 || p1.getY() &lt; -10){
          System.out.println(new Punkt());
      }
      else {
          System.out.println(p1.getX() + "," + p1.getY());
      }
      p2.verschiebe(3, 2);
      if (p2.getX() &gt; 10 || p2.getY() &gt; 10 || p2.getX() &lt; -10 || p2.getY() &lt; -10){
          System.out.println(new Punkt());
      }
      else {
          System.out.println(p2.getX() + "," + p2.getY());
      }
  }
  }
  </code></pre>