public class Square
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private LineSegment |
ls1
A square is defined by two line segments that have a common end-point.
|
private LineSegment |
ls2
A square is defined by two line segments that have a common end-point.
|
| Constructor and Description |
|---|
Square(LineSegment ls1,
LineSegment ls2)
A constructor for the Square object.
|
| Modifier and Type | Method and Description |
|---|---|
double |
area()
Method to compute the area of 'this' Square
|
boolean |
equals(java.lang.Object obj)
Method to compare 'this' Square segment for equality with the 'object' specified
as a parameter.
|
LineSegment |
getLs1()
Getter for LineSegment 1
|
LineSegment |
getLs2()
Getter for LineSegment 2
|
double |
perimeter()
Method to compute the perimeter of 'this' Square
|
java.lang.String |
toString()
Method to render 'this' instance of the Square class into a String.
|
private LineSegment ls1
private LineSegment ls2
public Square(LineSegment ls1, LineSegment ls2) throws LineSegmentsNotPerpendicularException, LineSegmentsNotAdjacentException, LineSegmentsUnequalException
ls1 - The first LineSegment defining the squarels2 - The second LineSegment defining the squareLineSegmentsNotPerpendicularException - This exception is thrown if the
two LineSegments are not perpendicular to each otherLineSegmentsNotAdjacentException - This exception is thrown if the
LineSegments do not share a common end-point.LineSegmentsUnequalException - This exception is thrown if the LineSegments
are not of equal length.public double area()
public double perimeter()
public LineSegment getLs1()
public LineSegment getLs2()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - An Object to be tested for equality with 'this' Squarepublic java.lang.String toString()
toString in class java.lang.Object