advictoriam

Untitled

Nov 26th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.awt.Rectangle;
  2.  
  3. public class IntersectionTester
  4. {
  5.    public static void main(String[] args)
  6.    {
  7.       Rectangle box1 = new Rectangle(5, 10, 20, 30);
  8.       Rectangle box2 = new Rectangle(10, 15, 20, 30);
  9.      
  10.       box2.translate(5, 15);
  11.      
  12.       Rectangle box = box1.intersection(box2);
  13.       double area = box.getWidth() * box.getHeight();
  14.       System.out.println(area);
  15.       System.out.println("Expected: 100");
  16.    }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment