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
-
Constructor Summary
ModifierConstructorDescriptionprivate
SwSize
(int width, int height) Constructs a SwSize object with the given width and height -
Method Summary
Modifier and TypeMethodDescriptionstatic SwSize
acquire
(int width, int height) static SwSize
acquireFromHeight
(int height) Acquires a SwSize object with the given heightstatic SwSize
acquireFromWidth
(int width) Acquires a SwSize object with the given widthint
area()
Calculates the area of the sizefloat
diagonal()
Calculates the diagonal of the size as in a right trianglevoid
swap()
Swaps the width and heightstatic SwSize
withHeight
(int height) Cascades the heightstatic SwSize
withWidth
(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:
swap
in interfaceSwSwappable
-