Package com.aidano7.bison.algebra
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 voidadd(RadicalNumber radicalNumber)Adds this and radicalNumber using the static method.static RadicalNumberadd(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)Adds the two numbers if both radicands are equal.floatapproximate()Returns the approximate value of this.booleanequals(RadicalNumber radicalNumber)Checks if radicalNumber is equal to this.floatgetCoefficient()Returns the coefficient.intgetRadicand()Returns the radicand.voidmultiply(RadicalNumber radicalNumber)Multiplies this and radicalNumber using the static method.static RadicalNumbermultiply(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)Multiplies the two numbers.voidsetCoefficient(float coefficient)Sets the coefficient.voidsetRadicand(int radicand)Sets the radicand.voidsubtract(RadicalNumber radicalNumber)Subtracts this and radicalNumber using the static method.static RadicalNumbersubtract(RadicalNumber radicalNumberA, RadicalNumber radicalNumberB)Subtracts the two numbers if both radicands are equal.java.lang.StringtoString()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 numberradicand- the radicand of the radical number
-
-
Method Details
-
add
Adds the two numbers if both radicands are equal.- Parameters:
radicalNumberA- first number to addradicalNumberB- second number to add- Returns:
- radicalNumberC sum of radicalNumberA and radicalNumberB
-
subtract
Subtracts the two numbers if both radicands are equal.- Parameters:
radicalNumberA- first number to subtractradicalNumberB- second number to subtract- Returns:
- radicalNumberC difference of radicalNumberA and radicalNumberB
-
multiply
Multiplies the two numbers.- Parameters:
radicalNumberA- the first number to multiplyradicalNumberB- 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:
toStringin classjava.lang.Object- Returns:
- string the standard form of the radical number
-
add
Adds this and radicalNumber using the static method.- Parameters:
radicalNumber- the number to add
-
subtract
Subtracts this and radicalNumber using the static method.- Parameters:
radicalNumber- the number to subtract
-
multiply
Multiplies this and radicalNumber using the static method.- Parameters:
radicalNumber- the number to multiply
-
equals
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
-