Package pkg.exoad.swiggie
Class SwSize
java.lang.Object
pkg.exoad.swiggie.SwSize
- All Implemented Interfaces:
SwSwappable
A class that represents a size constraint
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSwSize(int width, int height) Constructs a SwSize object with the given width and height -
Method Summary
Modifier and TypeMethodDescriptionstatic SwSizeacquire(int width, int height) static SwSizeacquireFromHeight(int height) Acquires a SwSize object with the given heightstatic SwSizeacquireFromWidth(int width) Acquires a SwSize object with the given widthintarea()Calculates the area of the sizefloatdiagonal()Calculates the diagonal of the size as in a right trianglevoidswap()Swaps the width and heightstatic SwSizewithHeight(int height) Cascades the heightstatic SwSizewithWidth(int width) Cascades the width
-
Field Details
-
width
private int width -
height
private int height
-
-
Constructor Details
-
SwSize
private SwSize(int width, int height) Constructs a SwSize object with the given width and height- Parameters:
width- The width of the sizeheight- The height of the size
-
-
Method Details
-
acquire
-
acquireFromWidth
Acquires a SwSize object with the given width- Parameters:
width- The width of the size- Returns:
- A SwSize object with the given width
-
acquireFromHeight
Acquires a SwSize object with the given height- Parameters:
height- The height of the size- Returns:
- A SwSize object with the given height
-
area
public int area()Calculates the area of the size- Returns:
- The area of the size
-
diagonal
public float diagonal()Calculates the diagonal of the size as in a right triangle- Returns:
- The diagonal of the size
-
withWidth
Cascades the width- Parameters:
width- The width to cascade- Returns:
- The SwSize object
-
withHeight
Cascades the height- Parameters:
height- The height to cascade- Returns:
- The SwSize object
-
swap
public void swap()Swaps the width and height- Specified by:
swapin interfaceSwSwappable
-