/** Rational is an interface for a class of objects 
 *  representing rational numbers.
 *
 * @author Adam Shaw
 */

public interface Rational {
    
    /**
     * returns the numerator of this rational number.
     * @return the numerator
     */
    public int num();    
    
    /**
     * returns the denominator of this rational number.
     * @return the denominator
     */
    public int denom();
    
    /** 
     * returns the reciprocal of this rational number.
     * @return the reciprocal
     */
    public Rational flipped();

    /** 
     * returns the negation of this rational number.
     * @return the negated rational
     */
    public Rational negated();

    /**
     * returns a new Rational with the value of the current Rational
     * ("this") plus the value of the argument "that".
     *
     * @param that a Rational
     * @return "this" plus "that"
     */
    public Rational plus(Rational that);

    /**
     * returns a new Rational with the value of the current Rational
     * ("this") minus the value of the argument "that".
     *
     * @param that a Rational
     * @return "this" minus "that"
     */
    public Rational minus(Rational that);

    /**
     * returns a new Rational with the value of the current Rational
     * ("this") times the value of the argument "that".
     *
     * @param that a Rational
     * @return "this" times "that"
     */
    public Rational times(Rational that);

    /**
     * returns a new Rational with the value of the current Rational
     * ("this") divided by the value of the argument "that".
     *
     * @param that a Rational
     * @return "this" divided by "that"
     */
    public Rational dividedBy(Rational that);

    /**
     * returns a numerical approximation of the current Rational
     * @return a double with value approximating this Rational
     */
    public double numericalApprox();
    
    /**
     * returns an approximation to the square root of the current Rational
     * @return the square root
     */
    public double sqrt();

    /** 
     * returns a textual representation of the current Rational
     * @return a textual representation of the current Rational
     */
    public String toString();

    /* EXTRA CREDIT FROM HERE ON... */

    /** raised, compareTo and equals are for extra credit */
    /** implement them if you have extra time */

    /**
     * returns a new Rational with the value of the current Rational
     * ("this") raised to the power p.
     *
     * @param p an int
     * @return this raised to the power p
     */
    public Rational raised(int p);
    
    /**
     * returns a neg int if this is less than o,
     * 0 if this is equal to o, 
     * a pos int if this is greater than o 
     *
     * @param o an Object
     * @return an int as per the compareTo contract
     * @throws ClassCastException if o is not a Rational
     */
    public int compareTo(Object o);

    /**
     * returns true if this and o are logically equal, false if
     * o is null or is not a Rational
     *
     * @param o an Object
     * @return logical equality of this and o
     */
    public boolean equals(Object o);

}
