import java.util.*; /** * A source of Quotes. * @author John Panzer * @version 1.0 * @see Quote */ public class QuoteSource { /** Internal storage for quotes */ private Quote[] _quotes = new Quote[] { new Quote("I'm astounded by people who want to 'know' the universe when it's hard enough to find your way around Chinatown. -- Woody Allen"), new Quote("Time is nature's way of keeping everything from happening at once. -- Anonymous"), new Quote("Future. That period of time in which our affairs prosper, our friends are true and our happiness is assured. -- Ambrose Bierce") }; /** A source of random numbers */ private Random _randSrc = new Random(); /** Returns a random quote */ public Quote next() { int nextQuoteIndex = Math.abs(_randSrc.nextInt()) % _quotes.length; // System.out.println("index = " + nextQuoteIndex); return _quotes[nextQuoteIndex]; } }