javacli
Class Rectangle

java.lang.Object
  extended by javacli.Rectangle

public class Rectangle
extends java.lang.Object

Class representing R2-rectangle


Field Summary
 int x0
           
 int x1
           
 int y0
           
 int y1
           
 
Constructor Summary
Rectangle()
          Create rectangle with all zero coordinates
Rectangle(int x0, int y0, int x1, int y1)
          Contruct rectangle with specified coordinates
Rectangle(Rectangle r)
          Create copy of the rectangle
 
Method Summary
 int area()
          Rectangle area
 boolean contains(Rectangle r)
          Checks whether this rectangle contains specified r rectangle
static int distance(Rectangle r, Rectangle q)
          Distance between two rectangles
 boolean equals(java.lang.Object obj)
          Checks whether two rectangles are the same
 int hashCode()
          Hash code method for references
 void join(Rectangle r)
          Calculate cover of two rectangles This rectangle is changesd to be the minimal rectangle containing original rectangle and specified rectangles
static Rectangle join(Rectangle p, Rectangle q)
          Calculate cover of two rectangles
 boolean overlaps(Rectangle r)
          Check whether two rectngles overlaps
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x0

public int x0

y0

public int y0

x1

public int x1

y1

public int y1
Constructor Detail

Rectangle

public Rectangle(int x0,
                 int y0,
                 int x1,
                 int y1)
Contruct rectangle with specified coordinates


Rectangle

public Rectangle(Rectangle r)
Create copy of the rectangle


Rectangle

public Rectangle()
Create rectangle with all zero coordinates

Method Detail

hashCode

public int hashCode()
Hash code method for references

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

distance

public static int distance(Rectangle r,
                           Rectangle q)
Distance between two rectangles

Parameters:
r - first rectangle
q - second rectangle
Returns:
distance between two rectangles

area

public int area()
Rectangle area


join

public static Rectangle join(Rectangle p,
                             Rectangle q)
Calculate cover of two rectangles

Parameters:
p - first rectangle
q - second rectangle
Returns:
minimal rectangle containing both specified rectangles

join

public void join(Rectangle r)
Calculate cover of two rectangles This rectangle is changesd to be the minimal rectangle containing original rectangle and specified rectangles

Parameters:
r - another rectangle

equals

public boolean equals(java.lang.Object obj)
Checks whether two rectangles are the same

Overrides:
equals in class java.lang.Object

overlaps

public boolean overlaps(Rectangle r)
Check whether two rectngles overlaps


contains

public boolean contains(Rectangle r)
Checks whether this rectangle contains specified r rectangle