Class SwSize

java.lang.Object
pkg.exoad.swiggie.SwSize
All Implemented Interfaces:
SwSwappable

public class SwSize extends Object implements SwSwappable
A class that represents a size constraint
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    SwSize(int width, int height)
    Constructs a SwSize object with the given width and height
  • Method Summary

    Modifier and Type
    Method
    Description
    static SwSize
    acquire(int width, int height)
     
    static SwSize
    acquireFromHeight(int height)
    Acquires a SwSize object with the given height
    static SwSize
    acquireFromWidth(int width)
    Acquires a SwSize object with the given width
    int
    Calculates the area of the size
    float
    Calculates the diagonal of the size as in a right triangle
    void
    Swaps the width and height
    static SwSize
    withHeight(int height)
    Cascades the height
    static SwSize
    withWidth(int width)
    Cascades the width

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 size
      height - The height of the size
  • Method Details

    • acquire

      public static SwSize acquire(int width, int height)
    • acquireFromWidth

      public static SwSize acquireFromWidth(int width)
      Acquires a SwSize object with the given width
      Parameters:
      width - The width of the size
      Returns:
      A SwSize object with the given width
    • acquireFromHeight

      public static SwSize acquireFromHeight(int height)
      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

      public static SwSize withWidth(int width)
      Cascades the width
      Parameters:
      width - The width to cascade
      Returns:
      The SwSize object
    • withHeight

      public static SwSize withHeight(int height)
      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 interface SwSwappable