Constructor and Description |
---|
Rational(long numerator,
long denominator)
Initializes a new instance of the
Rational class. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Indicates whether the current object is equal to another object of the same type.
|
boolean |
equals(Rational other)
Indicates whether the current object is equal to another object of the same type.
|
static boolean |
equals(Rational rational,
Rational other)
Compares pair of
Rational . |
long |
getDenominator()
Gets the denominator.
|
long |
getNumerator()
Gets the numerator.
|
double |
getValue()
Gets the rational value.
|
int |
hashCode()
Returns a hash code for this instance.
|
String |
toString()
Returns a
System.String that represents this instance. |
public Rational(long numerator, long denominator)
Initializes a new instance of the Rational
class.
numerator
- The numerator.denominator
- The denominator.ArgumentOutOfRangeException
- denominator;Denominator should be grater then zeropublic final long getNumerator()
Gets the numerator.
public final long getDenominator()
Gets the denominator.
public final double getValue()
Gets the rational value.
public static boolean equals(Rational rational, Rational other)
Compares pair of Rational
.
rational
- Comparing item.other
- Other item.true
if objects are equal; otherwise false
.public final boolean equals(Rational other)
Indicates whether the current object is equal to another object of the same type.
other
- An object to compare with this object.true
if the current object is equal to the other
parameter; otherwise, false
.public boolean equals(Object obj)
Indicates whether the current object is equal to another object of the same type.
public int hashCode()
Returns a hash code for this instance.
Copyright © 2019. All rights reserved.