package edu.bloomu.ch9c;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;

/**
 * Outputs a sorted list of random rational numbers.
 *
 * @author Drue Coles
 */
public class RationalSortDemo {

    public static void main(String[] args) { 
        ThreadLocalRandom rand = ThreadLocalRandom.current();
        RationalNumber[] rNumbers = new RationalNumber[10];
        for (int i = 0; i < rNumbers.length; i++) {
            int numerator = rand.nextInt(1, 10);
            int denominator = rand.nextInt(1, 10);
            rNumbers[i] = new RationalNumber(numerator, denominator);
        }

        Arrays.sort(rNumbers);
        for (RationalNumber num : rNumbers) {
            System.out.printf("%3s%n", num);
        }
    }
}