public class RectangularArea
extends java.lang.Object
invariant: topLeftPosition() != null && bottomRightPosition() != null
invariant: topLeftPosition().line() <= bottomRightPosition().line()
invariant: topLeftPosition().column() <= bottomRightPosition().column()
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor and Description |
---|
RectangularArea(Position topLeftPosition,
Position bottomRightPosition)
Constructs a new RectangularArea in GBoard (topLeftPosition x bottomRightPosition).
|
Modifier and Type | Method and Description |
---|---|
Position |
bottomRightPosition()
Bottom right position of area.
|
boolean |
isInside(int line,
int column)
Is position inside area?
|
boolean |
isInside(Position pos)
Is position inside area?
|
Position |
topLeftPosition()
Top left position of area.
|
java.lang.String |
toString() |
public RectangularArea(Position topLeftPosition, Position bottomRightPosition)
requires: topLeftPosition != null && bottomRightPosition != null
requires: topLeftPosition.line() <= bottomRightPosition.line()
requires: topLeftPosition.column() <= bottomRightPosition.column()
topLeftPosition
- top left position of areabottomRightPosition
- bottom right position of areapublic Position topLeftPosition()
Position
positionpublic Position bottomRightPosition()
Position
positionpublic boolean isInside(Position pos)
requires: pos != null
pos
- the position to checkboolean
true if insidepublic boolean isInside(int line, int column)
requires: line >= 0 && column >= 0
line
- line positioncolumn
- column positionboolean
true if insidepublic java.lang.String toString()
toString
in class java.lang.Object