Class RadicalNumber

java.lang.Object
com.aidano7.bison.algebra.RadicalNumber

public class RadicalNumber
extends java.lang.Object
Since:
3/26/2021

This class is for the implementation of a radical number. A radical number has two part, the coefficient and the radicand.

Author:
aidano-7
  • Constructor Summary

    Constructors
    Constructor Description
    RadicalNumber​(float coefficient, int radicand)
    Creates an instance of a radical number with a defined coefficient and radicand.
  • Method Summary

    Modifier and Type Method Description
    void add​(RadicalNumber radicalNumber)
    Adds this and radicalNumber using the static method.
    static RadicalNumber add​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
    Adds the two numbers if both radicands are equal.
    float approximate()
    Returns the approximate value of this.
    boolean equals​(RadicalNumber radicalNumber)
    Checks if radicalNumber is equal to this.
    float getCoefficient()
    Returns the coefficient.
    int getRadicand()
    Returns the radicand.
    void multiply​(RadicalNumber radicalNumber)
    Multiplies this and radicalNumber using the static method.
    static RadicalNumber multiply​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
    Multiplies the two numbers.
    void setCoefficient​(float coefficient)
    Sets the coefficient.
    void setRadicand​(int radicand)
    Sets the radicand.
    void subtract​(RadicalNumber radicalNumber)
    Subtracts this and radicalNumber using the static method.
    static RadicalNumber subtract​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
    Subtracts the two numbers if both radicands are equal.
    java.lang.String toString()
    Radical numbers are written as a√b.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RadicalNumber

      public RadicalNumber​(float coefficient, int radicand)
      Creates an instance of a radical number with a defined coefficient and radicand.
      Parameters:
      coefficient - the coefficient of the radical number
      radicand - the radicand of the radical number
  • Method Details

    • add

      public static RadicalNumber add​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
      Adds the two numbers if both radicands are equal.
      Parameters:
      radicalNumberA - first number to add
      radicalNumberB - second number to add
      Returns:
      radicalNumberC sum of radicalNumberA and radicalNumberB
    • subtract

      public static RadicalNumber subtract​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
      Subtracts the two numbers if both radicands are equal.
      Parameters:
      radicalNumberA - first number to subtract
      radicalNumberB - second number to subtract
      Returns:
      radicalNumberC difference of radicalNumberA and radicalNumberB
    • multiply

      public static RadicalNumber multiply​(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)
      Multiplies the two numbers.
      Parameters:
      radicalNumberA - the first number to multiply
      radicalNumberB - the second number to multiply
      Returns:
      radicalNumberC the product of radicalNumberA and radicalNumberB
    • getCoefficient

      public float getCoefficient()
      Returns the coefficient.
      Returns:
      coefficient the coefficient of the radical number
    • setCoefficient

      public void setCoefficient​(float coefficient)
      Sets the coefficient.
      Parameters:
      coefficient - the coefficient of the radical number
    • getRadicand

      public int getRadicand()
      Returns the radicand.
      Returns:
      radicand the radicand of the radical number
    • setRadicand

      public void setRadicand​(int radicand)
      Sets the radicand.
      Parameters:
      radicand - the radicand of the radical number
    • toString

      public java.lang.String toString()
      Radical numbers are written as a√b.
      Overrides:
      toString in class java.lang.Object
      Returns:
      string the standard form of the radical number
    • add

      public void add​(RadicalNumber radicalNumber)
      Adds this and radicalNumber using the static method.
      Parameters:
      radicalNumber - the number to add
    • subtract

      public void subtract​(RadicalNumber radicalNumber)
      Subtracts this and radicalNumber using the static method.
      Parameters:
      radicalNumber - the number to subtract
    • multiply

      public void multiply​(RadicalNumber radicalNumber)
      Multiplies this and radicalNumber using the static method.
      Parameters:
      radicalNumber - the number to multiply
    • equals

      public boolean equals​(RadicalNumber radicalNumber)
      Checks if radicalNumber is equal to this.
      Parameters:
      radicalNumber - the number to check equality against this
      Returns:
      boolean true if radicalNumber === this
    • approximate

      public float approximate()
      Returns the approximate value of this.
      Returns:
      float approximate value of this