## Class SquareRootFraction

    java.lang.Object
      SquareRootFraction

     class SquareRootFraction

extends Object

This class introduces all square roots of fractions (SRF) and features basic necessary operations with them. `SquareRootFraction`s are numbers in form (n*√nSqrt)/d, where all n, nSqrt, and d are integers (nSqrt is a non-negative integer).

Since:
  2014-04-01
Version:
  1.0
Author:
  Pavel Sikora <pavelsikora@mail.muni.cz>

Field Summary
`(package private) long` `d` denominator
`(package private) long` `n` whole part of the numerator
`(package private) long` `nSqrt` square-root-part of the numerator

Constructor Summary
`SquareRootFraction(Fraction F)` Constructs a `SquareRootFraction` from a `Fraction`.
`SquareRootFraction(long nn)` Constructs a `SquareRootFraction` from an integer.
`SquareRootFraction(long nn, long dd)` Constructs a `SquareRootFraction` from its numerator and denominator.

Method Summary
`(package private) Fraction` `convertToFraction()` Converts this `SquareRootFraction` to a `Fraction` if it indeed is a rational number.
`(package private) SquareRootFraction` `divide(SquareRootFraction d)` Divides this `SquareRootFraction` by another `SquareRootFraction`.
`(package private) boolean` `isEqual(SquareRootFraction c)` Checks if two `SquareRootFraction`s are equal.
`(package private) SquareRootFraction` `multiply(SquareRootFraction f)` Multiplies this `SquareRootFraction` by another `SquareRootFraction`.
`(package private) Fraction` `squared()` Squares `SquareRootFraction` producing a simple fraction.
`(package private) String` `toTeX()` Prints this `SquareRootFraction` formatted as TeX code.
`(package private) String` `toText()` Prints this `SquareRootFraction` formatted as text.

Methods inherited from class
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### d

    long d

  denominator

### n

    long n

  whole part of the numerator

### nSqrt

    long nSqrt

  square-root-part of the numerator

Constructor Detail

### SquareRootFraction

    SquareRootFraction(Fraction F)

  Constructs a `SquareRootFraction` from a `Fraction`. For example, `SquareRootFraction(new Fraction(1,2))` yields √2/2.

  Parameters:
    `F` - fraction to be taken the square root of
  Throws:
    `IllegalArgumentException` - Throws an exception if the fraction is negative.
    `IllegalArgumentException` - Throws an exception if the denominator would be zero.

### SquareRootFraction

    SquareRootFraction(long nn)

  Constructs a `SquareRootFraction` from an integer. For example, `SquareRootFraction(2)` yields √2.

  Parameters:
    `nn` - integer to be taken a square root of
  Throws:
    `IllegalArgumentException` - Throws an exception if the number is negative.

### SquareRootFraction

    SquareRootFraction(long nn,
                       long dd)

  Constructs a `SquareRootFraction` from its numerator and denominator. For example, `SquareRootFraction(1,2)` yields √2/2.

  Parameters:
    `nn` - nominator
    `dd` - denominator
  Throws:
    `IllegalArgumentException` - Throws an exception if the fraction is negative.
    `IllegalArgumentException` - Throws an exception if the denominator would be zero.

Method Detail

### convertToFraction

    Fraction convertToFraction()

  Converts this `SquareRootFraction` to a `Fraction` if it indeed is a rational number.

  Returns:
    the `SquareRootFraction` re-typed to `Fraction` with preserved value

### divide

    SquareRootFraction divide(SquareRootFraction d)

  Divides this `SquareRootFraction` by another `SquareRootFraction`.

  Parameters:
    `d` - divisor

### isEqual

    boolean isEqual(SquareRootFraction c)

  Checks if two `SquareRootFraction`s are equal.

  Parameters:
    `c` - comparand
  Returns:
    true if this `SquareRootFraction` is equal to the comparand, false otherwise

### multiply

    SquareRootFraction multiply(SquareRootFraction f)

  Multiplies this `SquareRootFraction` by another `SquareRootFraction`.

  Parameters:
    `f` - factor
  Returns:
    the product

### squared

    Fraction squared()

  Squares `SquareRootFraction` producing a simple fraction.

  Returns:
    the square of this `SquareRootFraction`

### toTeX

    String toTeX()

  Prints this `SquareRootFraction` formatted as TeX code.

  Returns:
    TeX code for this `SquareRootFraction`; for example, -3*√2/7 yields `-\frac{3\sqrt{2}}{7}`

### toText

    String toText()

  Prints this `SquareRootFraction` formatted as text.

  Returns:
    plain text description of this `SquareRootFraction`; for example, -3*√2/7 yields `-3*sqrt(2)/7`