MoveTester.java.html

  1  import java.awt.Rectangle; 
  2  
  3  public class MoveTester
  4  {
  5     public static void main(String[] args)
  6     {
  7        Rectangle box = new Rectangle(5, 10, 20, 30);
  8  
  9        // Move the rectangle
 10        box.translate(15, 25);
 11  
 12        // Print information about the moved rectangle 
 13        System.out.print("x: "); 
 14        System.out.println(box.getX());
 15        System.out.println("Expected: 20"); 
 16  
 17        System.out.print("y: "); 
 18        System.out.println(box.getY());
 19        System.out.println("Expected: 35");   
 20     }
 21  }